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:
@@ -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(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user