优化工作-1

This commit is contained in:
yml2213
2026-06-05 07:41:52 +08:00
parent b7ec5e2755
commit 0b9b0b5ea7
17 changed files with 1807 additions and 127 deletions
+14 -8
View File
@@ -44,6 +44,7 @@ router.beforeEach(async (to) => {
const loginPath = getLoginPath('user', to.path)
return { path: loginPath, query: { redirect: to.fullPath } }
}
// 优化: 只有当用户信息未加载时才调用 loadMe
if (!session.phone) {
try {
await session.loadMe()
@@ -60,18 +61,23 @@ router.beforeEach(async (to) => {
const loginPath = getLoginPath('user', to.path)
const realnamePath = to.path.startsWith('/m') ? '/m/realname' : '/realname'
// 优化: 只有当状态未知或未验证时才重新加载
if (session.realnameStatus !== 'verified') {
try {
await session.loadMe()
} catch {
if (!getAccessToken('user')) {
return { path: loginPath, query: { redirect: to.fullPath } }
// 如果没有 phone 信息,说明用户数据未加载
if (!session.phone) {
try {
await session.loadMe()
} catch {
if (!getAccessToken('user')) {
return { path: loginPath, query: { redirect: to.fullPath } }
}
}
}
}
if (session.realnameStatus !== 'verified') {
return { path: realnamePath, query: { redirect: to.fullPath } }
// 再次检查实名状态
if (session.realnameStatus !== 'verified') {
return { path: realnamePath, query: { redirect: to.fullPath } }
}
}
}