diff --git a/src-tauri/src/core/verge.rs b/src-tauri/src/core/verge.rs index f3a1f85..f5a728f 100644 --- a/src-tauri/src/core/verge.rs +++ b/src-tauri/src/core/verge.rs @@ -31,6 +31,9 @@ pub struct VergeConfig { /// can the app auto startup pub enable_auto_launch: Option, + /// not show the window on launch + pub enable_silent_start: Option, + /// set system proxy pub enable_system_proxy: Option, @@ -197,6 +200,9 @@ impl Verge { if patch.traffic_graph.is_some() { self.config.traffic_graph = patch.traffic_graph; } + if patch.enable_silent_start.is_some() { + self.config.enable_silent_start = patch.enable_silent_start; + } // should update system startup if patch.enable_auto_launch.is_some() { diff --git a/src-tauri/src/utils/resolve.rs b/src-tauri/src/utils/resolve.rs index 16a7129..244345a 100644 --- a/src-tauri/src/utils/resolve.rs +++ b/src-tauri/src/utils/resolve.rs @@ -4,8 +4,6 @@ use tauri::{App, AppHandle, Manager}; /// handle something when start app pub fn resolve_setup(app: &App) { - resolve_window(app); - // setup a simple http server for singleton server::embed_server(&app.handle()); @@ -46,6 +44,8 @@ pub fn resolve_setup(app: &App) { .get_item("system_proxy") .set_selected(enable)); }); + + resolve_window(app, verge.config.enable_silent_start.clone()); } /// reset system proxy @@ -57,9 +57,16 @@ pub fn resolve_reset(app_handle: &AppHandle) { } /// customize the window theme -fn resolve_window(app: &App) { +fn resolve_window(app: &App, hide: Option) { let window = app.get_window("main").unwrap(); + // silent start + hide.map(|hide| { + if hide { + window.hide().unwrap(); + } + }); + #[cfg(target_os = "windows")] { use window_shadows::set_shadow; diff --git a/src/components/setting/setting-system.tsx b/src/components/setting/setting-system.tsx index a09b3b4..be49d64 100644 --- a/src/components/setting/setting-system.tsx +++ b/src/components/setting/setting-system.tsx @@ -19,6 +19,7 @@ const SettingSystem = ({ onError }: Props) => { const { enable_tun_mode, enable_auto_launch, + enable_silent_start, enable_system_proxy, system_proxy_bypass, enable_proxy_guard, @@ -59,6 +60,20 @@ const SettingSystem = ({ onError }: Props) => { + + + onChangeData({ enable_silent_start: e })} + onGuard={(e) => patchVergeConfig({ enable_silent_start: e })} + > + + + +