App.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <script setup>
  2. import { RouterView } from 'vue-router'
  3. import { ref, onMounted, onUnmounted } from 'vue'
  4. // const checkVersion = () => {
  5. // const oldVersion = localStorage.getItem('version')
  6. // axios.get('/version.json', {
  7. // cache: 'no-store' // 禁用缓存
  8. // }).then(({ data }) => {
  9. // const res = data
  10. // if (+oldVersion !== +res.version) {
  11. // alert('页面已经更新,请点击 “确认” 按钮继续使用')
  12. // // 如果有更新,保存最新版本
  13. // localStorage.setItem('version', res.version)
  14. // // 帮用户刷新页面
  15. // setTimeout(() => {
  16. // window.location.reload()
  17. // }, 0)
  18. // }
  19. // })
  20. // }
  21. const timer = ref(null)
  22. onMounted(() => {
  23. console.log(1, 'import.meta.env', import.meta.env)
  24. // if (process.env.NODE_ENV === 'production') {
  25. // if (timer.value) clearInterval(timer.value)
  26. // timer.value = setInterval(() => { checkVersion() }, 3000)
  27. // }
  28. })
  29. onUnmounted(() => {
  30. if (timer.value) clearInterval(timer.value)
  31. })
  32. </script>
  33. <template>
  34. <v-app>
  35. <RouterView />
  36. </v-app>
  37. </template>
  38. <style scoped>
  39. </style>