feat(sj_1.0.0): useTitle 加上站点名

This commit is contained in:
dhb52 2024-06-09 15:14:59 +08:00
parent a6e49d21a2
commit 4ec53d3c35

View File

@ -2,12 +2,14 @@ import { useTitle } from '@vueuse/core';
import type { Router } from 'vue-router';
import { $t } from '@/locales';
const { VITE_APP_TITLE } = import.meta.env;
export function createDocumentTitleGuard(router: Router) {
router.afterEach(to => {
const { i18nKey, title } = to.meta;
const documentTitle = i18nKey ? $t(i18nKey) : title;
useTitle(documentTitle);
useTitle(documentTitle, { titleTemplate: `%s | ${VITE_APP_TITLE}` });
});
}