fix: mini timer window blank due to hash routing mismatch

The app uses createWebHashHistory but the mini timer window was
opened with WebviewUrl::App("/mini-timer") which sets the URL path,
not the hash fragment. Vue Router never matched the route, so the
Dashboard rendered in a 300x64 window (appearing blank). Now loads
root URL and sets window.location.hash via eval. Also shows/focuses
the main window when closing the mini timer.
This commit is contained in:
Your Name
2026-02-18 15:23:20 +02:00
parent 8c8de6a2a7
commit 28eb7a2639

View File

@@ -1132,7 +1132,9 @@ pub fn open_mini_timer(app: tauri::AppHandle) -> Result<(), String> {
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")
.inner_size(300.0, 64.0)
.always_on_top(true)
@@ -1142,6 +1144,9 @@ pub fn open_mini_timer(app: tauri::AppHandle) -> Result<(), String> {
.build()
.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(())
}
@@ -1150,6 +1155,11 @@ pub fn close_mini_timer(app: tauri::AppHandle) -> Result<(), String> {
if let Some(window) = app.get_webview_window("mini-timer") {
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(())
}