mini timer window blank due to hash routing mismatch

This commit is contained in:
2026-02-18 15:23:20 +02:00
parent 4fd304516a
commit df4970d29c

View File

@@ -1132,7 +1132,9 @@ pub fn open_mini_timer(app: tauri::AppHandle) -> Result<(), String> {
return Ok(()); return Ok(());
} }
tauri::WebviewWindowBuilder::new(&app, "mini-timer", WebviewUrl::App("/mini-timer".into())) // Load root URL — the app uses hash-based routing (createWebHashHistory),
// so we set the hash fragment via eval after the window is created.
let win = tauri::WebviewWindowBuilder::new(&app, "mini-timer", WebviewUrl::App(Default::default()))
.title("Timer") .title("Timer")
.inner_size(300.0, 64.0) .inner_size(300.0, 64.0)
.always_on_top(true) .always_on_top(true)
@@ -1142,6 +1144,9 @@ pub fn open_mini_timer(app: tauri::AppHandle) -> Result<(), String> {
.build() .build()
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
// Navigate Vue Router to the mini-timer route via hash
win.eval("window.location.hash = '/mini-timer'").ok();
Ok(()) Ok(())
} }
@@ -1150,6 +1155,11 @@ pub fn close_mini_timer(app: tauri::AppHandle) -> Result<(), String> {
if let Some(window) = app.get_webview_window("mini-timer") { if let Some(window) = app.get_webview_window("mini-timer") {
window.close().map_err(|e| e.to_string())?; window.close().map_err(|e| e.to_string())?;
} }
// Show and focus the main window
if let Some(main) = app.get_webview_window("main") {
main.show().ok();
main.set_focus().ok();
}
Ok(()) Ok(())
} }