From 61fe45927ea496af880352b9efcdbd0d9abab904 Mon Sep 17 00:00:00 2001 From: hi2hi Date: Mon, 23 Dec 2024 04:46:12 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=87=E9=A2=98=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 6 +++++- src/utils/page-title.js | 3 ++- src/views/detail.vue | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index c702868..a3a78f2 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -41,7 +41,11 @@ const routerOptions = { const router = createRouter(routerOptions); router.beforeResolve((to, from, next) => { - pageTitle(to?.meta?.title); + if (to?.meta?.title) { + pageTitle(to?.meta?.title); + } else if (to.name === 'Home') { + pageTitle(config.nazhua.title); + } next(); }); diff --git a/src/utils/page-title.js b/src/utils/page-title.js index 5d65338..3248def 100644 --- a/src/utils/page-title.js +++ b/src/utils/page-title.js @@ -1,5 +1,6 @@ import config from '@/config'; export default (...args) => { - document.title = [...args, config.nazhua.title].filter((i) => i).join(' - '); + const titles = [...new Set([...args, config.nazhua.title])].filter((i) => i); + document.title = titles.join(' - '); }; diff --git a/src/views/detail.vue b/src/views/detail.vue index a5f50b2..7e189f9 100644 --- a/src/views/detail.vue +++ b/src/views/detail.vue @@ -130,9 +130,9 @@ function handleWorldMapWidth() { ); } -watch(() => info.value, () => { - if (info.value) { - pageTitle(info.value?.Name, '节点详情'); +watch(() => info.value, (oldValue, newValue) => { + if (!oldValue && newValue && router.currentRoute.value.name === 'ServerDetail') { + pageTitle(newValue?.Name, '节点详情'); handleWorldMapWidth(); } });