diff --git a/frontend/src/components/VariableInput/index.tsx b/frontend/src/components/VariableInput/index.tsx index 00885a58..0fd0b354 100644 --- a/frontend/src/components/VariableInput/index.tsx +++ b/frontend/src/components/VariableInput/index.tsx @@ -1,47 +1,10 @@ import React, { useState, useRef, useMemo, useEffect } from 'react'; -import { Command, CommandEmpty, CommandGroup, CommandItem, CommandList } from '@/components/ui/command'; import { Input } from '@/components/ui/input'; import { Textarea } from '@/components/ui/textarea'; import type { VariableInputProps } from './types'; import { detectTrigger, insertVariable, filterVariables } from './utils'; import { collectNodeVariables, groupVariablesByNode } from '@/utils/workflow/collectNodeVariables'; -/** - * 高亮渲染 ${} 变量 - */ -const highlightVariables = (text: string): React.ReactNode[] => { - const regex = /\$\{([^}]+)\}/g; - const parts: React.ReactNode[] = []; - let lastIndex = 0; - let match; - - while ((match = regex.exec(text)) !== null) { - // 添加变量前的文本 - if (match.index > lastIndex) { - parts.push(text.substring(lastIndex, match.index)); - } - - // 添加高亮的变量 - parts.push( - - ${`{${match[1]}}`} - - ); - - lastIndex = match.index + match[0].length; - } - - // 添加剩余文本 - if (lastIndex < text.length) { - parts.push(text.substring(lastIndex)); - } - - return parts.length > 0 ? parts : [text]; -}; - /** * 变量输入组件 * 支持在输入 ${ 时自动提示可用变量 @@ -115,15 +78,9 @@ const VariableInput: React.FC = ({ // 插入变量 const handleSelectVariable = (nodeName: string, fieldName: string) => { - console.log('🎯 handleSelectVariable 被调用:', { nodeName, fieldName, value, triggerInfo }); - - if (!inputRef.current) { - console.error('❌ inputRef.current 不存在'); - return; - } + if (!inputRef.current) return; const cursorPos = inputRef.current.selectionStart || 0; - console.log('📍 当前光标位置:', cursorPos); // 使用工具函数插入变量 const { newText, newCursorPos } = insertVariable( @@ -133,8 +90,6 @@ const VariableInput: React.FC = ({ nodeName, fieldName ); - - console.log('✅ 插入结果:', { newText, newCursorPos }); // 更新值 onChange(newText); @@ -147,7 +102,6 @@ const VariableInput: React.FC = ({ if (inputRef.current) { inputRef.current.focus(); inputRef.current.setSelectionRange(newCursorPos, newCursorPos); - console.log('✅ 焦点已恢复,光标已设置'); } }, 0); }; @@ -200,10 +154,7 @@ const VariableInput: React.FC = ({
{ - console.log('点击变量:', variable.nodeName, variable.fieldName); - handleSelectVariable(variable.nodeName, variable.fieldName); - }} + onClick={() => handleSelectVariable(variable.nodeName, variable.fieldName)} > {variable.fieldName} {variable.fieldType} @@ -216,28 +167,20 @@ const VariableInput: React.FC = ({ ); }; - // 检测是否有变量需要高亮 - const hasVariables = value && /\$\{[^}]+\}/.test(value); - return ( -
+
{/* 输入框 */} {renderInput()} - {/* 变量高亮预览 */} - {hasVariables && !showSuggestions && ( -
-
变量预览:
-
- {highlightVariables(value)} -
-
- )} - - {/* 变量提示弹窗 - 绝对定位 */} + {/* 变量提示弹窗 - 绝对定位,使用更高的 z-index */} {showSuggestions && (
{renderSuggestions()} diff --git a/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx b/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx index 02ad5e41..133fa2bb 100644 --- a/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx +++ b/frontend/src/pages/Workflow/Design/nodes/NotificationNode.tsx @@ -1,4 +1,4 @@ -import { ConfigurableNodeDefinition, NodeType, NodeCategory } from './types'; +import {ConfigurableNodeDefinition, NodeType, NodeCategory} from './types'; /** * 通知节点定义 @@ -14,7 +14,7 @@ export const NotificationNodeDefinition: ConfigurableNodeDefinition = { // 渲染配置 renderConfig: { shape: 'rounded-rect', - size: { width: 120, height: 60 }, + size: {width: 120, height: 60}, icon: { type: 'emoji', content: '🔔', @@ -29,7 +29,7 @@ export const NotificationNodeDefinition: ConfigurableNodeDefinition = { }, handles: { input: true, - output: true + output: true }, features: { showBadge: true, @@ -85,35 +85,14 @@ export const NotificationNodeDefinition: ConfigurableNodeDefinition = { }, required: ["nodeName", "nodeCode", "notificationType", "title", "content", "recipients"] }, - - // 输入映射 Schema(可以引用上游节点的输出) - inputMappingSchema: { - type: "object", - title: "输入映射", - description: "配置从上游节点获取的数据", - properties: { - dynamicTitle: { - type: "string", - title: "动态标题", - description: "使用上游节点输出动态设置标题,如 ${upstream.buildStatus}", - default: "" - }, - dynamicContent: { - type: "string", - title: "动态内容", - description: "使用上游节点输出动态设置内容,如 构建结果: ${upstream.buildStatus}", - format: "textarea", - default: "" - }, - dynamicRecipients: { - type: "string", - title: "动态收件人", - description: "使用上游节点输出动态设置收件人", - default: "" - } - } - } - - // ✅ 通知节点没有输出能力(不定义 outputs 字段) + outputs: [{ + name: "status", + title: "执行状态", + type: "string", + enum: ["SUCCESS", "FAILURE"], + description: "执行的结果状态", + example: "SUCCESS", + required: true + }] };