refactor(auth): switch to class-based social login and v4 route handler

Migrate from function-based social login helpers (`facebookLogin`, `googleLogin`)
to class-based services (`new FacebookLogin().signIn()`, `new GoogleLogin().signIn()`),
updating call sites in `AuthFacebookPanel` and `SplashButton` with try/catch error
handling. The NextAuth route handler is also refactored to the v4 pattern, importing
pre-built `GET` / `POST` exports from `@/lib/auth/nextauth` instead of constructing
the handler inline with `NextAuth(authOptions)`.
This commit is contained in:
2026-06-10 15:34:52 +08:00
parent 90bb711a45
commit d70e61f92e
115 changed files with 9004 additions and 493 deletions
+28
View File
@@ -0,0 +1,28 @@
"use client";
/**
* 客户端鉴权门(class-oriented 封装)
*
* `useState` 是 static 方法而非实例方法(hooks 必须在 React 函数组件中调用,
* static 方法本质上仍由组件调用,hook 链合法)。调用方写法:
*
* ```tsx
* function MyComponent() {
* const { isAuthed } = AuthGate.useState();
* }
* ```
*
* 原始 Dart: nextauth-helpers.useAuthGate()
*/
import { useSession } from "next-auth/react";
export interface AuthGateState {
isAuthed: boolean;
}
export class AuthGate {
/** 必须在 React 函数组件内调用(useSession 是 hook */
static useState(): AuthGateState {
const { data: session } = useSession();
return { isAuthed: Boolean(session?.user) };
}
}