50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import type { UiMessage } from "@/data/dto/chat";
|
|
|
|
export interface ChatState {
|
|
messages: UiMessage[];
|
|
isReplyingAI: boolean;
|
|
pendingReplyCount: number;
|
|
/**
|
|
* WebSocket 连接状态(仅 VIP 用户会话期间 true)
|
|
* - VIP true:走 WS
|
|
* - 非 VIP / 游客:固定 false,走 HTTP
|
|
*/
|
|
wsConnected: boolean;
|
|
upgradePromptVisible: boolean;
|
|
upgradeReason: "daily_limit" | "private_message" | "image" | null;
|
|
upgradeHint: string | null;
|
|
upgradeDetail:
|
|
| {
|
|
type?: string;
|
|
usedToday?: number;
|
|
usedTotal?: number;
|
|
limit?: number;
|
|
}
|
|
| null;
|
|
unlockingPrivateMessageId: string | null;
|
|
isLoadingMore: boolean;
|
|
hasMore: boolean;
|
|
historyOffset: number;
|
|
/** history 加载完成标志(initial load —— local → network → save 跑完)
|
|
* - guestSession.initializing / user sessions initializing 走 always barrier
|
|
* - 不被 `loadMoreHistoryActor` 设置(翻页是另一码事)
|
|
*/
|
|
historyLoaded: boolean;
|
|
}
|
|
|
|
export const initialState: ChatState = {
|
|
messages: [],
|
|
isReplyingAI: false,
|
|
pendingReplyCount: 0,
|
|
wsConnected: false,
|
|
upgradePromptVisible: false,
|
|
upgradeReason: null,
|
|
upgradeHint: null,
|
|
upgradeDetail: null,
|
|
unlockingPrivateMessageId: null,
|
|
isLoadingMore: false,
|
|
hasMore: true,
|
|
historyOffset: 0,
|
|
historyLoaded: false,
|
|
};
|