diff --git a/src/app/chat/components/chat-input-text-field.module.css b/src/app/chat/components/chat-input-text-field.module.css index 61c0f6b4..bcdf67c2 100644 --- a/src/app/chat/components/chat-input-text-field.module.css +++ b/src/app/chat/components/chat-input-text-field.module.css @@ -18,7 +18,7 @@ width: 100%; min-height: 40px; max-height: 120px; /* 约 5 行 × 24px line-height */ - padding: 0; + padding: 6px 0 0 0; /* 上 6px:让文字视觉下移,避开正中位置 */ border: 0; outline: none; background: transparent; @@ -28,8 +28,6 @@ line-height: 24px; resize: none; font-family: inherit; - display: flex; /* 让 textarea 成为 flex 容器,让文字竖直居中 */ - align-items: center; /* 沿 cross axis 居中 = 文字竖直居中于 40px 高度内 */ } .textField::placeholder { diff --git a/src/models/auth/index.ts b/src/models/auth/index.ts index 98cd41e1..91c77317 100644 --- a/src/models/auth/index.ts +++ b/src/models/auth/index.ts @@ -4,4 +4,4 @@ export * from "./auth-mode"; export * from "./auth-panel-mode"; -export * from "./login-type"; +export * from "./login-status"; diff --git a/src/models/auth/login-status.ts b/src/models/auth/login-status.ts new file mode 100644 index 00000000..d00848bc --- /dev/null +++ b/src/models/auth/login-status.ts @@ -0,0 +1,26 @@ +/** + * 登录状态枚举 + * + * 原始 Dart: lib/ui/auth/bloc/auth_state.dart 的 `LoginType` 枚举(v7.0 新增)。 + * + * 2025-XX 改造:语义从"登录方式"扩展为"当前登录状态"—— + * 包含 notLoggedIn / guest / 各 OAuth provider 登录后态。 + * + * 字段命名(state)从 `loginType` 改为 `loginStatus`,更贴合语义。 + */ +export const LoginStatus = { + /** 未登录(默认初值) */ + NotLoggedIn: "notLoggedIn", + /** 游客登录(无需账号,10 轮免费消息) */ + Guest: "guest", + /** Facebook OAuth 登录 */ + Facebook: "facebook", + /** Google OAuth 登录 */ + Google: "google", + /** 邮箱 + 密码登录 */ + Email: "email", + /** Apple ID 登录 */ + Apple: "apple", +} as const; + +export type LoginStatus = (typeof LoginStatus)[keyof typeof LoginStatus]; diff --git a/src/models/auth/login-type.ts b/src/models/auth/login-type.ts deleted file mode 100644 index a4b0aad2..00000000 --- a/src/models/auth/login-type.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * 登录方式枚举 - * - * 原始 Dart: lib/ui/auth/bloc/auth_state.dart 的 `LoginType` 枚举(v7.0 新增)。 - */ -export const LoginType = { - None: "none", - Facebook: "facebook", - Google: "google", - Email: "email", - Apple: "apple", -} as const; - -export type LoginType = (typeof LoginType)[keyof typeof LoginType]; diff --git a/src/stores/auth/auth-context.tsx b/src/stores/auth/auth-context.tsx index 0b338a94..39eebd9d 100644 --- a/src/stores/auth/auth-context.tsx +++ b/src/stores/auth/auth-context.tsx @@ -33,7 +33,7 @@ interface AuthState { isLoading: boolean; errorMessage: string | null; isSuccess: boolean; - loginType: MachineContext["loginType"]; + loginStatus: MachineContext["loginStatus"]; } const AuthStateCtx = createContext(null); @@ -62,7 +62,7 @@ export function AuthProvider({ children }: AuthProviderProps) { state.matches("loadingOAuth"), errorMessage: state.context.errorMessage, isSuccess: state.matches("success"), - loginType: state.context.loginType, + loginStatus: state.context.loginStatus, }), [state], ); diff --git a/src/stores/auth/auth-machine.ts b/src/stores/auth/auth-machine.ts index 83c39b7e..65aba59c 100644 --- a/src/stores/auth/auth-machine.ts +++ b/src/stores/auth/auth-machine.ts @@ -11,7 +11,7 @@ import { setup, fromPromise, assign } from "xstate"; import { signIn } from "next-auth/react"; import type { AuthProvider } from "@/lib/auth/auth_platform"; -import type { LoginType } from "@/models/auth/login-type"; +import type { LoginStatus } from "@/models/auth/login-status"; import { authRepository } from "@/data/repositories/auth_repository"; import { AuthStorage } from "@/data/storage/auth/auth_storage"; import { Result } from "@/utils/result"; @@ -42,17 +42,17 @@ async function readGuestId(): Promise { // 本轮起不再调 /api/auth/marker 写 cookie(统一迁到 NextAuth session // cookie 检测,邮箱登录 proxy 行为在后续轮恢复)。 -const emailLoginActor = fromPromise( +const emailLoginActor = fromPromise( async ({ input }) => { const guestId = await readGuestId(); const result = await authRepository.emailLogin({ ...input, guestId }); if (Result.isErr(result)) throw result.error; - return "email" as LoginType; + return "email" as LoginStatus; }, ); const emailRegisterThenLoginActor = fromPromise< - LoginType, + LoginStatus, { email: string; password: string; username: string; confirmPassword: string } >(async ({ input }) => { const guestId = await readGuestId(); @@ -67,7 +67,7 @@ const emailRegisterThenLoginActor = fromPromise< guestId, }); if (Result.isErr(loginResult)) throw loginResult.error; - return "email" as LoginType; + return "email" as LoginStatus; }); // OAuth 登录 actor:调 next-auth/react 的 signIn(provider) 触发 OAuth 跳转。 @@ -144,7 +144,7 @@ export const authMachine = setup({ onDone: { target: "success", actions: assign({ - loginType: ({ event }) => event.output, + loginStatus: ({ event }) => event.output, errorMessage: null, }), }, @@ -174,7 +174,7 @@ export const authMachine = setup({ onDone: { target: "success", actions: assign({ - loginType: ({ event }) => event.output, + loginStatus: ({ event }) => event.output, errorMessage: null, }), }, diff --git a/src/stores/auth/auth-state.ts b/src/stores/auth/auth-state.ts index 4213206b..5b3fa770 100644 --- a/src/stores/auth/auth-state.ts +++ b/src/stores/auth/auth-state.ts @@ -3,7 +3,7 @@ */ import type { AuthMode } from "@/models/auth/auth-mode"; import type { AuthPanelMode } from "@/models/auth/auth-panel-mode"; -import type { LoginType } from "@/models/auth/login-type"; +import type { LoginStatus } from "@/models/auth/login-status"; export interface AuthState { /** 当前面板模式(Facebook / Email) */ @@ -15,7 +15,8 @@ export interface AuthState { username: string; confirmPassword: string; errorMessage: string | null; - loginType: LoginType; + /** 当前登录状态(未登录 / 游客 / OAuth / 邮箱) */ + loginStatus: LoginStatus; } export const initialState: AuthState = { @@ -26,5 +27,5 @@ export const initialState: AuthState = { username: "", confirmPassword: "", errorMessage: null, - loginType: "none", + loginStatus: "notLoggedIn", };