Trim online context from AI chat editors

This commit is contained in:
2026-06-09 00:06:35 +08:00
parent cd355180f6
commit 0a86fa80b4
7 changed files with 29 additions and 63 deletions
@@ -3,7 +3,11 @@ import type { DesignPreviewData } from './types';
import { computed, ref, watch } from 'vue';
import { Check, Copy, X } from '@vben/icons';
import {
Check,
Close as X,
CopyDocument as Copy,
} from '@element-plus/icons-vue';
import {
ElButton,
@@ -71,13 +75,14 @@ const summaryItems = computed(() => {
const fieldItems = computed(() => {
const source = payload.value as Record<string, any>;
const fields = source.form_fields || source.fields || source.schema?.fields;
const fields =
source.schema_fields || source.form_fields || source.fields || source.schema?.fields;
return Array.isArray(fields) ? fields.slice(0, 12) : [];
});
const tableItems = computed(() => {
const source = payload.value as Record<string, any>;
const tables = source.table_configs || source.tables || source.data_sources;
const tables = source.data_sources || source.table_configs || source.tables;
return Array.isArray(tables) ? tables.slice(0, 8) : [];
});
@@ -91,7 +91,7 @@ export function useChatApi(props: AiChatPanelProps): {
const adapter: ChatApiAdapter = {
sendMessage: (
message: string,
inputs: Record<string, any> | undefined,
_inputs: Record<string, any> | undefined,
onEvent: (event: StreamEvent) => void,
onError: (error: Error) => void,
onComplete: () => void,
@@ -110,16 +110,12 @@ export function useChatApi(props: AiChatPanelProps): {
type: att.type,
}));
// 从 inputs 中提取 form_code(如果存在)
const formCode = inputs?.form_code;
return sendAgentMessageStream(
props.agentId,
{
message,
conversation_id: conversationId.value || undefined,
attachments: attachmentInputs,
form_code: formCode,
},
(event) => {
// 捕获 conversation_id
@@ -97,8 +97,8 @@ export function useEventHandler(config: EventHandlerConfig) {
title: configData.title || '设计预览',
data: configData.data || {},
nodeId: event.node_id || '',
form_fields: configData.form_fields,
table_configs: configData.table_configs,
data_sources: configData.data_sources || configData.table_configs,
schema_fields: configData.schema_fields || configData.form_fields,
layoutOptions: configData.layoutOptions,
themeOptions: configData.themeOptions,
};
@@ -70,8 +70,8 @@ export interface DesignPreviewData {
title: string;
data: Record<string, any>;
nodeId: string;
form_fields?: any[];
table_configs?: any[];
data_sources?: any[];
schema_fields?: any[];
layoutOptions?: any[];
themeOptions?: any[];
}
@@ -89,6 +89,7 @@ export interface NodeEvent {
node_id: string;
node_type?: string;
node_label?: string;
event_type?: string;
status?: 'failed' | 'running' | 'success';
inputs?: Record<string, any>;
outputs?: Record<string, any>;
@@ -96,6 +97,7 @@ export interface NodeEvent {
tokens_used?: number;
error_message?: string;
loop_iteration?: number;
warnings?: any[];
}
/** 循环迭代事件 */
@@ -132,7 +134,7 @@ export interface AiChatPanelProps {
agent?: AgentInfo | null;
/** 当前对话 IDagent-chat 模式用于加载历史) */
conversationId?: null | string;
/** 初始输入参数(如 form_code 等系统变量) */
/** 初始输入参数 */
initialInputs?: Record<string, any>;
// ========== 功能开关 ==========