lxf 1 year ago
parent
commit
ef79d4a0a7
5 changed files with 16 additions and 5 deletions
  1. 3 0
      .env.development
  2. 3 0
      .env.production
  3. 6 3
      .env.staging
  4. 1 1
      package.json
  5. 3 1
      src/permission.js

+ 3 - 0
.env.development

@@ -9,4 +9,7 @@ VITE_APP_BASE_API = '/dev-api'
 
 VITE_APP_WS_API = ':10000/test-api'
 
+# 是否强制刷新
+VITE_REFRESH = false
+
 VITE_APP_IP = '121.37.194.75'

+ 3 - 0
.env.production

@@ -12,4 +12,7 @@ VITE_APP_WS_API = ':10000/prod-api'
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip
 
+# 是否强制刷新
+VITE_REFRESH = true
+
 VITE_APP_IP = '139.9.184.42'

+ 6 - 3
.env.staging

@@ -5,11 +5,14 @@ VITE_APP_TITLE = 胜德
 VITE_APP_ENV = 'staging'
 
 # 若依管理系统/生产环境
-VITE_APP_BASE_API = '/test-api'
+VITE_APP_BASE_API = '/prod-api'
 
-VITE_APP_WS_API = ':10000/test-api'
+VITE_APP_WS_API = ':10000/prod-api'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip
 
-VITE_APP_IP = '121.37.194.75'
+# 是否强制刷新
+VITE_REFRESH = true
+
+VITE_APP_IP = '139.9.184.42'

+ 1 - 1
package.json

@@ -7,7 +7,7 @@
   "scripts": {
     "dev": "vite",
     "build:prod": "vite build --mode production && node ./build/build-pro.js",
-    "build:stage": "vite build --mode staging",
+    "build:stage": "vite build --mode staging && node ./build/build-pro.js",
     "preview": "vite preview"
   },
   "repository": {

+ 3 - 1
src/permission.js

@@ -33,9 +33,11 @@ const checkVersion = async () => {
   }
   localStorage.setItem("sd_web_version", JSON.stringify({ version: version }));
 };
+
+const isRefresh = import.meta.env.VITE_REFRESH;
 router.beforeEach((to, from, next) => {
   // 检测版本更新;
-  if (from.path !== "/") {
+  if (from.path !== "/" && isRefresh === "true") {
     checkVersion();
   }
   NProgress.start();