Skip to content

Commit 8d2ceef

Browse files
committed
feat(tray): 添加托盘菜单'重启程序'选项
- 在右键托盘菜单中添加'重启程序'菜单项 - 支持多语言:简体中文、繁体中文、英文 - 点击后调用 Tauri 的 restart() 方法一键重启软件
1 parent 9cd16ec commit 8d2ceef

4 files changed

Lines changed: 7 additions & 0 deletions

File tree

src-tauri/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
"openlist_extra_args": "OpenList Extra Startup Args",
206206
"quit": "Quit",
207207
"tray_show": "Show Main Window",
208+
"tray_restart": "Restart Program",
208209
"open_log_dir": "Open Log Folder",
209210
"export_diagnostics": "Export Diagnostics",
210211
"diagnostics_exported": "Diagnostics exported",

src-tauri/locales/zh-cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
"openlist_extra_args": "OpenList 启动参数",
206206
"quit": "退出",
207207
"tray_show": "显示主窗口",
208+
"tray_restart": "重启程序",
208209
"open_log_dir": "打开日志目录",
209210
"export_diagnostics": "导出诊断包",
210211
"diagnostics_exported": "诊断包已导出",

src-tauri/locales/zh-hant.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
"openlist_extra_args": "OpenList 額外啟動參數",
206206
"quit": "退出",
207207
"tray_show": "顯示主視窗",
208+
"tray_restart": "重啟程式",
208209
"open_log_dir": "打開日誌目錄",
209210
"export_diagnostics": "匯出診斷包",
210211
"diagnostics_exported": "診斷包已匯出",

src-tauri/src/tray.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ impl Tray {
1414
let menu = tauri::menu::MenuBuilder::new(app)
1515
.items(&[
1616
&build_item("show", locale.get("tray_show"))?,
17+
&build_item("restart", locale.get("tray_restart"))?,
1718
&build_item("quit", locale.get("quit"))?,
1819
])
1920
.build()
@@ -45,6 +46,9 @@ impl Tray {
4546
let _ = window.toggle_visibility(Some(true));
4647
}
4748
}
49+
"restart" => {
50+
app.restart();
51+
}
4852
"quit" => {
4953
app.app_quit();
5054
}

0 commit comments

Comments
 (0)