From e0d0e353c0c30ba124e61b8c88220631f74bc041 Mon Sep 17 00:00:00 2001 From: chenhang Date: Wed, 10 Jun 2026 15:48:49 +0800 Subject: [PATCH] refactor(auth): remove AuthGate abstraction in favor of useSession - Drop AuthGate/AuthGateState re-exports from @/lib/auth/nextauth - Simplify SplashButton by removing skipHref prop and hardcoding ROUTES.chat - Update comments to reference useSession() (next-auth/react) directly instead of the AuthGate wrapper, since the auth UI gate no longer needs the extra abstraction layer. --- src/app/splash/components/splash-button.tsx | 11 +++----- src/lib/auth/auth_gate.ts | 28 --------------------- src/lib/auth/nextauth.ts | 3 +-- src/router/proxy.ts | 2 +- 4 files changed, 5 insertions(+), 39 deletions(-) delete mode 100644 src/lib/auth/auth_gate.ts diff --git a/src/app/splash/components/splash-button.tsx b/src/app/splash/components/splash-button.tsx index 8455d7b4..59b86837 100644 --- a/src/app/splash/components/splash-button.tsx +++ b/src/app/splash/components/splash-button.tsx @@ -6,7 +6,7 @@ * `Row(children: [Skip 文本, SizedBox 26, Facebook 登录按钮])` * * 本组件是 splash 鉴权流程的**自治单元**: - * - 消费 `useAuthGate`(内部用 useSession 监听 NextAuth session) + * - 消费 `useSession()`(next-auth/react)监听 NextAuth session * - 消费 `useAuthState` / `useAuthDispatch`(邮箱登录流程) * - 消费 `useChatDispatch` / `useUserDispatch`(登录成功后初始化) * - 自管路由跳转(已登录 / 登录成功 → /chat) @@ -25,12 +25,7 @@ import { ROUTES } from "@/router/routes"; import { LoadingIndicator } from "@/app/_components/core/loading-indicator"; import styles from "./splash-button.module.css"; -export interface SplashButtonProps { - /** Skip 链接的目标路由(默认 /chat) */ - skipHref?: string; -} - -export function SplashButton({ skipHref = ROUTES.chat }: SplashButtonProps) { +export function SplashButton() { // ===== 鉴权路由跳转已由 src/router/proxy.ts 集中处理 ===== // 本组件只负责: // 1. 触发登录动作 @@ -68,7 +63,7 @@ export function SplashButton({ skipHref = ROUTES.chat }: SplashButtonProps) {
{/* Skip 文本链接(next/link 渲染为 ,保留 SPA 体验) */}