/** * Auth 状态机:事件联合 * * 事件名与原 Dart AuthEvent 对齐。 */ import type { AuthProvider } from "@/lib/auth/auth_platform"; import type { AuthMode } from "@/models/auth/auth-mode"; import type { AuthPanelMode } from "@/models/auth/auth-panel-mode"; export type AuthEvent = // 内部 UI 事件 | { type: "AuthPanelModeChanged"; mode: AuthPanelMode } | { type: "AuthModeChanged"; mode: AuthMode } | { type: "AuthFormCleared" } | { type: "AuthLogoutSubmitted" } /** App 启动时一次性派发 —— 读 storage 把 loginStatus 同步到状态机 */ | { type: "AuthInit" } /** 显式游客登录 —— splash 上点"游客模式"按钮触发(不自动) */ | { type: "AuthGuestLoginSubmitted" } // 业务事件(提交) | { type: "AuthEmailLoginSubmitted"; email: string; password: string } | { type: "AuthEmailRegisterSubmitted"; email: string; password: string; username: string; confirmPassword: string; } // 社交登录 —— 状态机内部调 next-auth/react 的 signIn(provider) | { type: "AuthGoogleLoginSubmitted"; provider: AuthProvider } | { type: "AuthFacebookLoginSubmitted"; provider: AuthProvider } | { type: "AuthAppleLoginSubmitted" } // OAuth 回调后:把 OAuth provider token 转交后端换业务 token // 由 监听 useSession() 派发 | { type: "AuthGoogleSyncSubmitted"; idToken: string } | { type: "AuthFacebookSyncSubmitted"; accessToken: string } // ────────────────────────────────────────────────────────────────────── // splash / auth screen 跳完 /chat 后清"刚按了"信号(一次性): // `pendingRedirect` 在 login onDone action 里自动置 true(不是按钮派的) // —— 因此只需要 `AuthClearPendingRedirect` 一个事件 | { type: "AuthClearPendingRedirect" };