From 455890d7b3def8ec8c4482badc50435ad4ff3bd5 Mon Sep 17 00:00:00 2001 From: LemonNeko Date: Mon, 9 Jun 2025 08:14:11 +0800 Subject: [PATCH] fix(stage-tamagotchi): only show devtools in development (#201) --- apps/stage-tamagotchi/src-tauri/src/commands.rs | 2 +- apps/stage-tamagotchi/src-tauri/src/lib.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/stage-tamagotchi/src-tauri/src/commands.rs b/apps/stage-tamagotchi/src-tauri/src/commands.rs index bc081bad7..c6fb4d488 100644 --- a/apps/stage-tamagotchi/src-tauri/src/commands.rs +++ b/apps/stage-tamagotchi/src-tauri/src/commands.rs @@ -28,6 +28,6 @@ pub async fn open_chat_window(app: tauri::AppHandle) -> Result<(), tauri::Error> #[tauri::command] pub fn debug_println(msg: serde_json::Value) -> Result<(), tauri::Error> { - println!("{}", msg); + println!("{msg}"); Ok(()) } diff --git a/apps/stage-tamagotchi/src-tauri/src/lib.rs b/apps/stage-tamagotchi/src-tauri/src/lib.rs index 814243e58..9ba7d99a2 100644 --- a/apps/stage-tamagotchi/src-tauri/src/lib.rs +++ b/apps/stage-tamagotchi/src-tauri/src/lib.rs @@ -123,8 +123,12 @@ pub fn run() { let settings_item = MenuItem::with_id(app, "settings", "Settings", true, None::<&str>)?; let hide_item = MenuItem::with_id(app, "hide", "Hide", true, None::<&str>)?; let show_item = MenuItem::with_id(app, "show", "Show", true, None::<&str>)?; - let show_devtools_item = MenuItem::with_id(app, "show-devtools", "Show Devtools", true, None::<&str>)?; - let menu = Menu::with_items(app, &[&settings_item, &hide_item, &show_item, &show_devtools_item, &quit_item])?; + let menu = Menu::with_items(app, &[&settings_item, &hide_item, &show_item, &quit_item])?; + #[cfg(debug_assertions)] + { + let show_devtools_item = MenuItem::with_id(app, "show-devtools", "Show Devtools", true, None::<&str>)?; + menu.append_items(&[&show_devtools_item])?; + } let _ = TrayIconBuilder::new() .icon(app.default_window_icon().unwrap().clone()) // TODO: use custom icon @@ -146,17 +150,18 @@ pub fn run() { app_windows::settings::new_settings_window(app).unwrap(); } "hide" => { - let window = app.get_webview_window("settings"); + let window = app.get_webview_window("main"); if let Some(window) = window { let _ = window.hide(); } } "show" => { - let window = app.get_webview_window("settings"); + let window = app.get_webview_window("main"); if let Some(window) = window { let _ = window.show(); } } + #[cfg(debug_assertions)] "show-devtools" => { let window = app.get_webview_window("main"); if let Some(window) = window {