1
2
3
4
5
6
7
8
9
10
11
12
13
| import type { Router } from 'vue-router';
| import { useTitle } from '@vueuse/core';
| 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);
| });
| }
|
|