ソースを参照

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

Xiao_123 6 ヶ月 前
コミット
ed20bfcd2f
4 ファイル変更15 行追加6 行削除
  1. 2 2
      .env.development
  2. 3 1
      src/App.vue
  3. 8 1
      src/permission.js
  4. 2 2
      vite.config.mjs

+ 2 - 2
.env.development

@@ -1,7 +1,7 @@
 NODE_ENV = 'development'
 
-# 版本号 v 1818
-VITE_VERSION = 'v24.11.21.0954'
+# 版本号 v 0954
+VITE_VERSION = 'v24.11.21.1122'
 
 VITE_APP_TITLE = 门墩儿
 

+ 3 - 1
src/App.vue

@@ -52,7 +52,9 @@ const checkVersion = () => {
     ConfirmDone = true  // 后续不弹Confirm
     Confirm('系统提示', '发现新版本,将立即刷新页面', { hideCancelBtn: true }).then(() => {
       localStorage.setItem('RES_VERSION', res_v)
-      window.location.reload()
+      // window.location.reload() // 方法会根据缓存的有效期和修改时间,决定是否重新从服务器下载内容。如果缓存的内容没有过期或没有修改,就会直接使用缓存,这样可以节省流量和时间
+      window.location.reload(true) // true参数会忽略缓存的内容,强制重新从服务器下载所有内容.包括 JavaScript 文件,图像,文本文件等。这样可以保证显示网页的最新内容,但是会消耗更多的流量和时间。
+      // window.location.replace(window.location.href) // 方法会把浏览器中的临时文件夹的文件删除再重新从服务器下载。这样可以清除一些可能造成问题的缓存文件,但是也会消耗更多的流量和时间。
     })
   }).catch(err => {
     console.log('checkVersion-err', err)

+ 8 - 1
src/permission.js

@@ -72,4 +72,11 @@ router.afterEach((to) => {
   useTitle(to?.meta?.title)
   done() // 结束Progress
   // loadDone()
-})
+})
+
+// router.onError(error => {
+//   const fetchResourcesErrors = ['Failed to fetch dynamically imported module', 'Importing a module script failed']
+//    if (fetchResourcesErrors.some((item) => error?.message && error.message?.includes(item))) {
+//      window.location.reload()
+//    }
+// });

+ 2 - 2
vite.config.mjs

@@ -66,9 +66,9 @@ export default defineConfig({
     rollupOptions: {
       output: {
         // 设置静态资源引用的基础路径
-        assetFileNames: 'assets/[name].[ext]',
+        assetFileNames: 'assets/[name].[hash].[ext]',
         chunkFileNames: 'chunks/[name].[hash].js',
-        entryFileNames: '[name].js',
+        entryFileNames: '[name].[hash].js',
       },
       watch: true // 允许浏览器在源码变化时自动刷新
     },