feat: dismiss update toast
This commit is contained in:
@ -7,11 +7,13 @@
|
||||
const { t } = useI18n()
|
||||
const toast = useToast()
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const { dismissUpdateVersion } = storeToRefs(useConfigStore())
|
||||
|
||||
const interval = 5 * 60 * 1000
|
||||
let lastCheck: Date | undefined
|
||||
|
||||
const checkUpdate = async () => {
|
||||
if (import.meta.dev) return
|
||||
if (lastCheck && new Date().getTime() - lastCheck.getTime() < interval) {
|
||||
return
|
||||
}
|
||||
@ -20,7 +22,12 @@
|
||||
const response = (await $fetch(
|
||||
'https://deep-research.ataw.top/version.json',
|
||||
)) as typeof VersionMeta
|
||||
if (semverGt(response.version, runtimeConfig.public.version)) {
|
||||
|
||||
const hasNewVersion = semverGt(
|
||||
response.version,
|
||||
runtimeConfig.public.version,
|
||||
)
|
||||
if (hasNewVersion && dismissUpdateVersion.value !== response.version) {
|
||||
toast.add({
|
||||
title: t('autoUpdate.newVersionTitle', [response.version]),
|
||||
description: t('autoUpdate.newVersionDescription'),
|
||||
@ -29,10 +36,19 @@
|
||||
actions: [
|
||||
{
|
||||
label: t('autoUpdate.refresh'),
|
||||
color: 'info',
|
||||
onClick: () => {
|
||||
window.location.reload()
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('autoUpdate.dismiss'),
|
||||
color: 'info',
|
||||
variant: 'subtle',
|
||||
onClick: () => {
|
||||
dismissUpdateVersion.value = response.version
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
@ -89,7 +89,8 @@
|
||||
},
|
||||
"autoUpdate": {
|
||||
"newVersionTitle": "New version available: {0}",
|
||||
"newVersionDescription": "Please refresh the page to get the latest version.",
|
||||
"refresh": "Refresh"
|
||||
"newVersionDescription": "Note: If you are using a self-hosted version, please re-deploy to get new features and bug fixes.",
|
||||
"refresh": "Refresh page",
|
||||
"dismiss": "Dismiss"
|
||||
}
|
||||
}
|
@ -89,7 +89,8 @@
|
||||
},
|
||||
"autoUpdate": {
|
||||
"newVersionTitle": "发现新版本:{0}",
|
||||
"newVersionDescription": "请刷新页面以获取最新版本。",
|
||||
"refresh": "刷新"
|
||||
"newVersionDescription": "注:如果您使用的是自部署页面,请使用最新代码重新部署,即可获得最新功能和 bug 修复。",
|
||||
"refresh": "刷新",
|
||||
"dismiss": "忽略"
|
||||
}
|
||||
}
|
@ -32,6 +32,11 @@ export const useConfigStore = defineStore('config', () => {
|
||||
provider: 'tavily',
|
||||
},
|
||||
})
|
||||
// The version user dismissed the update notification
|
||||
const dismissUpdateVersion = useLocalStorage<string>(
|
||||
'dismiss-update-version',
|
||||
'',
|
||||
)
|
||||
|
||||
const aiApiBase = computed(() => {
|
||||
return config.value.ai.apiBase || 'https://api.openai.com/v1'
|
||||
@ -39,5 +44,10 @@ export const useConfigStore = defineStore('config', () => {
|
||||
|
||||
const showConfigManager = ref(false)
|
||||
|
||||
return { config: skipHydrate(config), aiApiBase, showConfigManager }
|
||||
return {
|
||||
config: skipHydrate(config),
|
||||
aiApiBase,
|
||||
showConfigManager,
|
||||
dismissUpdateVersion: skipHydrate(dismissUpdateVersion),
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user