chore: useTitle

pull/361/head
xiaojunnuo 2025-03-09 01:14:44 +08:00
parent 065713cdb6
commit 2c6d64976f
3 changed files with 12 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import { useUserStore } from "/@/store/modules/user";
import { mitter } from "/@/utils/util.mitt";
import { env } from "/@/utils/util.env";
import { updatePreferences } from "/@/vben/preferences";
import { useTitle } from "@vueuse/core";
export interface SettingState {
sysPublic?: SysPublicSetting;
installInfo?: {
@ -146,6 +146,14 @@ export const useSettingStore = defineStore({
}
});
}
if (this.siteInfo.title) {
updatePreferences({
app: {
name: this.siteInfo.title
}
});
useTitle(this.siteInfo.title);
}
},
async checkUrlBound() {
const userStore = useUserStore();

View File

@ -16,8 +16,8 @@ export async function setupVben(app: any, { loadMessages, router }: any) {
const store = await initStores(app, { namespace: "fs" });
watchEffect(() => {
if (preferences.app.dynamicTitle) {
const routeTitle = router.currentRoute.value.title;
const pageTitle = routeTitle || "" + preferences.app.name;
const routeTitle = router.currentRoute.value.meta?.title;
const pageTitle = (routeTitle ? `${routeTitle} - ` : "") + preferences.app.name;
useTitle(pageTitle);
}
});

View File

@ -18,7 +18,7 @@ const defaultPreferences: Preferences = {
layout: "mixed-nav",
locale: "zh-CN",
loginExpiredMode: "page",
name: "FsAdmin",
name: "",
preferencesButtonPosition: "auto",
watermark: false
},