diff --git a/src/router/guard/index.js b/src/router/guard/index.js index 519caa5..a8d88cd 100644 --- a/src/router/guard/index.js +++ b/src/router/guard/index.js @@ -1,7 +1,9 @@ import { createPageLoadingGuard } from './pageLoadingGuard' +import { createPageTitleGuard } from './pageTitleGuard' import { createPermissionGuard } from './permissionGuard' export function setupRouterGuard(router) { createPageLoadingGuard(router) createPermissionGuard(router) + createPageTitleGuard(router) } diff --git a/src/router/guard/pageTitleGuard.js b/src/router/guard/pageTitleGuard.js new file mode 100644 index 0000000..c26b7d2 --- /dev/null +++ b/src/router/guard/pageTitleGuard.js @@ -0,0 +1,12 @@ +const baseTitle = import.meta.env.VITE_APP_TITLE + +export function createPageTitleGuard(router) { + router.afterEach((to) => { + const pageTitle = to.meta?.title + if (pageTitle) { + document.title = `${pageTitle} | ${baseTitle}` + } else { + document.title = baseTitle + } + }) +}