fix(auth): retry silent login after logout to show user selection for Admin

When Admin switches user and the switched user logs out, instead of
showing the login dialog, re-run silent login to detect if the
computer belongs to an Admin user and show user selection dialog.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-04-01 16:28:26 +08:00
parent 63a292c5f9
commit 020bbcdccc

View File

@@ -246,12 +246,19 @@ export function useAppBootstrap() {
}, [])
const handleLogout = useCallback(async () => {
// 退出登录,清空后端状态
await window.electron.auth.logout()
// 清空前端状态
setIsAuthenticated(false)
setCurrentUser(null)
setIsSwitchedByAdmin(false)
setShowLoginDialog(true)
}, [])
setShowUserSelection(false)
setShowLoginDialog(false)
// 重新进行静默登录,如果是 Admin 会自动弹出用户选择界面
await initializeAuth()
}, [initializeAuth])
const openUpdateDialog = useCallback(async () => {
await Promise.all([refreshUpdateCatalog(), refreshUpdateState()])