From a321ce2f698cb031bac65efd4edfb2ad6e3c7b7c Mon Sep 17 00:00:00 2001 From: hi2hi Date: Thu, 12 Dec 2024 17:54:23 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E8=AF=BB=E5=8F=96=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=90=8D=E7=A7=B0=EF=BC=8C=E8=AE=BE=E7=BD=AE=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 3 ++- src/utils/page-title.js | 5 +++++ src/views/detail.vue | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/utils/page-title.js diff --git a/src/router/index.js b/src/router/index.js index 86195ec..63a4695 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -4,6 +4,7 @@ import { createWebHashHistory, } from 'vue-router'; import config from '@/config'; +import pageTitle from '@/utils/page-title'; const constantRoutes = [{ name: 'Home', @@ -35,7 +36,7 @@ const routerOptions = { const router = createRouter(routerOptions); router.beforeResolve((to, from, next) => { - document.title = [to?.meta?.title, config.nazhua.title].filter((i) => i).join(' - '); + pageTitle(to?.meta?.title); next(); }); diff --git a/src/utils/page-title.js b/src/utils/page-title.js new file mode 100644 index 0000000..5d65338 --- /dev/null +++ b/src/utils/page-title.js @@ -0,0 +1,5 @@ +import config from '@/config'; + +export default (...args) => { + document.title = [...args, config.nazhua.title].filter((i) => i).join(' - '); +}; diff --git a/src/views/detail.vue b/src/views/detail.vue index e315159..a5f50b2 100644 --- a/src/views/detail.vue +++ b/src/views/detail.vue @@ -54,6 +54,7 @@ import { alias2code, locationCode2Info, } from '@/utils/world-map'; +import pageTitle from '@/utils/page-title'; import WorldMap from '@/components/world-map/world-map.vue'; import ServerName from './components/server-detail/server-name.vue'; @@ -131,6 +132,7 @@ function handleWorldMapWidth() { watch(() => info.value, () => { if (info.value) { + pageTitle(info.value?.Name, '节点详情'); handleWorldMapWidth(); } }); @@ -145,6 +147,7 @@ watch(() => dataInit.value, () => { onMounted(() => { if (info.value) { + pageTitle(info.value?.Name, '节点详情'); handleWorldMapWidth(); } window.addEventListener('resize', handleWorldMapWidth);