fix(stage-tamagotchi): focus settings window if already exist

This commit is contained in:
Makito
2025-08-29 23:57:01 +09:00
parent 24d678b3e3
commit 9e226184b3
2 changed files with 7 additions and 7 deletions
@@ -3,12 +3,18 @@ use std::{path::Path, sync::Arc};
use anyhow::{Ok, Result};
#[cfg(target_os = "macos")]
use tauri::TitleBarStyle;
use tauri::{Runtime, WebviewUrl, WebviewWindowBuilder, webview::PageLoadPayload};
use tauri::{Manager, Runtime, WebviewUrl, WebviewWindowBuilder, webview::PageLoadPayload};
pub fn new_settings_window<R: Runtime>(
app: &tauri::AppHandle<R>,
page_load_handler: Option<Arc<dyn Fn(tauri::WebviewWindow<R>, PageLoadPayload) + Send + Sync>>,
) -> Result<tauri::WebviewWindow<R>> {
if let Some(window) = app.get_webview_window("settings") {
_ = window.show();
_ = window.set_focus();
return Ok(window);
}
let mut builder = WebviewWindowBuilder::new(
app,
"settings",
@@ -151,12 +151,6 @@ pub fn run() {
app.exit(0);
}
"settings" => {
let window = app.get_webview_window("settings");
if let Some(window) = window {
let _ = window.show();
return;
}
app::windows::settings::new_settings_window(app, None).unwrap();
}
"window-mode.fade-on-hover" => {