feat: 动态更新页面标题

This commit is contained in:
2024-08-29 14:46:06 +08:00
parent 94e94956bb
commit 702d65ef47
2 changed files with 17 additions and 0 deletions

9
src/assets/js/utils.js Normal file
View File

@@ -0,0 +1,9 @@
import { description as appDesc } from '@package-json';
/**
* @description 更新页面标题
* @param {string} title
*/
export function updateAppTitle(title = '') {
document.title = (title ? `${title} - ${appDesc}` : appDesc);
}

View File

@@ -3,6 +3,10 @@ import {
createWebHashHistory,
} from 'vue-router';
import {
updateAppTitle,
} from '@/assets/js/utils';
import {
ENABLE_SEARCH_MODULE,
ENABLE_NAV_MODULE,
@@ -67,3 +71,7 @@ export const router = createRouter({
},
],
});
router.afterEach((to) => {
updateAppTitle(to.meta.title);
});