From 16d0d1687f25b0a21dee0d92f2b76a565029a82a Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 18 Dec 2024 19:56:36 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/App.vue | 7 ++++--- resources/assets/js/app.js | 11 +++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index 71ee95fcd..50c03f90b 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -219,7 +219,7 @@ export default { if (buttons.length === 0) { return; } - buttons.each((index, item) => { + buttons.each((_, item) => { if ($A(item).text().indexOf("搜索")) { button = $A(item); } @@ -467,8 +467,9 @@ export default { this.autoTheme() $A.updateTimezone() $A.IDBTest() - if (this.lastCheckUpgradeYmd != $A.daytz().format('YYYY-MM-DD')) { - this.lastCheckUpgradeYmd = $A.daytz().format('YYYY-MM-DD') + const nowYmd = $A.daytz().format('YYYY-MM-DD') + if (this.lastCheckUpgradeYmd != nowYmd) { + this.lastCheckUpgradeYmd = nowYmd $A.eeuiAppCheckUpdate(); } } diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 254837958..1629769b8 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -98,10 +98,9 @@ VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } -const router = new VueRouter({ - mode: isSoftware && !/https?:/i.test(window.location.protocol) ? 'hash' : 'history', - routes -}); +// 路由方式 +const routeMode = isSoftware && !/https?:/i.test(window.location.protocol) ? 'hash' : 'history'; +const router = new VueRouter({mode: routeMode, routes}); // 进度条配置 if (!isSoftware) { @@ -292,8 +291,8 @@ const $init = async () => { const $preload = async () => { await store.dispatch("preload"); - const currentPath = (window.location.pathname || window.location.hash).replace(/^[#\/]/, ''); - if (currentPath !== 'preload') { + const hash = (window.location[routeMode === 'history' ? 'pathname' : 'hash']).replace(/^[#\/\s]/, ''); + if (hash !== 'preload') { $init().catch(_ => {}) return }