forked from b2894lxlx/tuanwei-admin
77378a2791
- 三模式各自独立工作区:切模式不丢消息、草稿与当前记录 - 历史面板加类型徽标与筛选(全部/聊天/写作/图片/创意/活动策划),文案改「历史记录」 - 生成成功认领末帧 chatId 并刷新列表;聊天 __END__ 帧的 chatId 同样接受 - 生图回复支持多张  渲染 - 写作/图片记录支持「按原参数再来一次」(只回填、不自动发送) - 三个独立页(文稿/创意/活动策划)加历史入口,/ai?type= 预置筛选 - 后台 aiChatList 加类型列与筛选;历史列表提示仅展示最近 30 条
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
/**
|
|
* AI 历史记录的类型(对应后端 `ai_chat_list.chat_type`)。
|
|
*
|
|
* 契约见 `docs/ai-history-contract.md`:类型由后端在生成成功时判定,前端只负责展示与筛选。
|
|
* 旧数据没有 `chat_type`,按聊天处理。
|
|
*/
|
|
|
|
export type AiChatType =
|
|
| 'chat'
|
|
| 'writing'
|
|
| 'image'
|
|
| 'creative'
|
|
| 'activity_outline';
|
|
|
|
/** 类型的中文名(徽标与后台表格共用) */
|
|
export const AI_CHAT_TYPE_LABELS: Record<AiChatType, string> = {
|
|
chat: '聊天',
|
|
writing: '写作',
|
|
image: '图片',
|
|
creative: '创意',
|
|
activity_outline: '活动策划'
|
|
};
|
|
|
|
/** 筛选下拉的可选项(不含「全部」,由使用方按需补充) */
|
|
export const AI_CHAT_TYPE_OPTIONS: { label: string; value: AiChatType }[] = [
|
|
{ label: '聊天', value: 'chat' },
|
|
{ label: '写作', value: 'writing' },
|
|
{ label: '图片', value: 'image' },
|
|
{ label: '创意', value: 'creative' },
|
|
{ label: '活动策划', value: 'activity_outline' }
|
|
];
|
|
|
|
/** 把后端返回值收敛到已知类型,缺失或未知一律按聊天处理 */
|
|
export function resolveAiChatType(value?: string | null): AiChatType {
|
|
const type = String(value || '').trim() as AiChatType;
|
|
return type in AI_CHAT_TYPE_LABELS ? type : 'chat';
|
|
}
|
|
|
|
/** 直接取中文名,用于模板与表格列 */
|
|
export function getAiChatTypeLabel(value?: string | null): string {
|
|
return AI_CHAT_TYPE_LABELS[resolveAiChatType(value)];
|
|
}
|