mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
add version check
This commit is contained in:
6
gen-version.js
Normal file
6
gen-version.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
const version = Date.now()
|
||||||
|
const versionModule = `export const version = "${version}"`
|
||||||
|
fs.writeFileSync(path.resolve(__dirname, 'src/version.js'), versionModule)
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"prebuild": "node gen-version.js",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"lint": "vite lint"
|
"lint": "vite lint"
|
||||||
|
|||||||
14
src/main.ts
14
src/main.ts
@@ -4,9 +4,19 @@ import router from './router'
|
|||||||
import { GetSelfAccount } from './api/account'
|
import { GetSelfAccount } from './api/account'
|
||||||
import { GetNotifactions } from './data/notifactions'
|
import { GetNotifactions } from './data/notifactions'
|
||||||
|
|
||||||
|
let currentVersion
|
||||||
|
import('@/version.js').then((versionModule) => {
|
||||||
|
currentVersion = versionModule.version
|
||||||
|
const savedVersion = localStorage.getItem('Version')
|
||||||
|
|
||||||
|
if (currentVersion && savedVersion && savedVersion !== currentVersion) {
|
||||||
|
alert('新的版本更新, 请按 Ctrl+F5 强制刷新页面')
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorage.setItem('Version', currentVersion)
|
||||||
|
})
|
||||||
|
|
||||||
createApp(App).use(router).mount('#app')
|
createApp(App).use(router).mount('#app')
|
||||||
|
|
||||||
GetSelfAccount()
|
GetSelfAccount()
|
||||||
GetNotifactions()
|
GetNotifactions()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import path from 'path'
|
|||||||
import svgLoader from 'vite-svg-loader'
|
import svgLoader from 'vite-svg-loader'
|
||||||
import mkcert from 'vite-plugin-mkcert'
|
import mkcert from 'vite-plugin-mkcert'
|
||||||
|
|
||||||
|
const Timestamp = new Date().getTime()
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue(), svgLoader()],
|
plugins: [vue(), svgLoader()],
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
Reference in New Issue
Block a user