improve update process for macOS and Linux

This commit is contained in:
josc146 2023-06-09 20:38:19 +08:00
parent a95fbbbd78
commit b7c34b0d42
3 changed files with 27 additions and 22 deletions

View File

@ -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
}

View File

@ -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.": "更新完成, 请重启程序"
}

View File

@ -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'