🐛 修复页面标题异常

This commit is contained in:
hi2hi 2024-12-23 04:46:12 +00:00
parent 7a2e22c30c
commit 61fe45927e
3 changed files with 10 additions and 5 deletions

View File

@ -41,7 +41,11 @@ const routerOptions = {
const router = createRouter(routerOptions); const router = createRouter(routerOptions);
router.beforeResolve((to, from, next) => { 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(); next();
}); });

View File

@ -1,5 +1,6 @@
import config from '@/config'; import config from '@/config';
export default (...args) => { 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(' - ');
}; };

View File

@ -130,9 +130,9 @@ function handleWorldMapWidth() {
); );
} }
watch(() => info.value, () => { watch(() => info.value, (oldValue, newValue) => {
if (info.value) { if (!oldValue && newValue && router.currentRoute.value.name === 'ServerDetail') {
pageTitle(info.value?.Name, '节点详情'); pageTitle(newValue?.Name, '节点详情');
handleWorldMapWidth(); handleWorldMapWidth();
} }
}); });