解决登录显示、首页显示bug

This commit is contained in:
2026-05-19 11:06:46 +08:00
parent 2f7e097e6c
commit 00a859c551
181 changed files with 55329 additions and 998 deletions

View File

@@ -49,6 +49,27 @@ export const setUserProfile = (profile : UserProfile) => {
state.userProfile = profile
}
function clearUserAuthStorage() : void {
const keys : Array<string> = [
'userInfo',
'user_id',
'access_token',
'refresh_token',
'token',
'currentUser',
'current_user',
'user',
'auth_user',
'supabase.auth.token'
]
for (let i = 0; i < keys.length; i++) {
try {
uni.removeStorageSync(keys[i])
} catch (e) {}
}
}
// 获取当前用户信息(含补全 profile
export async function getCurrentUser() : Promise<UserProfile | null> {
try {
@@ -191,6 +212,8 @@ export async function getCurrentUser() : Promise<UserProfile | null> {
// 登出并清空用户信息
export function logout() {
supa.signOut()
clearUserAuthStorage()
state.authUser = null
state.userProfile = { username: '', email: '' } as UserProfile
state.isLoggedIn = false // 登出
}