mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-09 21:36:52 +08:00
refactor(desktop): make build_tray_menu function more generic
Replace specific tauri::App<R> parameter with generic Manager<R> trait to improve flexibility and allow the function to work with different Tauri manager types while maintaining the same functionality.
This commit is contained in:
parent
32ab92cd64
commit
b10e9fa2e9
2 changed files with 4 additions and 4 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
4.6.3-develop10
|
||||
4.6.3-develop11
|
||||
|
|
|
@ -219,7 +219,7 @@ fn build_server_url(port: u16, base_url: &Option<String>) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn build_tray_menu<R: tauri::Runtime>(app: &tauri::App<R>, minimize_to_tray: bool, startup_enabled: bool) -> Result<tauri::menu::Menu<R>, tauri::Error> {
|
||||
fn build_tray_menu<R: tauri::Runtime, M: tauri::Manager<R>>(app: &M, minimize_to_tray: bool, startup_enabled: bool) -> Result<tauri::menu::Menu<R>, tauri::Error> {
|
||||
let open_item = MenuItemBuilder::with_id("open", "Open").build(app)?;
|
||||
let restart_item = MenuItemBuilder::with_id("restart", "Restart Server").build(app)?;
|
||||
let minimize_item = CheckMenuItemBuilder::with_id("minimize_startup", "Minimize to Tray on Startup")
|
||||
|
@ -597,7 +597,7 @@ pub fn run() {
|
|||
let minimize_to_tray = *current;
|
||||
let startup_enabled = *STARTUP_ENABLED.lock().unwrap();
|
||||
|
||||
if let Ok(tray_menu) = build_tray_menu(&app.handle(), minimize_to_tray, startup_enabled) {
|
||||
if let Ok(tray_menu) = build_tray_menu(app, minimize_to_tray, startup_enabled) {
|
||||
if let Some(tray) = TRAY_HANDLE.lock().unwrap().as_ref() {
|
||||
let _ = tray.set_menu(Some(tray_menu));
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ pub fn run() {
|
|||
let minimize_to_tray = *MINIMIZE_TO_TRAY.lock().unwrap();
|
||||
let startup_enabled = *current;
|
||||
|
||||
if let Ok(tray_menu) = build_tray_menu(&app.handle(), minimize_to_tray, startup_enabled) {
|
||||
if let Ok(tray_menu) = build_tray_menu(app, minimize_to_tray, startup_enabled) {
|
||||
if let Some(tray) = TRAY_HANDLE.lock().unwrap().as_ref() {
|
||||
let _ = tray.set_menu(Some(tray_menu));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue