Trim online design previews from AI panels
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
sendAgentMessageStream,
|
||||
} from '#/api/ai-platform/ai-platform';
|
||||
import { ChatBox } from '#/components/ChatBox/index';
|
||||
import { AppDesignPanel, DesignEditorPanel } from '#/components/form-editor';
|
||||
import { DesignEditorPanel } from '#/components/form-editor';
|
||||
|
||||
import AiWorkingAnimation from '../../../../components/ai-loading/AiWorkingAnimation.vue';
|
||||
|
||||
@@ -54,7 +54,6 @@ const emit = defineEmits<{
|
||||
|
||||
// 设计面板显示状态
|
||||
const showDesignPanel = ref(false);
|
||||
const showAppDesignPanel = ref(false);
|
||||
|
||||
// 对话状态
|
||||
const chatMessages = ref<AgentMessage[]>([]);
|
||||
@@ -79,14 +78,6 @@ const currentDesign = ref<null | {
|
||||
type: string;
|
||||
}>(null);
|
||||
|
||||
// 应用设计面板状态
|
||||
const currentAppDesign = ref<null | {
|
||||
data: any;
|
||||
nodeId: string;
|
||||
title: string;
|
||||
type: string;
|
||||
}>(null);
|
||||
|
||||
// 取消流式请求
|
||||
let cancelStream: (() => void) | null = null;
|
||||
|
||||
@@ -493,31 +484,17 @@ function handleStreamEvent(
|
||||
if (configData?.type === 'design_preview') {
|
||||
const previewType = configData.preview_type;
|
||||
|
||||
// 应用设计方案使用 AppDesignPanel(富文本编辑器)
|
||||
if (previewType === 'app_design') {
|
||||
currentAppDesign.value = {
|
||||
type: previewType,
|
||||
title:
|
||||
configData.title ||
|
||||
$t('ai-platform.agent.chatPanel.appDesignTitle'),
|
||||
data: configData.data || {},
|
||||
nodeId: event.node_id || '',
|
||||
};
|
||||
showAppDesignPanel.value = true;
|
||||
} else {
|
||||
// 其他设计类型使用 DesignEditorPanel(表单编辑器)
|
||||
currentDesign.value = {
|
||||
type: previewType,
|
||||
title:
|
||||
configData.title ||
|
||||
$t('ai-platform.agent.chatPanel.designPreview'),
|
||||
data: configData.data || {},
|
||||
nodeId: event.node_id || '',
|
||||
form_fields: configData.form_fields || [],
|
||||
table_configs: configData.table_configs || [],
|
||||
};
|
||||
showDesignPanel.value = true;
|
||||
}
|
||||
currentDesign.value = {
|
||||
type: previewType,
|
||||
title:
|
||||
configData.title ||
|
||||
$t('ai-platform.agent.chatPanel.designPreview'),
|
||||
data: configData.data || {},
|
||||
nodeId: event.node_id || '',
|
||||
form_fields: configData.form_fields || [],
|
||||
table_configs: configData.table_configs || [],
|
||||
};
|
||||
showDesignPanel.value = true;
|
||||
|
||||
// 显示提示消息
|
||||
const waitingContent = `**${configData.title}**\n\n${configData.message || $t('ai-platform.agent.chatPanel.designPanelHint')}`;
|
||||
@@ -795,46 +772,6 @@ function handleDesignCancel() {
|
||||
currentDesign.value = null;
|
||||
}
|
||||
|
||||
// 应用设计面板确认
|
||||
function handleAppDesignConfirm(data: Record<string, any>) {
|
||||
showAppDesignPanel.value = false;
|
||||
|
||||
// 添加用户确认消息
|
||||
const userMsg: AgentMessage = {
|
||||
id: generateId(),
|
||||
role: 'user',
|
||||
content: $t('ai-platform.agent.chatPanel.confirmAppDesign'),
|
||||
status: 'completed',
|
||||
reasoning_steps: [],
|
||||
tool_calls: [],
|
||||
prompt_tokens: 0,
|
||||
completion_tokens: 0,
|
||||
total_tokens: 0,
|
||||
elapsed_time: 0,
|
||||
error_message: '',
|
||||
feedback: '',
|
||||
created_at: new Date().toISOString(),
|
||||
};
|
||||
chatMessages.value.push(userMsg);
|
||||
|
||||
// 重置等待状态
|
||||
waitingForInput.value = false;
|
||||
waitingConfig.value = null;
|
||||
currentAppDesign.value = null;
|
||||
|
||||
// 继续工作流,传递编辑后的数据
|
||||
doSendMessage(JSON.stringify(data), false);
|
||||
}
|
||||
|
||||
// 应用设计面板取消
|
||||
function handleAppDesignCancel() {
|
||||
showAppDesignPanel.value = false;
|
||||
waitingForInput.value = false;
|
||||
waitingConfig.value = null;
|
||||
currentAppDesign.value = null;
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
clearChat,
|
||||
scrollToBottom,
|
||||
@@ -909,18 +846,5 @@ onUnmounted(() => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 应用设计面板 -->
|
||||
<div
|
||||
v-if="showAppDesignPanel && currentAppDesign"
|
||||
class="flex flex-1 flex-col overflow-hidden"
|
||||
>
|
||||
<AppDesignPanel
|
||||
:visible="showAppDesignPanel"
|
||||
:design="currentAppDesign as any"
|
||||
@update:visible="showAppDesignPanel = $event"
|
||||
@confirm="handleAppDesignConfirm"
|
||||
@close="handleAppDesignCancel"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user