perf: 走查问题调整
This commit is contained in:
@ -11,12 +11,16 @@ import { FILE_TYPE } from '@/components/xt-chat/chat-view/constants';
|
||||
export default {
|
||||
emits: ['close'],
|
||||
props: {
|
||||
rightViewData: {
|
||||
dataSource: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
previewData: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
setup(props: { rightViewData: any[] }, { emit, expose }) {
|
||||
setup(props: { dataSource: any[]; previewData: any }, { emit, expose }) {
|
||||
const bubbleRef = ref(null);
|
||||
|
||||
const md = markdownit({
|
||||
@ -26,19 +30,15 @@ export default {
|
||||
typographer: true,
|
||||
});
|
||||
|
||||
const dataSource = computed(() => {
|
||||
return props.rightViewData.find((v) => v.task_type === '任务管理') ?? {};
|
||||
});
|
||||
|
||||
const tasks = computed(() => {
|
||||
return dataSource.value.payload?.tasks ?? [];
|
||||
return props.previewData.payload?.tasks ?? [];
|
||||
});
|
||||
|
||||
const isTaskManage = computed(() => {
|
||||
return dataSource.value.task_type === '任务管理';
|
||||
return props.previewData.task_type === '任务管理';
|
||||
});
|
||||
const hasMediaCenter = computed(() => {
|
||||
return props.rightViewData.some((v) => v.task_type === '素材中心')
|
||||
return props.dataSource.some((v) => v.task_type === '素材中心');
|
||||
});
|
||||
|
||||
const onDownload = () => {
|
||||
@ -46,10 +46,11 @@ export default {
|
||||
message.success('下载成功!');
|
||||
};
|
||||
const onAddMediaCenter = () => {
|
||||
const _data = props.dataSource.find((v) => v.task_type === '素材中心');
|
||||
const {
|
||||
api: { endpoint, method },
|
||||
payload,
|
||||
} = dataSource.value;
|
||||
} = _data;
|
||||
Http[method.toLowerCase()]?.(endpoint, payload).then((res) => {
|
||||
const { code } = res;
|
||||
if (code === 200) {
|
||||
@ -58,10 +59,11 @@ export default {
|
||||
});
|
||||
};
|
||||
const onAddTaskManage = () => {
|
||||
const _data = props.dataSource.find((v) => v.task_type === '任务管理');
|
||||
const {
|
||||
api: { endpoint, method },
|
||||
payload,
|
||||
} = dataSource.value;
|
||||
} = _data;
|
||||
Http[method.toLowerCase()]?.(endpoint, payload).then((res) => {
|
||||
const { code } = res;
|
||||
if (code === 200) {
|
||||
@ -111,7 +113,7 @@ export default {
|
||||
);
|
||||
};
|
||||
const renderTaskManage = () => {
|
||||
const { file_type } = dataSource.value;
|
||||
const { file_type } = props.previewData;
|
||||
return tasks.value.map((item) => {
|
||||
const { params, execution_time, name } = item;
|
||||
if (file_type === FILE_TYPE.topic_only) {
|
||||
|
||||
@ -9,7 +9,8 @@ export interface UseChatHandlerReturn {
|
||||
generateLoading?: Ref<boolean>;
|
||||
conversationList?: Ref<any[]>;
|
||||
showRightView?: Ref<boolean>;
|
||||
rightViewData?: Ref<any>;
|
||||
rightViewDataSource?: Ref<any>;
|
||||
rightPreviewData?: Ref<any>;
|
||||
senderRef?: Ref<null>
|
||||
}
|
||||
export enum EnumTeamRunStatus {
|
||||
|
||||
@ -108,7 +108,8 @@ export default {
|
||||
const {
|
||||
roles,
|
||||
showRightView,
|
||||
rightViewData,
|
||||
rightViewDataSource,
|
||||
rightPreviewData,
|
||||
generateTeamRunTaskId,
|
||||
handleMessage,
|
||||
conversationList,
|
||||
@ -178,7 +179,8 @@ export default {
|
||||
{showRightView.value && (
|
||||
<RightView
|
||||
ref={rightViewRef}
|
||||
rightViewData={rightViewData.value}
|
||||
dataSource={rightViewDataSource.value}
|
||||
previewData={rightPreviewData.value}
|
||||
showRightView={showRightView.value}
|
||||
onClose={() => (showRightView.value = false)}
|
||||
/>
|
||||
|
||||
@ -48,7 +48,8 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
|
||||
const generateTeamRunTaskId = ref<string | null>(null);
|
||||
|
||||
const showRightView = ref(false);
|
||||
const rightViewData = ref<any>({});
|
||||
const rightViewDataSource = ref<any>([]);
|
||||
const rightPreviewData = ref<any>([]);
|
||||
|
||||
// 初始化markdown
|
||||
const md = markdownit({
|
||||
@ -84,18 +85,28 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
|
||||
placement: 'end',
|
||||
shape: 'round',
|
||||
style: ROLE_STYLE,
|
||||
messageRender: (message: string) => {
|
||||
return <div class="max-w-400px">
|
||||
{message}
|
||||
</div>;
|
||||
},
|
||||
},
|
||||
[REMOTE_USER_ROLE]: {
|
||||
placement: 'end',
|
||||
shape: 'round',
|
||||
style: ROLE_STYLE,
|
||||
messageRender: (message: string) => {
|
||||
return <div class="max-w-400px">
|
||||
{message}
|
||||
</div>;
|
||||
},
|
||||
},
|
||||
[REMOTE_ASSISTANT_ROLE]: {
|
||||
placement: 'start',
|
||||
variant: 'borderless',
|
||||
style: ROLE_STYLE,
|
||||
messageRender: (message: string) => {
|
||||
return <div v-html={md.render(message)} />;
|
||||
return <div class="max-w-400px" v-html={md.render(message)} />;
|
||||
},
|
||||
footer: (params) => {
|
||||
const { content, item } = params as { content: string; item: MESSAGE.Answer };
|
||||
@ -118,7 +129,7 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
|
||||
|
||||
// 下载处理
|
||||
const onDownload = () => {
|
||||
console.log('onDownload', rightViewData.value);
|
||||
console.log('onDownload', rightViewDataSource.value);
|
||||
};
|
||||
|
||||
const onCopy = (content: string) => {
|
||||
@ -303,13 +314,14 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
|
||||
// 含有思考过程,折叠思考过程,展示结果
|
||||
if (_hasRunTask) {
|
||||
setRunTaskCollapse(teamRunTaskId, false);
|
||||
if (extra_data) {
|
||||
const _targetData = extra_data?.data?.find((item: any) => item.task_type === '任务管理')
|
||||
if (_targetData) {
|
||||
showRightView.value = true;
|
||||
rightViewData.value = extra_data.data;
|
||||
rightViewDataSource.value = extra_data.data;
|
||||
rightPreviewData.value = _targetData;
|
||||
}
|
||||
|
||||
_targetTask.content.customRender = () => {
|
||||
const _targetData = extra_data?.data.find((item: any) => item.task_type === '任务管理')
|
||||
return (
|
||||
<>
|
||||
<div v-html={md.render(output)} />
|
||||
@ -395,6 +407,7 @@ export default function useChatHandler(options: UseChatHandlerOptions): UseChatH
|
||||
generateLoading,
|
||||
conversationList,
|
||||
showRightView,
|
||||
rightViewData,
|
||||
rightViewDataSource,
|
||||
rightPreviewData
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user