mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-06 13:44:21 +08:00
feat(settings): add dock icon visibility setting to desktop settings
- Introduced a new setting `show_dock_icon` in the `DesktopSettings` interface. - Updated `AppLifecycleSettingsCard` to manage dock icon visibility with a toggle switch. - Enhanced the API to read and write the new dock icon visibility setting. - Added corresponding translations for the new setting in both English and Chinese locales. - Updated tests to ensure the default behavior of showing the dock icon and proper round-trip functionality for settings.
This commit is contained in:
@@ -47,10 +47,25 @@ pub struct TabSettings {
|
||||
pub address: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct DesktopSettings {
|
||||
#[serde(default)]
|
||||
pub silent_start: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub show_dock_icon: bool,
|
||||
}
|
||||
|
||||
impl Default for DesktopSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
silent_start: false,
|
||||
show_dock_icon: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
impl TabSettings {
|
||||
@@ -324,6 +339,30 @@ mod tests {
|
||||
assert_eq!(store.port_settings().await.unwrap(), settings);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn desktop_settings_show_the_dock_icon_by_default_and_round_trip() {
|
||||
let store = Store::connect("sqlite::memory:").await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
store.desktop_settings().await.unwrap(),
|
||||
DesktopSettings::default()
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_str::<DesktopSettings>(r#"{"silent_start":true}"#).unwrap(),
|
||||
DesktopSettings {
|
||||
silent_start: true,
|
||||
show_dock_icon: true,
|
||||
}
|
||||
);
|
||||
let settings = DesktopSettings {
|
||||
silent_start: true,
|
||||
show_dock_icon: false,
|
||||
};
|
||||
store.set_desktop_settings(settings).await.unwrap();
|
||||
|
||||
assert_eq!(store.desktop_settings().await.unwrap(), settings);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn proxy_settings_are_write_only_and_preserve_an_unchanged_password() {
|
||||
let store = Store::connect("sqlite::memory:").await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user