From 8d318a2146194936b030f2fb8bf571ec7886f74c Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Sat, 9 May 2026 18:08:06 +0800 Subject: [PATCH] fix(updater): fix restart after update --- src-tauri/capabilities/default.json | 1 + src/components/layout/UpdateDialog.vue | 2 +- src/composables/useAppUpdater.ts | 8 ++++++-- src/i18n/locales/en.ts | 5 +++-- src/i18n/locales/zh-CN.ts | 5 +++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 26ab9c7b69..3451ced340 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -23,6 +23,7 @@ "fs:default", "fs:allow-write-text-file", "fs:allow-read-text-file", + "process:default", "shell:allow-open", "updater:default", "window-state:default" diff --git a/src/components/layout/UpdateDialog.vue b/src/components/layout/UpdateDialog.vue index 542165f222..09d0565ea1 100644 --- a/src/components/layout/UpdateDialog.vue +++ b/src/components/layout/UpdateDialog.vue @@ -84,7 +84,7 @@ const renderedNotes = computed(() => { {{ t("updates.openRelease") }} - {{ t("updates.exitAndUpdate") }} + {{ t("updates.restart") }} {{ t("updates.reopenHint") }} diff --git a/src/composables/useAppUpdater.ts b/src/composables/useAppUpdater.ts index 41f6be28c8..c6a253032f 100644 --- a/src/composables/useAppUpdater.ts +++ b/src/composables/useAppUpdater.ts @@ -91,8 +91,12 @@ export function useAppUpdater() { async function restartApp() { if (!isTauriRuntime()) return; - const { exit } = await import("@tauri-apps/plugin-process"); - await exit(0); + try { + const { relaunch } = await import("@tauri-apps/plugin-process"); + await relaunch(); + } catch (e: any) { + toast(t("updates.restartFailed", { error: e?.message || String(e) }), 5000); + } } return { diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 9d8558211f..60229dd431 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -51,9 +51,10 @@ export default { downloadAndInstall: "Download & Install", downloading: "Downloading {progress}%", downloadFailed: "Update download failed: {error}", - restart: "Restart Now", + restart: "Exit & Restart", + restartFailed: "Failed to restart app: {error}", exitAndUpdate: "Exit & Update", - reopenHint: "Changes will take effect when you reopen the app", + reopenHint: "The app will relaunch to finish updating", }, sidebar: { connections: "CONNECTIONS", diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 37044e8dc7..76da0152a2 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -50,9 +50,10 @@ export default { downloadAndInstall: "下载并安装", downloading: "下载中 {progress}%", downloadFailed: "更新下载失败:{error}", - restart: "立即重启", + restart: "退出并重启", + restartFailed: "重启应用失败:{error}", exitAndUpdate: "退出并更新", - reopenHint: "更新将在重新打开应用后生效", + reopenHint: "应用将自动重启以完成更新", }, sidebar: { connections: "连接",