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
+1 -7
View File
@@ -5,13 +5,7 @@ const pbUrl = import.meta.env.VITE_PB_URL || window.location.origin
export const pb = new PocketBase(pbUrl)
// 认证状态持久化
pb.authStore.loadFromCookie(document.cookie)
// 保存认证状态到 cookie
pb.authStore.onChange(() => {
document.cookie = pb.authStore.exportToCookie({ httpOnly: false, path: '/' })
})
// SDK v0.21+ 自动使用 localStorage 持久化,无需手动 cookie 操作
// 获取当前用户
export function getCurrentUser() {