fix: allow closing last session tab and restore DevTools shortcut
Closing the sole remaining non-welcome tab now resets to welcome; enable Tauri devtools, menu/shortcut toggle, and copy release artifacts from CARGO_TARGET_DIR. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
da95113e6d
commit
188f3556ed
14 files changed
+95
-38
No files matched your search
@@ -31,7 +31,7 @@ sha2 = "0.10"
|
||||
hmac = "0.12"
|
||||
portable-pty = "0.9"
|
||||
serialport = { version = "4.8", default-features = false, features = ["libudev"] }
|
||||
tauri = { version = "2.8", features = [] }
|
||||
tauri = { version = "2.8", features = ["devtools"] }
|
||||
tauri-plugin-deep-link = "2"
|
||||
tauri-plugin-single-instance = "2"
|
||||
thiserror = "2.0"
|
||||
|
||||
@@ -70,3 +70,17 @@ pub fn clipboard_write_text(text: String) -> Result<(), String> {
|
||||
let mut clipboard = arboard::Clipboard::new().map_err(|error| error.to_string())?;
|
||||
clipboard.set_text(text).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn toggle_devtools(app: AppHandle) -> Result<bool, String> {
|
||||
let window = app
|
||||
.get_webview_window("main")
|
||||
.ok_or_else(|| "主窗口不存在".to_string())?;
|
||||
if window.is_devtools_open() {
|
||||
window.close_devtools();
|
||||
Ok(false)
|
||||
} else {
|
||||
window.open_devtools();
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
+18
-22
@@ -73,6 +73,7 @@ pub fn run() {
|
||||
commands::system::toggle_maximize,
|
||||
commands::system::clipboard_read_text,
|
||||
commands::system::clipboard_write_text,
|
||||
commands::system::toggle_devtools,
|
||||
commands::deep_link::take_pending_ssh_links,
|
||||
commands::local_terminal::local_list_shells,
|
||||
commands::local_terminal::local_create_shell,
|
||||
@@ -244,20 +245,18 @@ pub fn run() {
|
||||
let settings = MenuItemBuilder::with_id("open-settings", "设置")
|
||||
.accelerator("CmdOrCtrl+,")
|
||||
.build(app)?;
|
||||
let view_menu = SubmenuBuilder::new(app, "视图").item(&settings);
|
||||
#[cfg(debug_assertions)]
|
||||
let view_menu = {
|
||||
let devtools =
|
||||
MenuItemBuilder::with_id("toggle-devtools", "Toggle Developer Tools")
|
||||
.accelerator(if cfg!(target_os = "macos") {
|
||||
"CmdOrCtrl+Alt+I"
|
||||
} else {
|
||||
"F12"
|
||||
})
|
||||
.build(app)?;
|
||||
view_menu.separator().item(&devtools)
|
||||
};
|
||||
let view_menu = view_menu.build()?;
|
||||
let devtools = MenuItemBuilder::with_id("toggle-devtools", "开发者工具")
|
||||
.accelerator(if cfg!(target_os = "macos") {
|
||||
"CmdOrCtrl+Alt+I"
|
||||
} else {
|
||||
"F12"
|
||||
})
|
||||
.build(app)?;
|
||||
let view_menu = SubmenuBuilder::new(app, "视图")
|
||||
.item(&settings)
|
||||
.separator()
|
||||
.item(&devtools)
|
||||
.build()?;
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
let window_menu = SubmenuBuilder::new(app, "窗口")
|
||||
.minimize_with_text("最小化")
|
||||
@@ -291,14 +290,11 @@ pub fn run() {
|
||||
let _ = app.emit("menu:open-settings", ());
|
||||
}
|
||||
"toggle-devtools" => {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
if window.is_devtools_open() {
|
||||
window.close_devtools();
|
||||
} else {
|
||||
window.open_devtools();
|
||||
}
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
if window.is_devtools_open() {
|
||||
window.close_devtools();
|
||||
} else {
|
||||
window.open_devtools();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user