From cba52884a307e34e0f57f48627205bab2da0f61f Mon Sep 17 00:00:00 2001 From: chenhang Date: Tue, 16 Jun 2026 12:01:42 +0800 Subject: [PATCH] chore: clean up migration comments and unused params Remove obsolete Dart migration notes and route handling comments from splash-button.tsx and auth-machine.ts, and drop the unused `self` parameter from `chatWebSocketActor` callback signature. --- src/app/splash/components/splash-button.tsx | 5 ----- src/stores/auth/auth-machine.ts | 12 +----------- src/stores/chat/chat-machine.actors.ts | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/app/splash/components/splash-button.tsx b/src/app/splash/components/splash-button.tsx index 456a7c48..ab82cac4 100644 --- a/src/app/splash/components/splash-button.tsx +++ b/src/app/splash/components/splash-button.tsx @@ -2,16 +2,11 @@ /** * Splash 底部按钮组 * - * 原始 Dart: lib/ui/splash/widgets/splash_button.dart - * `Row(children: [Skip 文本, SizedBox 26, 社交登录按钮])` - * * 本组件是 splash 鉴权流程的**纯 UI 入口**: * - 消费 `useAuthState` / `useAuthDispatch`(仅用于 isLoading 显示 + 派事件) * - **Skip 按钮 = 显式游客登录入口**(派发 `AuthGuestLoginSubmitted`) * - 社交登录按钮仅派发 `AuthFacebookLoginSubmitted` 事件,由状态机负责调 NextAuth * - * **不**做路由跳转 —— 路由逻辑**全部**移到 splash-screen.tsx 统一管理。 - * * **派事件策略**(**单**事件): * - 派业务事件(`AuthGuestLoginSubmitted` / `AuthFacebookLoginSubmitted`)→ 状态机开始跑 * - `pendingRedirect: true` 在**登录成功 onDone** 里**自动**置(auth-machine.ts `onLoginSuccess` helper) diff --git a/src/stores/auth/auth-machine.ts b/src/stores/auth/auth-machine.ts index 73cb98ac..87bf0385 100644 --- a/src/stores/auth/auth-machine.ts +++ b/src/stores/auth/auth-machine.ts @@ -1,14 +1,5 @@ /** * Auth 状态机(XState v5) - * - * 原始 Dart: lib/ui/auth/bloc/auth_bloc.dart + auth_state.dart + auth_event.dart - * - * 本轮迁移:所有认证登录调用(含 OAuth 社交登录)统一收口到状态机内。 - * 业务层只派发事件(`AuthEmailLoginSubmitted` / `AuthGoogleLoginSubmitted` / 等), - * 状态机通过 actors 调 `authRepository`(邮箱 / OAuth token sync)或 - * `next-auth/react.signIn`(OAuth 跳转)。 - * - * 异步服务(actors)已抽到 `./auth-actors`,小工具抽到 `./auth-helpers`。 */ import { setup, assign } from "xstate"; @@ -35,8 +26,6 @@ export type { AuthEvent } from "./auth-events"; // Machine // // 设计:所有登录/同步流跑完都回 `idle`(带正确 `loginStatus`)。 -// **不**再设 `success` state —— 之前曾用 "success" 当"刚成功"信号, -// 但 status check 流也会误入 success,触发 splash-button 误跳 /chat。 // // `pendingRedirect: boolean`("用户**显式**触发了登录"信号)—— // **在登录成功的 onDone 里自动置 true**: @@ -100,6 +89,7 @@ export const authMachine = setup({ AuthEmailRegisterSubmitted: "loadingEmailRegister", AuthGoogleLoginSubmitted: "loadingOAuth", AuthFacebookLoginSubmitted: "loadingOAuth", + // OAuth 回调后 sync 入口 —— 由 派发 AuthGoogleSyncSubmitted: "syncingGoogleBackend", AuthFacebookSyncSubmitted: "syncingFacebookBackend", diff --git a/src/stores/chat/chat-machine.actors.ts b/src/stores/chat/chat-machine.actors.ts index 66383787..65588391 100644 --- a/src/stores/chat/chat-machine.actors.ts +++ b/src/stores/chat/chat-machine.actors.ts @@ -184,7 +184,7 @@ export const loadMoreHistoryActor = fromPromise< * - cleanup 函数 → XState 在 parent state exit 时自动调用 */ export const chatWebSocketActor = fromCallback( - ({ sendBack, input, self }) => { + ({ sendBack, input }) => { console.log("[chat-machine] chatWebSocketActor ENTRY", { hasToken: !!input.token, tokenLength: input.token?.length ?? 0,