From f525707358e8766e5bc44478fcf213ef33802cbe Mon Sep 17 00:00:00 2001 From: wren Date: Tue, 31 Mar 2026 15:12:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(rules):=20VLM=20=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=A4=9A=E5=AE=9E=E4=BD=93=E9=80=90=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=BC=80=E5=85=B3=EF=BC=8C=E5=AF=B9=E9=BD=90=20LLM=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 多实体总开关开启后,VLM 字段可点击单独切换 multi_entity(绿色=已开启) - 新增 VLM 字段时默认写入 multi_entity: false - 删除按钮 stopPropagation 避免触发多实体切换 Co-Authored-By: Claude Sonnet 4.6 --- .../rules/new/ExtractionSettings.tsx | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/app/components/rules/new/ExtractionSettings.tsx b/app/components/rules/new/ExtractionSettings.tsx index dd954f1..6c1a48f 100644 --- a/app/components/rules/new/ExtractionSettings.tsx +++ b/app/components/rules/new/ExtractionSettings.tsx @@ -232,12 +232,14 @@ export function ExtractionSettings({ newFields.push({ name: input, type: selectedVlmFieldType as VLMFieldType, - template: customVlmPrompt + template: customVlmPrompt, + multi_entity: false, }); } else { newFields.push({ name: input, - type: selectedVlmFieldType as VLMFieldType + type: selectedVlmFieldType as VLMFieldType, + multi_entity: false, }); } } @@ -289,6 +291,18 @@ export function ExtractionSettings({ setHasPendingChanges(true); }; + // 切换 VLM 字段的多实体状态 + const toggleVLMFieldMultiEntity = (index: number) => { + if (!multiEntityEnabled) return; // 多实体未开启时不允许切换 + const newFields = [...fields.vlm]; + const field = newFields[index]; + if (typeof field === 'object') { + newFields[index] = { ...field, multi_entity: !field.multi_entity }; + setFields({ ...fields, vlm: newFields }); + setHasPendingChanges(true); + } + }; + // 获取VLM字段信息 const getFieldInfo = (field: string | { name: string, type: string, template?: string }) => { let fieldName, fieldType, typeName, badgeClass; @@ -885,18 +899,27 @@ export function ExtractionSettings({
{fields.vlm.map((field, index) => { const { fieldName, fieldType, typeName, badgeClass } = getFieldInfo(field); + const isMulti = typeof field === 'object' && field.multi_entity === true; return ( -
+
toggleVLMFieldMultiEntity(index)} + role={multiEntityEnabled ? 'button' : undefined} + title={multiEntityEnabled ? (isMulti ? '点击关闭多实体展开' : '点击开启多实体展开') : fieldName} + > {fieldName} {typeName} removeField("vlm", index)} + onClick={(e) => { e.stopPropagation(); removeField("vlm", index); }} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") removeField("vlm", index); @@ -904,6 +927,7 @@ export function ExtractionSettings({ role="button" tabIndex={0} aria-label={`删除字段 ${fieldName}`} + style={multiEntityEnabled && isMulti ? { color: 'rgba(255,255,255,0.8)' } : undefined} > ×