From a5d8214650d0d1fe54b59d92052c80e3625a7325 Mon Sep 17 00:00:00 2001 From: chenhang Date: Tue, 9 Jun 2026 18:47:04 +0800 Subject: [PATCH] refactor: migrate state imports from contexts to stores directory --- src/app/auth/components/auth-email-panel.tsx | 2 +- .../auth/components/auth-facebook-panel.tsx | 2 +- src/app/auth/components/auth-panel.tsx | 2 +- src/app/auth/components/auth-screen.tsx | 6 +-- src/app/auth/components/email-login-form.tsx | 2 +- .../auth/components/email-register-form.tsx | 2 +- src/app/chat/components/chat-screen.tsx | 4 +- src/app/sidebar/components/sidebar-screen.tsx | 2 +- src/app/splash/components/splash-button.tsx | 26 +++++++---- src/app/splash/components/splash-content.tsx | 2 +- src/app/splash/components/splash-screen.tsx | 46 ++++++++++--------- src/providers/root-providers.tsx | 8 ++-- .../auth/auth-context.tsx | 0 src/{contexts => stores}/auth/auth-machine.ts | 0 src/{contexts => stores}/auth/auth-types.ts | 0 src/{contexts => stores}/auth/index.ts | 0 .../chat/chat-context.tsx | 0 src/{contexts => stores}/chat/chat-machine.ts | 0 src/{contexts => stores}/chat/chat-types.ts | 0 src/{contexts => stores}/chat/index.ts | 0 src/{contexts => stores}/sidebar/index.ts | 0 .../sidebar/sidebar-context.tsx | 0 .../sidebar/sidebar-machine.ts | 0 .../sidebar/sidebar-types.ts | 0 src/{contexts => stores}/user/index.ts | 0 .../user/user-context.tsx | 0 src/{contexts => stores}/user/user-machine.ts | 0 src/{contexts => stores}/user/user-types.ts | 0 src/utils/storage.ts | 18 ++++++-- 29 files changed, 72 insertions(+), 50 deletions(-) rename src/{contexts => stores}/auth/auth-context.tsx (100%) rename src/{contexts => stores}/auth/auth-machine.ts (100%) rename src/{contexts => stores}/auth/auth-types.ts (100%) rename src/{contexts => stores}/auth/index.ts (100%) rename src/{contexts => stores}/chat/chat-context.tsx (100%) rename src/{contexts => stores}/chat/chat-machine.ts (100%) rename src/{contexts => stores}/chat/chat-types.ts (100%) rename src/{contexts => stores}/chat/index.ts (100%) rename src/{contexts => stores}/sidebar/index.ts (100%) rename src/{contexts => stores}/sidebar/sidebar-context.tsx (100%) rename src/{contexts => stores}/sidebar/sidebar-machine.ts (100%) rename src/{contexts => stores}/sidebar/sidebar-types.ts (100%) rename src/{contexts => stores}/user/index.ts (100%) rename src/{contexts => stores}/user/user-context.tsx (100%) rename src/{contexts => stores}/user/user-machine.ts (100%) rename src/{contexts => stores}/user/user-types.ts (100%) diff --git a/src/app/auth/components/auth-email-panel.tsx b/src/app/auth/components/auth-email-panel.tsx index a16bce09..15a0f3ba 100644 --- a/src/app/auth/components/auth-email-panel.tsx +++ b/src/app/auth/components/auth-email-panel.tsx @@ -10,7 +10,7 @@ */ import { useState } from "react"; -import { useAuthState } from "@/contexts/auth/auth-context"; +import { useAuthState } from "@/stores/auth/auth-context"; import { EmailLoginForm } from "./email-login-form"; import { EmailRegisterForm } from "./email-register-form"; diff --git a/src/app/auth/components/auth-facebook-panel.tsx b/src/app/auth/components/auth-facebook-panel.tsx index 1866f293..6c8370ab 100644 --- a/src/app/auth/components/auth-facebook-panel.tsx +++ b/src/app/auth/components/auth-facebook-panel.tsx @@ -10,7 +10,7 @@ */ import { useState } from "react"; -import { useAuthState, useAuthDispatch } from "@/contexts/auth/auth-context"; +import { useAuthState, useAuthDispatch } from "@/stores/auth/auth-context"; import { AuthSocialButtons } from "./auth-social-buttons"; import { AuthDivider } from "./auth-divider"; diff --git a/src/app/auth/components/auth-panel.tsx b/src/app/auth/components/auth-panel.tsx index 89924f15..246488b9 100644 --- a/src/app/auth/components/auth-panel.tsx +++ b/src/app/auth/components/auth-panel.tsx @@ -4,7 +4,7 @@ * * 原始 Dart: lib/ui/auth/widgets/auth_panel.dart */ -import { useAuthState } from "@/contexts/auth/auth-context"; +import { useAuthState } from "@/stores/auth/auth-context"; import { AuthFacebookPanel } from "./auth-facebook-panel"; import { AuthEmailPanel } from "./auth-email-panel"; diff --git a/src/app/auth/components/auth-screen.tsx b/src/app/auth/components/auth-screen.tsx index 7803d084..c3055c5e 100644 --- a/src/app/auth/components/auth-screen.tsx +++ b/src/app/auth/components/auth-screen.tsx @@ -13,9 +13,9 @@ import { useEffect, useRef } from "react"; import { useRouter } from "next/navigation"; -import { useAuthState, useAuthDispatch } from "@/contexts/auth/auth-context"; -import { useChatDispatch } from "@/contexts/chat/chat-context"; -import { useUserDispatch } from "@/contexts/user/user-context"; +import { useAuthState, useAuthDispatch } from "@/stores/auth/auth-context"; +import { useChatDispatch } from "@/stores/chat/chat-context"; +import { useUserDispatch } from "@/stores/user/user-context"; import { useAuthGate } from "@/lib/auth/use-auth-gate"; import { ROUTES } from "@/lib/routes"; import { MobileShell } from "@/app/_components/core/mobile-shell"; diff --git a/src/app/auth/components/email-login-form.tsx b/src/app/auth/components/email-login-form.tsx index a18d0e3f..5ce3fa93 100644 --- a/src/app/auth/components/email-login-form.tsx +++ b/src/app/auth/components/email-login-form.tsx @@ -6,7 +6,7 @@ */ import { useState } from "react"; -import { useAuthDispatch } from "@/contexts/auth/auth-context"; +import { useAuthDispatch } from "@/stores/auth/auth-context"; import { validateEmail, validatePassword, diff --git a/src/app/auth/components/email-register-form.tsx b/src/app/auth/components/email-register-form.tsx index bdecf428..617b126d 100644 --- a/src/app/auth/components/email-register-form.tsx +++ b/src/app/auth/components/email-register-form.tsx @@ -6,7 +6,7 @@ */ import { useState } from "react"; -import { useAuthDispatch } from "@/contexts/auth/auth-context"; +import { useAuthDispatch } from "@/stores/auth/auth-context"; import { validateConfirmPassword, validateEmail, diff --git a/src/app/chat/components/chat-screen.tsx b/src/app/chat/components/chat-screen.tsx index 33958275..0ba296b2 100644 --- a/src/app/chat/components/chat-screen.tsx +++ b/src/app/chat/components/chat-screen.tsx @@ -4,8 +4,8 @@ import { type FormEvent, useEffect, useRef, useState } from "react"; import { MobileShell } from "@/app/_components/core/mobile-shell"; import { Dialog } from "@/app/_components/core/dialog"; -import { useChatDispatch, useChatState } from "@/contexts/chat/chat-context"; -import { GuestChatQuota } from "@/contexts/chat/chat-types"; +import { useChatDispatch, useChatState } from "@/stores/chat/chat-context"; +import { GuestChatQuota } from "@/stores/chat/chat-types"; import type { UiMessage } from "@/models/chat/ui-message"; import styles from "./chat-screen.module.css"; diff --git a/src/app/sidebar/components/sidebar-screen.tsx b/src/app/sidebar/components/sidebar-screen.tsx index b9f8b941..945a9798 100644 --- a/src/app/sidebar/components/sidebar-screen.tsx +++ b/src/app/sidebar/components/sidebar-screen.tsx @@ -4,7 +4,7 @@ import { useEffect } from "react"; import Link from "next/link"; import { MobileShell } from "@/app/_components/core/mobile-shell"; -import { useUserDispatch, useUserState } from "@/contexts/user/user-context"; +import { useUserDispatch, useUserState } from "@/stores/user/user-context"; import styles from "./sidebar-screen.module.css"; diff --git a/src/app/splash/components/splash-button.tsx b/src/app/splash/components/splash-button.tsx index 8b966955..155b68b4 100644 --- a/src/app/splash/components/splash-button.tsx +++ b/src/app/splash/components/splash-button.tsx @@ -10,18 +10,25 @@ * - 居中布局 (MainAxisAlignment.center) * - Facebook 按钮:带渐变(primaryGradient)+ 圆角 24 + 高度 48 * - 加载中:按钮内显示 spinner + * + * Skip 按钮使用 `` 而非 ` +