fix(tauri): ensure devtools opens after window is visible
- window.show() before open_devtools() since visible=false in config - Add 1s delay in spawned thread for WebView init completion
This commit is contained in:
@@ -59,7 +59,17 @@ pub fn run() {
|
||||
// Release 构建也打开 DevTools(临时:排查 Windows 网络问题)
|
||||
// 排查完成后可移除或改为快捷键触发
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.open_devtools();
|
||||
// 窗口默认 visible=false,必须先 show 再 open_devtools 才有效
|
||||
let _ = window.show();
|
||||
let _ = window.set_focus();
|
||||
// 延迟 1s 等 WebView 完全初始化
|
||||
let app_handle = app.handle().clone();
|
||||
std::thread::spawn(move || {
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
if let Some(w) = app_handle.get_webview_window("main") {
|
||||
let _ = w.open_devtools();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// macOS 自定义菜单栏(中文本地化)
|
||||
|
||||
Reference in New Issue
Block a user