|
@@ -6,7 +6,7 @@ import axios from 'axios'
|
|
|
import { vue_version } from './version.js'
|
|
|
import { useSystem } from '@/store/system'
|
|
|
|
|
|
-const { setBeijingTimestamp } = useSystem()
|
|
|
+const { setTimeDifference } = useSystem()
|
|
|
const timer = ref(null)
|
|
|
// const setFn = ref()
|
|
|
const setIntervalTime = 3000 // 接口调用间隔时间
|
|
@@ -33,6 +33,24 @@ onUnmounted(() => {
|
|
|
// window.location.reload(true) // true参数会忽略缓存的内容,强制重新从服务器下载所有内容.包括 JavaScript 文件,图像,文本文件等。这样可以保证显示网页的最新内容,但是会消耗更多的流量和时间。
|
|
|
// window.location.replace(window.location.href) // 方法会把浏览器中的临时文件夹的文件删除再重新从服务器下载。这样可以清除一些可能造成问题的缓存文件,但是也会消耗更多的流量和时间。
|
|
|
|
|
|
+const getVersion = () => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const baseUrl = import.meta.env.VITE_BASE_URL || ''
|
|
|
+ const tenantId = import.meta.env?.VITE_TENANTCODE || ''
|
|
|
+ axios.get(`${baseUrl}/app-api/menduner/system/get/version`, {
|
|
|
+ headers: { ['tenant-id']: tenantId },
|
|
|
+ cache: 'no-store' // 禁用缓存
|
|
|
+ }).then(resolve)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+getVersion().then(({ data }) => {
|
|
|
+ const _now = new Date().getTime()
|
|
|
+ const { time } = data?.data
|
|
|
+ // 设置浏览器和服务器时间差
|
|
|
+ setTimeDifference(time - _now)
|
|
|
+})
|
|
|
+
|
|
|
let ConfirmDone = false
|
|
|
// 检查版本号
|
|
|
const checkVersion = () => {
|
|
@@ -42,12 +60,9 @@ const checkVersion = () => {
|
|
|
const get_v = localStorage.getItem('RES_VERSION') || ''
|
|
|
//
|
|
|
if (!baseUrl || !vue_version || !tenantId) return
|
|
|
- axios.get(`${baseUrl}/app-api/menduner/system/get/version`, {
|
|
|
- headers: { ['tenant-id']: tenantId },
|
|
|
- cache: 'no-store' // 禁用缓存
|
|
|
- }).then(({ data }) => {
|
|
|
+
|
|
|
+ getVersion().then(({ data }) => {
|
|
|
const { version, time } = data?.data
|
|
|
- setBeijingTimestamp(time)
|
|
|
if (!version || version === vue_version ) { // 接口报错和版本一致不弹Confirm
|
|
|
return
|
|
|
}
|