Parcourir la source

检查版本号

lifanagju_citu il y a 6 mois
Parent
commit
ea220360e9
1 fichiers modifiés avec 5 ajouts et 8 suppressions
  1. 5 8
      src/App.vue

+ 5 - 8
src/App.vue

@@ -4,9 +4,9 @@ import { ref, onMounted, onUnmounted, nextTick } from 'vue'
 import Confirm from '@/plugins/confirm'
 import axios from 'axios'
 
-const testOpen = true
+const testOpen = false // 开启测试环境测试 默认关闭
 const timer = ref(null)
-const autoCloseTime = 30000
+const setIntervalTime = 300000 // 
 onMounted(() => {
   nextTick(() => {
     console.log('baseurl', import.meta.env?.VITE_BASE_URL, 'version', import.meta.env?.VITE_VERSION)
@@ -14,7 +14,7 @@ onMounted(() => {
     const process_ENV = process?.env?.NODE_ENV || ''
     if (process_ENV === 'production' || testOpen) { // development production
       if (timer.value) clearInterval(timer.value)
-      timer.value = setInterval(() => { checkVersion() }, autoCloseTime)
+      timer.value = setInterval(() => { checkVersion() }, setIntervalTime)
     }
   })
 })
@@ -29,14 +29,11 @@ const checkVersion = () => {
   const tenantId = import.meta.env?.VITE_TENANTCODE || ''
   if (!baseUrl || !version) return
   axios.get(`${baseUrl}/app-api/menduner/system/get/version`, {
-    headers: {
-      ['tenant-id']: tenantId
-    },
-    // cache: 'no-store' // 禁用缓存
+    headers: { ['tenant-id']: tenantId }
   }).then((res) => {
     if (res?.data?.data !== version) {
       const option = {
-        autoCloseTime: autoCloseTime > 3000 ? (autoCloseTime-3000) : autoCloseTime
+        autoCloseTime: setIntervalTime > 30000 ? setIntervalTime/2 : setIntervalTime > 10000 ? setIntervalTime - 3000 : setIntervalTime
       }
       Confirm('系统提示', '发现新版本,是否立即刷新页面', option).then(() => {
         window.location.reload()