From 0652753a0555684c1b3049594c872d641ab7d420 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Tue, 27 Dec 2022 23:52:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0Windows=E4=B8=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/Cargo.toml | 2 ++ src-tauri/src/main.rs | 59 +++++++++++++++---------------------------- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d829449..0489c7d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -22,6 +22,8 @@ image = "0.24.5" home = "0.5" tauri-utils = "1.2.1" tauri-plugin-window-state = { git = "https://github.com/tauri-apps/tauri-plugin-window-state", branch = "dev"} + +[target.'cfg(target_os = "linux")'.dependencies] webkit2gtk = "0.18.0" # webbrowser = "0.8.2" # wry = "0.23.4" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 0ac2093..171f041 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -9,51 +9,34 @@ use app::{get_menu, menu_event_handle}; pub fn run_app() { let system_tray = get_system_tray(); + let (pake_config, tauri_config) = get_pake_config(); + let data_dir = get_data_dir(tauri_config); #[cfg(target_os = "macos")] - { - let (pake_config, _) = get_pake_config(); + let tauri_app = { let menu = get_menu(); tauri::Builder::default() .menu(menu) .on_menu_event(menu_event_handle) - .system_tray(system_tray) - .on_system_tray_event(system_tray_handle) - .plugin(tauri_plugin_window_state::Builder::default().build()) - .invoke_handler(tauri::generate_handler![]) - .setup(|app| { - let _window = get_window(app, pake_config, std::path::PathBuf::new()); - #[cfg(feature = "devtools")] - { - app.get_window("pake").unwrap().open_devtools(); - } - Ok(()) - }) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } + }; #[cfg(any(target_os = "linux", target_os = "windows"))] - { - let (pake_config, tauri_config) = get_pake_config(); - let data_dir = get_data_dir(tauri_config); - // let menu = get_menu(); + let tauri_app = { tauri::Builder::default() - // .menu(menu) - // .on_menu_event(menu_event_handle) - .system_tray(system_tray) - .on_system_tray_event(system_tray_handle) - .plugin(tauri_plugin_window_state::Builder::default().build()) - .invoke_handler(tauri::generate_handler![]) - .setup(|app| { - let _window = get_window(app, pake_config, data_dir); - #[cfg(feature = "devtools")] - { - app.get_window("pake").unwrap().open_devtools(); - } - Ok(()) - }) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); - } + }; + tauri_app + .system_tray(system_tray) + .on_system_tray_event(system_tray_handle) + .plugin(tauri_plugin_window_state::Builder::default().build()) + .invoke_handler(tauri::generate_handler![]) + .setup(|app| { + let _window = get_window(app, pake_config, data_dir); + #[cfg(feature = "devtools")] + { + _window.open_devtools(); + } + Ok(()) + }) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } fn main() {