fix: Login 页面进入时自动检测登录状态(通过轻量 cookie-check)

This commit is contained in:
2026-03-01 16:37:16 +08:00
parent 785ec84e56
commit 0e693842a6
+10
View File
@@ -13,6 +13,16 @@ export function LoginPage() {
const { status, loading: statusLoading, refresh: refreshStatus } = useLoginStatus();
const { token } = useAuth();
const { toast } = useToast();
// Auto-check cookie on mount (lightweight, no browser opened)
useEffect(() => {
if (!token) return;
void checkLoginCookie().then((res) => {
if (res.success && res.data?.hasCookies) {
void refreshStatus(); // Only open browser if cookies exist
}
}).catch(() => {});
}, [token, refreshStatus]);
const navigate = useNavigate();
const [qrData, setQrData] = useState<string | null>(null);