diff --git a/src/app/chat/chat-screen.tsx b/src/app/chat/chat-screen.tsx index a247f6db..3f2a956d 100644 --- a/src/app/chat/chat-screen.tsx +++ b/src/app/chat/chat-screen.tsx @@ -21,7 +21,7 @@ import { useEffect, useRef } from "react"; import Image from "next/image"; import { useAuthState } from "@/stores/auth/auth-context"; -import type { LoginStatus } from "@/models/auth/login-status"; +import type { LoginStatus } from "@/data/dto/auth"; import { AuthStorage } from "@/data/storage/auth/auth_storage"; import { useChatDispatch, useChatState } from "@/stores/chat/chat-context"; diff --git a/src/app/chat/components/chat-area.tsx b/src/app/chat/components/chat-area.tsx index b7dc8f09..9d8a9f51 100644 --- a/src/app/chat/components/chat-area.tsx +++ b/src/app/chat/components/chat-area.tsx @@ -16,7 +16,7 @@ */ import { useEffect, useRef } from "react"; -import type { UiMessage } from "@/models/chat/ui-message"; +import type { UiMessage } from "@/data/dto/chat"; import { AiDisclosureBanner } from "./ai-disclosure-banner"; import { DateHeader } from "./date-header"; @@ -79,4 +79,4 @@ function renderMessagesWithDateHeaders(messages: readonly UiMessage[]) { /> ), ); -} \ No newline at end of file +} diff --git a/src/models/auth/auth-mode.ts b/src/data/dto/auth/auth_mode.ts similarity index 100% rename from src/models/auth/auth-mode.ts rename to src/data/dto/auth/auth_mode.ts diff --git a/src/models/auth/auth-panel-mode.ts b/src/data/dto/auth/auth_panel_mode.ts similarity index 70% rename from src/models/auth/auth-panel-mode.ts rename to src/data/dto/auth/auth_panel_mode.ts index c029dc10..d55d2414 100644 --- a/src/models/auth/auth-panel-mode.ts +++ b/src/data/dto/auth/auth_panel_mode.ts @@ -8,4 +8,5 @@ export const AuthPanelMode = { Email: "email", } as const; -export type AuthPanelMode = (typeof AuthPanelMode)[keyof typeof AuthPanelMode]; +export type AuthPanelMode = + (typeof AuthPanelMode)[keyof typeof AuthPanelMode]; diff --git a/src/data/dto/auth/index.ts b/src/data/dto/auth/index.ts index 5fc5ae40..3f018ccf 100644 --- a/src/data/dto/auth/index.ts +++ b/src/data/dto/auth/index.ts @@ -3,12 +3,15 @@ */ export * from "./apple_login_request"; +export * from "./auth_mode"; +export * from "./auth_panel_mode"; export * from "./facebook_login_request"; export * from "./facebook_user_data"; export * from "./fb_id_login_request"; export * from "./google_login_request"; export * from "./guest_login_request"; export * from "./guest_login_response"; +export * from "./login_status"; export * from "./login_request"; export * from "./login_response"; export * from "./logout_response"; diff --git a/src/models/auth/login-status.ts b/src/data/dto/auth/login_status.ts similarity index 100% rename from src/models/auth/login-status.ts rename to src/data/dto/auth/login_status.ts diff --git a/src/models/chat/chat-list-item.ts b/src/data/dto/chat/chat_list_item.ts similarity index 94% rename from src/models/chat/chat-list-item.ts rename to src/data/dto/chat/chat_list_item.ts index 6664ef16..2cea1c76 100644 --- a/src/models/chat/chat-list-item.ts +++ b/src/data/dto/chat/chat_list_item.ts @@ -9,7 +9,7 @@ * - loading-animation:AI 正在输入的动画 * - message:实际消息 */ -import type { UiMessage } from "./ui-message"; +import type { UiMessage } from "./ui_message"; export type ChatListItem = | { type: "ai-disclosure" } diff --git a/src/data/dto/chat/index.ts b/src/data/dto/chat/index.ts index b11282a1..abd3fbee 100644 --- a/src/data/dto/chat/index.ts +++ b/src/data/dto/chat/index.ts @@ -3,6 +3,7 @@ */ export * from "./chat_history_response"; +export * from "./chat_list_item"; export * from "./chat_message"; export * from "./chat_send_response"; export * from "./chat_sync_data"; @@ -12,3 +13,4 @@ export * from "./image_upload_response"; export * from "./send_message_request"; export * from "./stt_data"; export * from "./sync_message"; +export * from "./ui_message"; diff --git a/src/models/chat/ui-message.ts b/src/data/dto/chat/ui_message.ts similarity index 85% rename from src/models/chat/ui-message.ts rename to src/data/dto/chat/ui_message.ts index 965e9e39..7b76b4e7 100644 --- a/src/models/chat/ui-message.ts +++ b/src/data/dto/chat/ui_message.ts @@ -25,7 +25,12 @@ export const UiMessage = { create(input: Omit & { date?: string }): UiMessage { return UiMessageSchema.parse({ ...input, - date: input.date ?? new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), + date: + input.date ?? + new Date().toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + }), }); }, }; diff --git a/src/data/dto/user/index.ts b/src/data/dto/user/index.ts index 287d1254..3e0d014a 100644 --- a/src/data/dto/user/index.ts +++ b/src/data/dto/user/index.ts @@ -10,3 +10,4 @@ export * from "./recent_memory"; export * from "./update_profile_request"; export * from "./user"; export * from "./user_stats_response"; +export * from "./user_view"; diff --git a/src/models/user/user.ts b/src/data/dto/user/user_view.ts similarity index 99% rename from src/models/user/user.ts rename to src/data/dto/user/user_view.ts index 9638f28e..764ddfe3 100644 --- a/src/models/user/user.ts +++ b/src/data/dto/user/user_view.ts @@ -20,6 +20,4 @@ export const UserViewSchema = z.object({ stripeCustomerId: z.string().nullable(), }); - - export type UserView = z.infer; diff --git a/src/models/auth/index.ts b/src/models/auth/index.ts deleted file mode 100644 index 91c77317..00000000 --- a/src/models/auth/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from "./auth-mode"; -export * from "./auth-panel-mode"; -export * from "./login-status"; diff --git a/src/models/chat/index.ts b/src/models/chat/index.ts deleted file mode 100644 index 7c9b9a40..00000000 --- a/src/models/chat/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from "./chat-list-item"; -export * from "./ui-message"; diff --git a/src/models/user/index.ts b/src/models/user/index.ts deleted file mode 100644 index ce953594..00000000 --- a/src/models/user/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from "./user"; diff --git a/src/stores/auth/auth-actors.ts b/src/stores/auth/auth-actors.ts index d6e4d56e..67ff2e4a 100644 --- a/src/stores/auth/auth-actors.ts +++ b/src/stores/auth/auth-actors.ts @@ -4,7 +4,7 @@ import { fromPromise } from "xstate"; import { AuthPlatform, type AuthProvider } from "@/lib/auth/auth_platform"; -import type { LoginStatus } from "@/models/auth/login-status"; +import type { LoginStatus } from "@/data/dto/auth"; import { authRepository } from "@/data/repositories/auth_repository"; import type { IAuthRepository } from "@/data/repositories/interfaces"; import { AuthStorage } from "@/data/storage/auth/auth_storage"; diff --git a/src/stores/auth/auth-events.ts b/src/stores/auth/auth-events.ts index c58b5b6a..4eabf42f 100644 --- a/src/stores/auth/auth-events.ts +++ b/src/stores/auth/auth-events.ts @@ -4,8 +4,7 @@ * 事件名与原 Dart AuthEvent 对齐。 */ import type { AuthProvider } from "@/lib/auth/auth_platform"; -import type { AuthMode } from "@/models/auth/auth-mode"; -import type { AuthPanelMode } from "@/models/auth/auth-panel-mode"; +import type { AuthMode, AuthPanelMode } from "@/data/dto/auth"; export type AuthEvent = // 内部 UI 事件 diff --git a/src/stores/auth/auth-state.ts b/src/stores/auth/auth-state.ts index 0d4cee55..80eb8471 100644 --- a/src/stores/auth/auth-state.ts +++ b/src/stores/auth/auth-state.ts @@ -1,9 +1,7 @@ /** * Auth 状态机:State 形状 + 初始值 */ -import type { AuthMode } from "@/models/auth/auth-mode"; -import type { AuthPanelMode } from "@/models/auth/auth-panel-mode"; -import type { LoginStatus } from "@/models/auth/login-status"; +import type { AuthMode, AuthPanelMode, LoginStatus } from "@/data/dto/auth"; export interface AuthState { /** 当前面板模式(Facebook / Email) */ diff --git a/src/stores/chat/chat-machine.actors.ts b/src/stores/chat/chat-machine.actors.ts index b64286c7..cef62d26 100644 --- a/src/stores/chat/chat-machine.actors.ts +++ b/src/stores/chat/chat-machine.actors.ts @@ -308,4 +308,4 @@ export const sendMessageWsActor = fromPromise( ); // Re-export `UiMessage` type for the chat-machine.ts public API -type UiMessage = import("@/models/chat/ui-message").UiMessage; +type UiMessage = import("@/data/dto/chat").UiMessage; diff --git a/src/stores/chat/chat-machine.helpers.ts b/src/stores/chat/chat-machine.helpers.ts index b1f2e639..62cb08ba 100644 --- a/src/stores/chat/chat-machine.helpers.ts +++ b/src/stores/chat/chat-machine.helpers.ts @@ -20,7 +20,7 @@ * - `AuthStorage` import 已删(只 `readInitData` 用过,移到 `chatInit` actor 上层调用) */ -import type { UiMessage } from "@/models/chat/ui-message"; +import type { UiMessage } from "@/data/dto/chat"; import { chatRepository } from "@/data/repositories/chat_repository"; import type { IChatRepository } from "@/data/repositories/interfaces"; import { ChatStorage } from "@/data/storage/chat/chat_storage"; diff --git a/src/stores/chat/chat-state.ts b/src/stores/chat/chat-state.ts index 85dabdae..7b1d7d99 100644 --- a/src/stores/chat/chat-state.ts +++ b/src/stores/chat/chat-state.ts @@ -9,7 +9,7 @@ * - `ChatWebSocketConnected` 事件 → true * - `userSession.exit` → false(WS actor cleanup 时也会跑 exit) */ -import type { UiMessage } from "@/models/chat/ui-message"; +import type { UiMessage } from "@/data/dto/chat"; export interface ChatState { messages: UiMessage[]; diff --git a/src/stores/user/user-events.ts b/src/stores/user/user-events.ts index bbb793d6..fd73086e 100644 --- a/src/stores/user/user-events.ts +++ b/src/stores/user/user-events.ts @@ -1,7 +1,7 @@ /** * User 状态机:事件联合 */ -import type { UserView } from "@/models/user/user"; +import type { UserView } from "@/data/dto/user"; export type UserEvent = | { type: "UserInit" } diff --git a/src/stores/user/user-machine.actors.ts b/src/stores/user/user-machine.actors.ts index 020a5bbb..00c6d56d 100644 --- a/src/stores/user/user-machine.actors.ts +++ b/src/stores/user/user-machine.actors.ts @@ -14,7 +14,7 @@ import { fromPromise } from "xstate"; -import type { UserView } from "@/models/user/user"; +import type { UserView } from "@/data/dto/user"; import { userRepository } from "@/data/repositories/user_repository"; import { authRepository } from "@/data/repositories/auth_repository"; import type { @@ -70,4 +70,4 @@ export const userFetchActor = fromPromise(async () => { */ export const userLogoutActor = fromPromise(async () => { await authRepo.logout(); -}); \ No newline at end of file +}); diff --git a/src/stores/user/user-machine.helpers.ts b/src/stores/user/user-machine.helpers.ts index 647acd70..eaa9f901 100644 --- a/src/stores/user/user-machine.helpers.ts +++ b/src/stores/user/user-machine.helpers.ts @@ -13,7 +13,7 @@ * - machine 依赖 actors(import)—— 不直接依赖 helpers */ -import type { UserView } from "@/models/user/user"; +import type { UserView } from "@/data/dto/user"; import { UserStorage } from "@/data/storage/user/user_storage"; import { Result } from "@/utils/result"; @@ -102,4 +102,4 @@ export async function readInitData(): Promise { } return { user, avatarUrl }; -} \ No newline at end of file +} diff --git a/src/stores/user/user-state.ts b/src/stores/user/user-state.ts index b7a6e3a0..5f192938 100644 --- a/src/stores/user/user-state.ts +++ b/src/stores/user/user-state.ts @@ -1,7 +1,7 @@ /** * User 状态机:State 形状 + 初始值 */ -import type { UserView } from "@/models/user/user"; +import type { UserView } from "@/data/dto/user"; export interface UserState { currentUser: UserView | null;