Files
shanxia2.0/mobile-h5/src/utils/upgrade.ts
T
zlwuandCursor a4b13fa2bc chore(mobile-h5): add existing H5 app sources to the monorepo
Track the weighbridge mobile-h5 codebase (excluding node_modules, dist, and local .env) so subsequent adaptation tasks can evolve it in-repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 22:28:53 +08:00

48 lines
1.3 KiB
TypeScript

import { upgradeLogList } from '@/mock/upgradeLog'
import { showNotify } from 'vant'
import { useUserStore } from '@/store/modules/user'
// 系统升级
export function systemUpgrade() {
const version = import.meta.env.VITE_VERSION
// 跳过版本为1.0.0的提示
if (version === '1.0.0') return
setTimeout(() => {
const { title: content, requireReLogin } = upgradeLogList.value[0]
// 系统升级公告
const message = [
`<p style="color: var(--art-gray-text-800) !important; padding-bottom: 5px;">`,
`系统已升级到 ${version} 版本,此次更新带来了以下改进:`,
`</p>`,
content,
requireReLogin
? `<p style="color: var(--main-color); padding-top: 5px;">升级完成,请重新登录后继续使用。</p>`
: ''
].join('')
const oldSysKey = Object.keys(localStorage).find(
(key) => key.startsWith('sys-v') && key !== `sys-v${version}`
)
if (oldSysKey) {
showNotify({
type: 'success',
message: message,
duration: 0
})
setTimeout(() => {
// 更新版本号
localStorage.setItem('version', version)
// 删除旧版本号
localStorage.removeItem(oldSysKey)
// 需要重新登录
if (requireReLogin) {
useUserStore().logOut()
}
}, 1000)
}
}, 1000)
}