12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <script setup>
- import { RouterView } from 'vue-router'
- import { ref, onMounted, onUnmounted } from 'vue'
- // const checkVersion = () => {
- // const oldVersion = localStorage.getItem('version')
- // axios.get('/version.json', {
- // cache: 'no-store' // 禁用缓存
- // }).then(({ data }) => {
- // const res = data
- // if (+oldVersion !== +res.version) {
- // alert('页面已经更新,请点击 “确认” 按钮继续使用')
- // // 如果有更新,保存最新版本
- // localStorage.setItem('version', res.version)
- // // 帮用户刷新页面
- // setTimeout(() => {
- // window.location.reload()
- // }, 0)
- // }
- // })
- // }
- const timer = ref(null)
- onMounted(() => {
- console.log(1, 'import.meta.env', import.meta.env)
- // if (process.env.NODE_ENV === 'production') {
- // if (timer.value) clearInterval(timer.value)
- // timer.value = setInterval(() => { checkVersion() }, 3000)
- // }
- })
- onUnmounted(() => {
- if (timer.value) clearInterval(timer.value)
- })
- </script>
- <template>
- <v-app>
- <RouterView />
- </v-app>
- </template>
- <style scoped>
- </style>
|