提交 ad9737d8 authored 作者: 徐立's avatar 徐立

优化版本更新系统

上级 1f221df8
...@@ -122,7 +122,7 @@ export const request = (url, data, options = {}) => { ...@@ -122,7 +122,7 @@ export const request = (url, data, options = {}) => {
}).then(response => { }).then(response => {
if (response.errCode && response.errCode == '10000') { if (response.errCode && response.errCode == '10000') {
const ul = window.location.href; const ul = window.location.href;
if (ul.indexOf('?') == -1) { if (ul.indexOf('timeVersion=') == -1) {
let x = JSON.parse(response.errMsg); let x = JSON.parse(response.errMsg);
let time = +new Date(); let time = +new Date();
localStorage.setItem('version', JSON.stringify(x.version)); localStorage.setItem('version', JSON.stringify(x.version));
...@@ -132,15 +132,19 @@ export const request = (url, data, options = {}) => { ...@@ -132,15 +132,19 @@ export const request = (url, data, options = {}) => {
showToast('检查到最新版本,即将自动更新,更新完成后请重新操作'); showToast('检查到最新版本,即将自动更新,更新完成后请重新操作');
window.location.href = x.mobileAdress window.location.href = x.mobileAdress
? mobileAdress + '?time=' + time ? mobileAdress + '?timeVersion=' + time
: ul + '?time=' + time; : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
} else { } else {
sessionStorage.removeItem('cacheMobile'); sessionStorage.removeItem('cacheMobile');
openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作'); openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作');
window.location.href = x.webAdress window.location.href = x.webAdress
? x.webAdress + '?time=' + time ? x.webAdress + '?timeVersion=' + time
: ul + '?time=' + time; : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
} }
setTimeout(() => location.reload(), 3000); setTimeout(() => location.reload(), 3000);
} }
...@@ -194,7 +198,7 @@ export const request = (url, data, options = {}) => { ...@@ -194,7 +198,7 @@ export const request = (url, data, options = {}) => {
}).then(response => { }).then(response => {
if (response.errCode && response.errCode == '10000') { if (response.errCode && response.errCode == '10000') {
const ul = window.location.href; const ul = window.location.href;
if (ul.indexOf('?') == -1) { if (ul.indexOf('timeVersion=') == -1) {
let x = JSON.parse(response.errMsg); let x = JSON.parse(response.errMsg);
let time = +new Date(); let time = +new Date();
localStorage.setItem('version', JSON.stringify(x.version)); localStorage.setItem('version', JSON.stringify(x.version));
...@@ -203,15 +207,19 @@ export const request = (url, data, options = {}) => { ...@@ -203,15 +207,19 @@ export const request = (url, data, options = {}) => {
sessionStorage.removeItem('cacheMobile'); sessionStorage.removeItem('cacheMobile');
showToast('检查到最新版本,即将自动更新,更新完成后请重新操作'); showToast('检查到最新版本,即将自动更新,更新完成后请重新操作');
window.location.href = x.mobileAdress window.location.href = x.mobileAdress
? mobileAdress + '?time=' + time ? mobileAdress + '?timeVersion=' + time
: ul + '?time=' + time; : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
} else { } else {
sessionStorage.removeItem('cacheMobile'); sessionStorage.removeItem('cacheMobile');
openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作'); openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作');
window.location.href = x.webAdress window.location.href = x.webAdress
? x.webAdress + '?time=' + time ? x.webAdress + '?timeVersion=' + time
: ul + '?time=' + time; : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
} }
setTimeout(() => location.reload(), 3000); setTimeout(() => location.reload(), 3000);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论