feature/0723/ZR #1

Merged
chenzhen merged 14 commits from feature/0723/ZR into release/0.01 2026-07-27 10:44:41 +08:00
Showing only changes of commit 4c7a0709a4 - Show all commits
+11 -4
View File
@@ -1,6 +1,13 @@
import router from '@/router';
import { auth } from '@/hooks/useAuth';
const appTitle = import.meta.env.VITE_APP_TITLE || 'CPMS 运营平台';
/** 导航完成后设置页面标题,避免动态路由加载前误匹配 404 导致 title 闪烁 */
function updateDocumentTitle(title?: string) {
document.title = title ? `${title} - ${appTitle}` : appTitle;
}
/**
* 全局路由守卫
* 核心流程:
@@ -15,10 +22,6 @@ import { auth } from '@/hooks/useAuth';
* matched 信息带过去,导致仍然匹配到 /:pathMatch(.*)*。
*/
router.beforeEach(async (to, _from, next) => {
// 设置页面标题
const appTitle = import.meta.env.VITE_APP_TITLE || 'CPMS 运营平台';
document.title = to.meta.title ? `${to.meta.title} - ${appTitle}` : appTitle;
// ── /login 特殊处理 ──
if (to.path === '/login') {
if (auth.isLoggedIn()) {
@@ -51,3 +54,7 @@ router.beforeEach(async (to, _from, next) => {
next();
});
router.afterEach((to) => {
updateDocumentTitle(to.meta.title as string | undefined);
});