18 lines
547 B
TypeScript
18 lines
547 B
TypeScript
import defaultSettings from '@/settings';
|
|
import { useSettingsStore } from '@/store/modules/settings';
|
|
import i18n from '@/lang';
|
|
import { translateRouteTitle } from '@/utils/i18n';
|
|
|
|
/**
|
|
* 动态修改标题
|
|
*/
|
|
export const useDynamicTitle = () => {
|
|
const settingsStore = useSettingsStore();
|
|
const appTitle = i18n.global.t('app.title');
|
|
if (settingsStore.dynamicTitle) {
|
|
document.title = translateRouteTitle(settingsStore.title) + ' - ' + appTitle;
|
|
} else {
|
|
document.title = appTitle || (defaultSettings.title as string);
|
|
}
|
|
};
|