fix: silent start (#150)

This commit is contained in:
FoundTheWOUT 2022-08-09 14:14:06 +08:00 committed by GitHub
parent 4942b0fca5
commit 5aa7d5ffe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -91,16 +91,16 @@ impl Core {
let clash = self.clash.lock();
let verge = self.verge.lock();
let silent_start = verge.enable_silent_start.clone();
// let silent_start = verge.enable_silent_start.clone();
let auto_launch = verge.enable_auto_launch.clone();
// silent start
if silent_start.unwrap_or(false) {
let window = self.window.lock();
window.as_ref().map(|win| {
win.hide().unwrap();
});
}
// if silent_start.unwrap_or(false) {
// let window = self.window.lock();
// window.as_ref().map(|win| {
// win.hide().unwrap();
// });
// }
let mut sysopt = self.sysopt.lock();

View File

@ -158,8 +158,15 @@ fn main() -> std::io::Result<()> {
builder = builder.menu(Menu::new().add_submenu(submenu_file));
}
let mut context = tauri::generate_context!();
let verge = Verge::new();
for win in context.config_mut().tauri.windows.iter_mut() {
if verge.enable_silent_start.unwrap_or(false) {
win.visible = false;
}
}
builder
.build(tauri::generate_context!())
.build(context)
.expect("error while running tauri application")
.run(|app_handle, e| match e {
tauri::RunEvent::ExitRequested { api, .. } => {