Skip to content

Commit

Permalink
feat: Supports downloading the latest app, but manual replacement is …
Browse files Browse the repository at this point in the history
…required
  • Loading branch information
Ayideyia committed Sep 20, 2024
1 parent 5c2cb33 commit 474ddc2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions frontend/src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/locale/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ export default {
restart: '重启软件',
noDownloadLink: '没有发现下载链接',
updateSuccessfulRestart: '更新完成,请重启软件',
updateSuccessfulReplace: '下载完成,请手动替换软件',
updateSuccessful: '更新完成',
newVersion: '发现新版本',
latestVersion: '已经是最新版本了'
Expand Down
33 changes: 16 additions & 17 deletions frontend/src/views/AboutView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,7 +12,8 @@ import {
RestartApp,
UnzipZIPFile,
Makedir,
Removefile
Removefile,
AbsolutePath
} from '@/bridge'
import {
APP_TITLE,
Expand All @@ -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()
Expand All @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit 474ddc2

Please sign in to comment.