feat(chat): sync multi-role backend APIs

This commit is contained in:
2026-07-20 11:29:54 +08:00
parent 16b5c16e76
commit b6fdc912ae
84 changed files with 1488 additions and 439 deletions
+9 -3
View File
@@ -7,6 +7,7 @@ import {
DEFAULT_CHARACTER_ID,
} from "@/data/constants/character";
import type { ChatPromotionState } from "./helper/promotion";
import type { CharacterErrorCode } from "@/data/services/api";
export type ChatUpgradeReason = "insufficient_credits";
@@ -29,6 +30,7 @@ export interface ChatUnlockPaywallRequest
export interface ChatState {
characterId: string;
characterErrorCode: CharacterErrorCode | null;
emptyChatGreeting: string;
messages: UiMessage[];
promotion: ChatPromotionState | null;
@@ -58,11 +60,12 @@ export interface ChatState {
}
export function createInitialChatState(
characterId: string = DEFAULT_CHARACTER_ID,
emptyChatGreeting: string = DEFAULT_CHARACTER.emptyChatGreeting,
characterId: string,
emptyChatGreeting: string,
): ChatState {
return {
characterId,
characterErrorCode: null,
emptyChatGreeting,
messages: [],
promotion: null,
@@ -91,4 +94,7 @@ export function createInitialChatState(
};
}
export const initialState: ChatState = createInitialChatState();
export const initialState: ChatState = createInitialChatState(
DEFAULT_CHARACTER_ID,
DEFAULT_CHARACTER.emptyChatGreeting,
);