feat: complete check for update
This commit is contained in:
parent
36c23deef8
commit
218bebe09d
|
@ -12,6 +12,7 @@ import { BrowserOpenURL } from 'wailsjs/runtime/runtime.js'
|
||||||
import Log from '@/components/icons/Log.vue'
|
import Log from '@/components/icons/Log.vue'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import Help from '@/components/icons/Help.vue'
|
import Help from '@/components/icons/Help.vue'
|
||||||
|
import usePreferencesStore from 'stores/preferences.js'
|
||||||
|
|
||||||
const themeVars = useThemeVars()
|
const themeVars = useThemeVars()
|
||||||
|
|
||||||
|
@ -80,12 +81,14 @@ const renderContextLabel = (option) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const dialogStore = useDialogStore()
|
const dialogStore = useDialogStore()
|
||||||
|
const preferencesStore = usePreferencesStore()
|
||||||
const onSelectPreferenceMenu = (key) => {
|
const onSelectPreferenceMenu = (key) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'preferences':
|
case 'preferences':
|
||||||
dialogStore.openPreferencesDialog()
|
dialogStore.openPreferencesDialog()
|
||||||
break
|
break
|
||||||
case 'update':
|
case 'update':
|
||||||
|
preferencesStore.checkForUpdate(true)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,8 @@
|
||||||
"help": "Help",
|
"help": "Help",
|
||||||
"check_update": "Check for Updates...",
|
"check_update": "Check for Updates...",
|
||||||
"auto_refresh": "Auto Refresh",
|
"auto_refresh": "Auto Refresh",
|
||||||
|
"new_version_tip": "A new version is available. Download now?",
|
||||||
|
"no_update": "You're update to date",
|
||||||
"refresh": "Refresh",
|
"refresh": "Refresh",
|
||||||
"uptime": "Uptime",
|
"uptime": "Uptime",
|
||||||
"connected_clients": "Clients",
|
"connected_clients": "Clients",
|
||||||
|
|
|
@ -142,6 +142,8 @@
|
||||||
"help": "帮助",
|
"help": "帮助",
|
||||||
"check_update": "检查更新...",
|
"check_update": "检查更新...",
|
||||||
"auto_refresh": "自动刷新",
|
"auto_refresh": "自动刷新",
|
||||||
|
"new_version_tip": "有可用的新版本,是否立即下载",
|
||||||
|
"no_update": "当前已是最新版",
|
||||||
"refresh": "立即刷新",
|
"refresh": "立即刷新",
|
||||||
"uptime": "运行时间",
|
"uptime": "运行时间",
|
||||||
"connected_clients": "已连客户端",
|
"connected_clients": "已连客户端",
|
||||||
|
|
|
@ -131,6 +131,10 @@ const usePreferencesStore = defineStore('preferences', {
|
||||||
}
|
}
|
||||||
return lang || 'en'
|
return lang || 'en'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
autoCheckUpdate() {
|
||||||
|
return get(this.general, 'checkUpdate', false)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
_applyPreferences(data) {
|
_applyPreferences(data) {
|
||||||
|
@ -216,6 +220,37 @@ const usePreferencesStore = defineStore('preferences', {
|
||||||
setAsideWidth(width) {
|
setAsideWidth(width) {
|
||||||
this.general.asideWidth = width
|
this.general.asideWidth = width
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async checkForUpdate(manual = false) {
|
||||||
|
const message = useMessage()
|
||||||
|
const confirmDialog = useConfirmDialog()
|
||||||
|
let msgRef = null
|
||||||
|
if (manual) {
|
||||||
|
msgRef = message.loading('Retrieving for new version', { duration: 0 })
|
||||||
|
}
|
||||||
|
let respObj = null
|
||||||
|
try {
|
||||||
|
const resp = await fetch('https://api.github.com/repos/tiny-craft/tiny-rdm/releases/latest')
|
||||||
|
if (resp.status === 200) {
|
||||||
|
respObj = await resp.json()
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (msgRef != null) {
|
||||||
|
msgRef.destroy()
|
||||||
|
msgRef = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (respObj != null && !isEmpty(respObj['html_url'])) {
|
||||||
|
confirmDialog.warning(i18nGlobal.t('new_version_tip'), () => {
|
||||||
|
BrowserOpenURL(respObj['html_url'])
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (manual) {
|
||||||
|
message.info(i18nGlobal.t('no_update'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue