dedsudiyu 9 hónapja
szülő
commit
cfa787c503
3 módosított fájl, 37 hozzáadás és 19 törlés
  1. 1 0
      .gitignore
  2. 32 16
      src/App.vue
  3. 4 3
      vue.config.js

+ 1 - 0
.gitignore

@@ -22,3 +22,4 @@ pnpm-debug.log*
 *.sln
 *.sw?
 /bigData
+/public/version.txt

+ 32 - 16
src/App.vue

@@ -8,6 +8,7 @@
 </template>
 
 <script>
+    import axios from 'axios'
     import { MessageBox } from 'element-ui'
     export default {
         name: 'App',
@@ -69,23 +70,38 @@
                 checkForUpdates();
                 self.timer = window.setInterval(checkForUpdates, intervalTime);
                 async function checkForUpdates() {
-                    getFilesName().then(res=>{
-                        if(res){
-                            if(res !== process.env.VUE_APP_RENEWAL_ENCODING){
-                                MessageBox.confirm('发现新版本,是否立即刷新页面?', '系统提示', {
-                                        confirmButtonText: '确定',
-                                        showCancelButton:true,
-                                        closeOnClickModal:false,
-                                        cancelButtonText: '取消',
-                                        type: 'warning'
-                                    }
-                                ).then(() => {
-                                    clearInterval(self.timer);
-                                    location.reload(true);
-                                }).catch(() => {});
-                            }
+                    axios.get('/version.txt').then((data) => {
+                        if (data.data !== process.env.VUE_APP_RENEWAL_ENCODING){
+                            MessageBox.confirm('发现新版本,是否立即刷新页面?', '系统提示', {
+                                    confirmButtonText: '确定',
+                                    showCancelButton:true,
+                                    closeOnClickModal:false,
+                                    cancelButtonText: '取消',
+                                    type: 'warning'
+                                }
+                            ).then(() => {
+                                clearInterval(self.timer);
+                                location.reload(true);
+                            }).catch(() => {});
                         }
-                    });
+                    })
+                    // getFilesName().then(res=>{
+                    //     if(res){
+                    //         if(res !== process.env.VUE_APP_RENEWAL_ENCODING){
+                    //             MessageBox.confirm('发现新版本,是否立即刷新页面?', '系统提示', {
+                    //                     confirmButtonText: '确定',
+                    //                     showCancelButton:true,
+                    //                     closeOnClickModal:false,
+                    //                     cancelButtonText: '取消',
+                    //                     type: 'warning'
+                    //                 }
+                    //             ).then(() => {
+                    //                 clearInterval(self.timer);
+                    //                 location.reload(true);
+                    //             }).catch(() => {});
+                    //         }
+                    //     }
+                    // });
                 }
                 function getMetaContent(htmlContent) {
                     let matchContent = [];

+ 4 - 3
vue.config.js

@@ -25,8 +25,11 @@ const myDate = new Date()
 const buildTime = myDate.getFullYear() +'-'+ (myDate.getMonth()+1) +'-'+ myDate.getDate() +' '+ myDate.getHours() +':'+ myDate.getMinutes();
 const logsList = getFile ? fs.readFileSync('.git/logs/HEAD', 'utf-8').replace(/\r\n|\r/g, "\n").split("\n") : false
 const buildUser = getFile ? logsList[logsList.length-2].split(" ")[2] : '未配置'
+
 //生成随机版本编码
-process.env.VUE_APP_RENEWAL_ENCODING = generateRandomString()
+const revision = generateRandomString()
+process.env.VUE_APP_RENEWAL_ENCODING = revision
+require('fs').writeFileSync('public/version.txt', revision)
 function generateRandomString() {
     let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
     let randomString = "";
@@ -66,8 +69,6 @@ module.exports = defineConfig({
         args[0].buildUser = buildUser;
         args[0].buildTime = buildTime;
         args[0].buildEdition = buildEdition;
-        args[0].renewalEncoding = process.env.VUE_APP_RENEWAL_ENCODING;
-        // args[0].minify.removeComments = false
         return args
     })
     config