diff --git a/src/data/dto/auth/auth_mode.ts b/src/data/dto/auth/auth_mode.ts deleted file mode 100644 index 37bb179a..00000000 --- a/src/data/dto/auth/auth_mode.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * 认证模式(登录 / 注册) - * - * - */ -export const AuthMode = { - Login: "login", - Register: "register", -} as const; - -export type AuthMode = (typeof AuthMode)[keyof typeof AuthMode]; diff --git a/src/data/dto/auth/index.ts b/src/data/dto/auth/index.ts index 9add076b..8b2b519f 100644 --- a/src/data/dto/auth/index.ts +++ b/src/data/dto/auth/index.ts @@ -2,7 +2,6 @@ * @file Automatically generated by barrelsby. */ -export * from "./auth_mode"; export * from "./auth_panel_mode"; export * from "./facebook_user_data"; export * from "./login_status"; diff --git a/src/stores/auth/__tests__/auth-machine.test.ts b/src/stores/auth/__tests__/auth-machine.test.ts index 8fe5d6c6..7bb1cc0f 100644 --- a/src/stores/auth/__tests__/auth-machine.test.ts +++ b/src/stores/auth/__tests__/auth-machine.test.ts @@ -58,22 +58,12 @@ function createTestAuthMachine( } describe("authMachine", () => { - it("updates panel mode, auth mode, and unsupported Apple login errors", () => { + it("updates panel mode", () => { const actor = createActor(createTestAuthMachine()).start(); actor.send({ type: "AuthPanelModeChanged", mode: "email" }); - actor.send({ type: "AuthModeChanged", mode: "register" }); expect(actor.getSnapshot().context.authPanelMode).toBe("email"); - expect(actor.getSnapshot().context.authMode).toBe("register"); - - actor.send({ type: "AuthAppleLoginSubmitted" }); - expect(actor.getSnapshot().context.errorMessage).toBe( - "Apple login not implemented", - ); - - actor.send({ type: "AuthFormCleared" }); - expect(actor.getSnapshot().context.errorMessage).toBeNull(); actor.stop(); }); diff --git a/src/stores/auth/auth-context.tsx b/src/stores/auth/auth-context.tsx index db41d2ef..7c3486d9 100644 --- a/src/stores/auth/auth-context.tsx +++ b/src/stores/auth/auth-context.tsx @@ -25,11 +25,6 @@ import type { AuthEvent, AuthState as MachineContext } from "./auth-machine"; */ interface AuthState { authPanelMode: MachineContext["authPanelMode"]; - authMode: MachineContext["authMode"]; - email: string; - password: string; - username: string; - confirmPassword: string; isLoading: boolean; errorMessage: string | null; /** 当前登录状态(未登录 / 游客 / OAuth / 邮箱) */ @@ -52,11 +47,6 @@ export function AuthProvider({ children }: AuthProviderProps) { const authState = useMemo( () => ({ authPanelMode: state.context.authPanelMode, - authMode: state.context.authMode, - email: state.context.email, - password: state.context.password, - username: state.context.username, - confirmPassword: state.context.confirmPassword, // isLoading 覆盖邮箱登录 / 邮箱注册 / OAuth 跳转(NextAuth 重定向期间)/ // OAuth 回调后端 sync / 显式游客登录 isLoading: diff --git a/src/stores/auth/auth-events.ts b/src/stores/auth/auth-events.ts index 63dc4973..3c518d27 100644 --- a/src/stores/auth/auth-events.ts +++ b/src/stores/auth/auth-events.ts @@ -4,13 +4,11 @@ * 事件名与原 Dart AuthEvent 对齐。 */ import type { AuthProvider } from "@/lib/auth/auth_platform"; -import type { AuthMode, AuthPanelMode } from "@/data/dto/auth"; +import type { AuthPanelMode } from "@/data/dto/auth"; export type AuthEvent = // 内部 UI 事件 | { type: "AuthPanelModeChanged"; mode: AuthPanelMode } - | { type: "AuthModeChanged"; mode: AuthMode } - | { type: "AuthFormCleared" } | { type: "AuthLogoutSubmitted" } /** App 启动时一次性派发 —— 读 storage 把 loginStatus 同步到状态机 */ | { type: "AuthInit" } @@ -27,7 +25,6 @@ export type AuthEvent = // 社交登录 —— 状态机内部调 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 } diff --git a/src/stores/auth/auth-machine.ts b/src/stores/auth/auth-machine.ts index aed10667..6be2823f 100644 --- a/src/stores/auth/auth-machine.ts +++ b/src/stores/auth/auth-machine.ts @@ -70,21 +70,6 @@ export const authMachine = setup({ errorMessage: null, }), }, - AuthModeChanged: { - actions: assign({ - authMode: ({ event }) => event.mode, - errorMessage: null, - }), - }, - AuthFormCleared: { - actions: assign({ - email: "", - password: "", - username: "", - confirmPassword: "", - errorMessage: null, - }), - }, AuthLogoutSubmitted: { guard: "canLogoutToGuest", target: "loggingOut", @@ -100,11 +85,6 @@ export const authMachine = setup({ AuthEmailRegisterSubmitted: "loadingEmailRegister", AuthGoogleLoginSubmitted: "loadingOAuth", AuthFacebookLoginSubmitted: "loadingOAuth", - AuthAppleLoginSubmitted: { - actions: assign({ - errorMessage: "Apple login not implemented", - }), - }, // OAuth 回调后 sync 入口 —— 由 派发 AuthGoogleSyncSubmitted: "syncingGoogleBackend", diff --git a/src/stores/auth/auth-state.ts b/src/stores/auth/auth-state.ts index d71dd3a1..957f66db 100644 --- a/src/stores/auth/auth-state.ts +++ b/src/stores/auth/auth-state.ts @@ -1,17 +1,11 @@ /** * Auth 状态机:State 形状 + 初始值 */ -import type { AuthMode, AuthPanelMode, LoginStatus } from "@/data/dto/auth"; +import type { AuthPanelMode, LoginStatus } from "@/data/dto/auth"; export interface AuthState { /** 当前面板模式(Facebook / Email) */ authPanelMode: AuthPanelMode; - /** 内部登录模式(login / register) */ - authMode: AuthMode; - email: string; - password: string; - username: string; - confirmPassword: string; errorMessage: string | null; /** 当前登录状态(未登录 / 游客 / OAuth / 邮箱)—— 下游同步器监听此字段的双向变化 */ loginStatus: LoginStatus; @@ -21,11 +15,6 @@ export interface AuthState { export const initialState: AuthState = { authPanelMode: "facebook", - authMode: "login", - email: "", - password: "", - username: "", - confirmPassword: "", errorMessage: null, loginStatus: "notLoggedIn", hasInitialized: false,