From 474ddc230a9af7e40d0c3c3f83429e71c3d67152 Mon Sep 17 00:00:00 2001 From: Ayideyia <150233177+Ayideyia@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:25:42 -0700 Subject: [PATCH] feat: Supports downloading the latest app, but manual replacement is required --- frontend/src/lang/locale/en.ts | 1 + frontend/src/lang/locale/zh.ts | 1 + frontend/src/views/AboutView.vue | 33 ++++++++++++++++---------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/frontend/src/lang/locale/en.ts b/frontend/src/lang/locale/en.ts index ed87120..6c29e77 100644 --- a/frontend/src/lang/locale/en.ts +++ b/frontend/src/lang/locale/en.ts @@ -577,6 +577,7 @@ export default { restart: 'Restart APP', noDownloadLink: 'No download link found', updateSuccessfulRestart: 'Update completed, please restart the App', + updateSuccessfulReplace: 'Download completed, please manually replace the App', updateSuccessful: 'Update completed', newVersion: 'New version found', latestVersion: 'Already the latest version' diff --git a/frontend/src/lang/locale/zh.ts b/frontend/src/lang/locale/zh.ts index b4427d6..421697f 100644 --- a/frontend/src/lang/locale/zh.ts +++ b/frontend/src/lang/locale/zh.ts @@ -576,6 +576,7 @@ export default { restart: '重启软件', noDownloadLink: '没有发现下载链接', updateSuccessfulRestart: '更新完成,请重启软件', + updateSuccessfulReplace: '下载完成,请手动替换软件', updateSuccessful: '更新完成', newVersion: '发现新版本', latestVersion: '已经是最新版本了' diff --git a/frontend/src/views/AboutView.vue b/frontend/src/views/AboutView.vue index 62d81e0..9d01b7e 100644 --- a/frontend/src/views/AboutView.vue +++ b/frontend/src/views/AboutView.vue @@ -2,7 +2,7 @@ import { useI18n } from 'vue-i18n' import { ref, computed } from 'vue' -import { useMessage } from '@/hooks' +import { useMessage, useAlert } from '@/hooks' import { useEnvStore } from '@/stores' import { Download, @@ -12,7 +12,8 @@ import { RestartApp, UnzipZIPFile, Makedir, - Removefile + Removefile, + AbsolutePath } from '@/bridge' import { APP_TITLE, @@ -34,6 +35,7 @@ const remoteVersion = ref(APP_VERSION) const needUpdate = computed(() => APP_VERSION !== remoteVersion.value) const { t } = useI18n() +const { alert } = useAlert() const { message } = useMessage() const envStore = useEnvStore() @@ -49,11 +51,6 @@ const downloadApp = async () => { const { appName, os } = envStore.env - if (os === 'darwin') { - message.error('Updates not supported') - return - } - const tmpFile = 'data/.cache/gui.zip' try { @@ -67,20 +64,22 @@ const downloadApp = async () => { message.destroy(id) }) - await Movefile(appName, appName + '.bak') - - await UnzipZIPFile(tmpFile, '.') - - const suffix = { windows: '.exe', linux: '' }[os] - - await Movefile(APP_TITLE + suffix, appName) + if (os !== 'darwin') { + await Movefile(appName, appName + '.bak') + await UnzipZIPFile(tmpFile, '.') + const suffix = { windows: '.exe', linux: '' }[os] + await Movefile(APP_TITLE + suffix, appName) + message.success('about.updateSuccessfulRestart') + needRestart.value = true + } else { + await UnzipZIPFile(tmpFile, 'data') + alert('common.success', 'about.updateSuccessfulReplace') + BrowserOpenURL(await AbsolutePath('data')) + } await Removefile(tmpFile) await ignoredError(Removefile, 'data/rolling-release') - - needRestart.value = true - message.success('about.updateSuccessfulRestart') } catch (error: any) { console.log(error) message.error(error, 5_000)