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);