update alert

This commit is contained in:
2023-11-25 11:42:09 +08:00
parent f3b3e02120
commit 10d7f591fd
10 changed files with 218 additions and 75 deletions

View File

@@ -1,26 +1,33 @@
import { QueryGetAPI } from '@/api/query'
import { BASE_API } from '@/data/constants'
import { createApp } from 'vue'
import { createApp, h } from 'vue'
import App from './App.vue'
import router from './router'
import { GetSelfAccount } from './api/account'
import { GetNotifactions } from './data/notifactions'
let currentVersion
QueryGetAPI(BASE_API + 'vtsuru/version').then((version) => {
if (version.code == 200) {
currentVersion = version.data
const savedVersion = localStorage.getItem('Version')
if (currentVersion && savedVersion && savedVersion !== currentVersion) {
alert('发现新的版本更新, 请按 Ctrl+F5 强制刷新页面')
}
localStorage.setItem('Version', currentVersion)
}
})
import { NText, createDiscreteApi } from 'naive-ui'
createApp(App).use(router).mount('#app')
GetSelfAccount()
GetNotifactions()
let currentVersion: string
const { notification } = createDiscreteApi(['notification'])
QueryGetAPI<string>(BASE_API + 'vtsuru/version').then((version) => {
if (version.code == 200) {
currentVersion = version.data
const savedVersion = localStorage.getItem('Version')
if (currentVersion && savedVersion && savedVersion !== currentVersion) {
//alert('发现新的版本更新, 请按 Ctrl+F5 强制刷新页面')
notification.info({
title: '发现新的版本更新',
content: '请按 Ctrl+F5 强制刷新页面',
duration: 5000,
meta: () => h(NText, { depth: 3 }, () => currentVersion),
})
}
localStorage.setItem('Version', currentVersion)
}
})