From b7c34b0d4299a1778ae88de9fca04a226f1736f2 Mon Sep 17 00:00:00 2001 From: josc146 Date: Fri, 9 Jun 2023 20:38:19 +0800 Subject: [PATCH] improve update process for macOS and Linux --- backend-golang/app.go | 12 +++++---- frontend/src/_locales/zh-hans/main.json | 3 ++- frontend/src/utils/index.tsx | 34 +++++++++++++------------ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/backend-golang/app.go b/backend-golang/app.go index 901b7fd..9eadc39 100644 --- a/backend-golang/app.go +++ b/backend-golang/app.go @@ -53,12 +53,14 @@ func (a *App) UpdateApp(url string) (broken bool, err error) { } return false, err } - name, err := os.Executable() - if err != nil { - return false, err + if runtime.GOOS == "windows" { + name, err := os.Executable() + if err != nil { + return false, err + } + exec.Command(name, os.Args[1:]...).Start() + wruntime.Quit(a.ctx) } - exec.Command(name, os.Args[1:]...).Start() - wruntime.Quit(a.ctx) return false, nil } diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index 62b97ac..a607495 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -141,5 +141,6 @@ "Current Strategy": "当前Strategy", "MacOS is not yet supported for performing this operation, please do it manually.": "MacOS尚未支持此操作, 请手动执行", "Linux is not yet supported for performing this operation, please do it manually.": "Linux尚未支持此操作, 请手动执行", - "On Linux system, you must manually install python dependencies.": "在Linux系统下, 你必须手动安装python依赖" + "On Linux system, you must manually install python dependencies.": "在Linux系统下, 你必须手动安装python依赖", + "Update completed, please restart the program.": "更新完成, 请重启程序" } \ No newline at end of file diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index 5554982..91655bf 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -16,7 +16,6 @@ import { Button } from '@fluentui/react-components'; import { Language, Languages, SettingsType } from '../pages/Settings'; import { ModelSourceItem } from '../pages/Models'; import { ModelConfig, ModelParameters } from '../pages/Configs'; -import { BrowserOpenURL } from '../../wailsjs/runtime'; export type Cache = { models: ModelSourceItem[] @@ -250,24 +249,27 @@ export async function checkUpdate(notifyEvenLatest: boolean = false) { `https://gitee.com/josc146/RWKV-Runner/releases/download/${versionTag}/${asset.name}`; toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => { DeleteFile('cache.json'); - if (commonStore.platform != 'darwin') { - toast(t('Downloading update, please wait. If it is not completed, please manually download the program from GitHub and replace the original program.'), { - type: 'info', - position: 'bottom-left', - autoClose: 20000 - }); - setTimeout(() => { - UpdateApp(updateUrl).catch((e) => { - toast(t('Update Error') + ' - ' + e.message || e, { - type: 'error', + toast(t('Downloading update, please wait. If it is not completed, please manually download the program from GitHub and replace the original program.'), { + type: 'info', + position: 'bottom-left', + autoClose: 30000 + }); + setTimeout(() => { + UpdateApp(updateUrl).then(() => { + toast(t('Update completed, please restart the program.'), { + type: 'success', position: 'bottom-left', autoClose: false - }); + } + ); + }).catch((e) => { + toast(t('Update Error') + ' - ' + e.message || e, { + type: 'error', + position: 'bottom-left', + autoClose: false }); - }, 500); - } else { - BrowserOpenURL(updateUrl); - } + }); + }, 500); }, { autoClose: false, position: 'bottom-left'