Skip to content

Commit

Permalink
feat: 支持从托盘菜单中重启应用 (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb authored Nov 15, 2024
1 parent 8d69c86 commit ce923d0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/components/Tray/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { emit } from "@tauri-apps/api/event";
import { Menu, MenuItem, PredefinedMenuItem } from "@tauri-apps/api/menu";
import { resolveResource } from "@tauri-apps/api/path";
import { TrayIcon, type TrayIconOptions } from "@tauri-apps/api/tray";
import { exit } from "@tauri-apps/plugin-process";
import { exit, relaunch } from "@tauri-apps/plugin-process";
import { open } from "@tauri-apps/plugin-shell";

const Tray = () => {
Expand Down Expand Up @@ -104,9 +104,13 @@ const Tray = () => {
text: `${t("component.tray.label.version")} ${appVersion}`,
enabled: false,
}),
MenuItem.new({
text: t("component.tray.label.relaunch"),
action: relaunch,
}),
MenuItem.new({
text: t("component.tray.label.exit"),
action: () => exit(1),
action: () => exit(0),
}),
]);

Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@
"check_update": "Check Update",
"open_source_address": "Open Source Address",
"version": "Version",
"relaunch": "Relaunch",
"exit": "Exit"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@
"check_update": "アップデートを確認",
"open_source_address": "ギットハブ",
"version": "バージョン",
"relaunch": "再開",
"exit": "終了する"
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@
"check_update": "检查更新",
"open_source_address": "开源地址",
"version": "版本",
"exit": "退出"
"relaunch": "重启应用",
"exit": "退出应用"
}
},
"note_modal": {
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@
"check_update": "檢查更新",
"open_source_address": "開源地址",
"version": "版本",
"exit": "退出"
"relaunch": "重啓應用",
"exit": "退出應用"
}
},
"note_modal": {
Expand Down

0 comments on commit ce923d0

Please sign in to comment.