fix: login persistence, username login, realtime refresh, group name uniqueness

- Remove loadFromCookie that overwrites valid localStorage auth data
- Set user status to idle on first login (was empty string)
- Default empty status to idle instead of away

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
congsh
2026-04-18 09:56:11 +08:00
parent 9405406c47
commit 6b684f8600
2 changed files with 6 additions and 8 deletions
+5 -1
View File
@@ -12,7 +12,7 @@ export const useUserStore = defineStore('user', () => {
// 计算属性
const isLoggedIn = computed(() => isAuthenticated() && user.value !== null)
const userStatus = computed(() => user.value?.status || 'away')
const userStatus = computed(() => user.value?.status || 'idle')
const userId = computed(() => user.value?.id || '')
// 初始化用户信息
@@ -41,6 +41,10 @@ export const useUserStore = defineStore('user', () => {
loading.value = true
await pb.collection('users').authWithPassword(email, password)
await initUser()
// 首次登录设置默认状态为空闲
if (user.value && !user.value.status) {
await setStatus('idle')
}
} catch (error: any) {
throw new Error('邮箱或密码错误')
} finally {