feat: maskpage&newchatpage adapt new ui framework done

This commit is contained in:
butterfly
2024-04-19 11:55:51 +08:00
parent b3559f99a2
commit 3d0a98d5d2
40 changed files with 2273 additions and 774 deletions

View File

@@ -30,9 +30,26 @@ export type ChatMessage = RequestMessage & {
model?: ModelType;
};
export function createMessage(override: Partial<ChatMessage>): ChatMessage {
let tempGlobalId = 0;
export function createMessage(
override: Partial<ChatMessage>,
options?: { temp?: boolean; customId?: string },
): ChatMessage {
const { temp, customId } = options ?? {};
let id: string;
if (customId) {
id = customId;
} else if (temp) {
tempGlobalId += 1;
id = String(tempGlobalId);
} else {
id = nanoid();
}
return {
id: nanoid(),
id,
date: new Date().toLocaleString(),
role: "user",
content: "",