完善刷新页面展示bug

This commit is contained in:
2026-03-14 14:52:36 +08:00
parent 5914104851
commit 500160df11
3 changed files with 131 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import { state, getCurrentUser } from '@/utils/store.uts'
import { clearAdminRoleCache, refreshAdminRole } from './role.uts'
import supa from '@/components/supadb/aksupainstance.uts'
import supa, { supaReady } from '@/components/supadb/aksupainstance.uts'
let __isHandlingExpired = false
@@ -51,6 +51,11 @@ export function handleSessionExpired(reason?: string) {
*/
export async function ensureAdminSession(): Promise<boolean> {
try {
// ① 等待 hydrateSessionFromStorage() 完成从storage恢复token→异步网络请求
// 必须在 getSession() 之前 await否则刷新后 this.session 仍为 null
// 会被误判为未登录并触发 handleSessionExpired。
try { await supaReady } catch (_) {}
const sessionInfo = supa.getSession()
if (sessionInfo.session == null) {
console.warn('[AdminAuth] 没有发现凭证,要求重新登录')