mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-23 20:06:37 +08:00
14 lines
338 B
TypeScript
14 lines
338 B
TypeScript
import { useTitle } from '@vueuse/core';
|
|
import type { Router } from 'vue-router';
|
|
import { $t } from '@/locales';
|
|
|
|
export function createDocumentTitleGuard(router: Router) {
|
|
router.afterEach(to => {
|
|
const { i18nKey, title } = to.meta;
|
|
|
|
const documentTitle = i18nKey ? $t(i18nKey) : title;
|
|
|
|
useTitle(documentTitle);
|
|
});
|
|
}
|