|
@@ -70,59 +70,27 @@
|
|
checkForUpdates();
|
|
checkForUpdates();
|
|
self.timer = window.setInterval(checkForUpdates, intervalTime);
|
|
self.timer = window.setInterval(checkForUpdates, intervalTime);
|
|
async function checkForUpdates() {
|
|
async function checkForUpdates() {
|
|
- 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(() => {});
|
|
|
|
|
|
+ let xhr = new XMLHttpRequest();
|
|
|
|
+ xhr.open('GET', 'version.txt', true); // 替换为你要读取的txt文件路径
|
|
|
|
+ xhr.onreadystatechange = function() {
|
|
|
|
+ if (xhr.readyState === 4 && xhr.status === 200) {
|
|
|
|
+ let version = xhr.responseText;
|
|
|
|
+ if (version !== 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 = [];
|
|
|
|
- const metaTags = htmlContent.match(/<meta[^>]*>/g) || [];
|
|
|
|
- for (const tag of metaTags) {
|
|
|
|
- if(tag.indexOf('renewalEncoding') != -1){
|
|
|
|
- let matchName = tag.match(/content=[^]*>/g);
|
|
|
|
- matchName = removeChars(matchName[0], '>', '<', '"', "'");
|
|
|
|
- matchContent = matchName.split("=");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return matchContent[1];
|
|
|
|
- }
|
|
|
|
- function removeChars(str, ...chars) {
|
|
|
|
- const pattern = new RegExp(`[${chars.join('')}]`, 'g');
|
|
|
|
- return str.replace(pattern, '');
|
|
|
|
- }
|
|
|
|
- async function getFilesName() {
|
|
|
|
- const response = await fetch("./index.html");
|
|
|
|
- const htmlContent = await response.text();
|
|
|
|
- return getMetaContent(htmlContent);
|
|
|
|
|
|
+ };
|
|
|
|
+ xhr.send();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|