improve updates

This commit is contained in:
josc146
2023-05-20 10:52:25 +08:00
parent 66a5a903c5
commit 1573c09db0
5 changed files with 34 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import {
DeleteFile,
DownloadFile,
FileExists,
ListDirFiles,
@@ -188,6 +189,13 @@ export function forceDownloadProgramFiles() {
});
}
export function deletePythonProgramFiles() {
manifest.programFiles.forEach(({path}) => {
if (path.endsWith('.py'))
DeleteFile(path);
});
}
export async function checkUpdate() {
let updateUrl = '';
await fetch('https://api.github.com/repos/josstorer/RWKV-Runner/releases/latest').then((r) => {
@@ -198,7 +206,16 @@ export async function checkUpdate() {
if (versionTag.replace('v', '') > manifest.version) {
updateUrl = `https://github.com/josStorer/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`;
toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => {
UpdateApp(updateUrl);
deletePythonProgramFiles();
setTimeout(() => {
UpdateApp(updateUrl).catch((e) => {
toast(t('Update Error, Please restart this program') + ' - ' + e.message, {
type: 'error',
position: 'bottom-left',
autoClose: false
});
});
}, 500);
});
}
} else {