perf: 中断打字
This commit is contained in:
@ -1,6 +1,29 @@
|
||||
import type { Ref } from 'vue';
|
||||
import type { BubbleListProps } from '@/components/xt-chat/xt-bubble/types';
|
||||
|
||||
export interface UseChatHandlerReturn {
|
||||
roles?: BubbleListProps['roles'];
|
||||
generateTeamRunTaskId?: Ref<string | null>;
|
||||
handleMessage?: (parsedData: { event: string; data: MESSAGE.Answer }) => void;
|
||||
handleOpen?: (data: Response) => void;
|
||||
generateLoading?: Ref<boolean>;
|
||||
conversationList?: Ref<any[]>;
|
||||
showRightView?: Ref<boolean>;
|
||||
rightViewData?: Ref<any>;
|
||||
senderRef?: Ref<null>
|
||||
}
|
||||
export enum EnumTeamRunStatus {
|
||||
TeamRunStarted = 'TeamRunStarted', // 对话开始
|
||||
TeamRunResponseContent = 'TeamRunResponseContent', // 对话执行中
|
||||
TeamRunCompleted = 'TeamRunCompleted', // 对话完成
|
||||
RunStarted = 'RunStarted', // l2开始运行
|
||||
RunResponseContent = 'RunResponseContent', // l2执行中
|
||||
RunCompleted = 'RunCompleted', // l2完成
|
||||
}
|
||||
export interface UseChatHandlerOptions {
|
||||
initSse: (inputInfo: CHAT.TInputInfo) => Promise<void>; // 明确 initSse 带参
|
||||
}
|
||||
|
||||
// 定义角色常量
|
||||
export const LOADING_ROLE = 'loading'; // 加载中
|
||||
export const INTELLECTUAL_THINKING_ROLE = 'intellectual_thinking'; // 智能思考标题
|
||||
@ -22,26 +45,6 @@ export const ANSWER_STYLE = {
|
||||
left: '6px',
|
||||
};
|
||||
|
||||
export interface UseChatHandlerReturn {
|
||||
roles?: BubbleListProps['roles'];
|
||||
generateTeamRunTaskId?: Ref<string | null>;
|
||||
handleMessage?: (parsedData: { event: string; data: MESSAGE.Answer }) => void;
|
||||
handleOpen?: (data: Response) => void;
|
||||
generateLoading?: Ref<boolean>;
|
||||
conversationList?: Ref<any[]>;
|
||||
showRightView?: Ref<boolean>;
|
||||
rightViewData?: Ref<any>;
|
||||
senderRef?: Ref<null>
|
||||
}
|
||||
export enum EnumTeamRunStatus {
|
||||
TeamRunStarted = 'TeamRunStarted', // 对话开始
|
||||
TeamRunResponseContent = 'TeamRunResponseContent', // 对话执行中
|
||||
TeamRunCompleted = 'TeamRunCompleted', // 对话完成
|
||||
RunStarted = 'RunStarted', // l2开始运行
|
||||
RunResponseContent = 'RunResponseContent', // l2执行中
|
||||
RunCompleted = 'RunCompleted', // l2完成
|
||||
}
|
||||
|
||||
export const FILE_TYPE = {
|
||||
topic_only: 'topic_only', // 排期&选题
|
||||
topic_with_content: 'topic_with_content', // 选题&内容稿件
|
||||
|
||||
@ -31,18 +31,19 @@ import {
|
||||
REMOTE_ASSISTANT_ROLE,
|
||||
FILE_TYPE_MAP,
|
||||
} from './constants';
|
||||
import type { UseChatHandlerReturn } from './constants';
|
||||
import type { UseChatHandlerReturn, UseChatHandlerOptions } from './constants';
|
||||
|
||||
/**
|
||||
* 聊天处理器Hook
|
||||
* @returns 包含角色配置、消息处理函数和对话列表的对象
|
||||
*/
|
||||
export default function useChatHandler({ initSse }): UseChatHandlerReturn {
|
||||
export default function useChatHandler(options: UseChatHandlerOptions): UseChatHandlerReturn {
|
||||
const { initSse } = options;
|
||||
// 在内部定义对话列表
|
||||
const { copy } = useClipboard();
|
||||
|
||||
const senderRef = ref(null);
|
||||
const conversationList = ref<any[]>([]);
|
||||
const conversationList = ref<MESSAGE.Answer[]>([]);
|
||||
const generateLoading = ref<boolean>(false);
|
||||
const generateTeamRunTaskId = ref<string | null>(null);
|
||||
const showRightView = ref(false);
|
||||
|
||||
Reference in New Issue
Block a user