From 790dc388849b4769b39d9c2a4fa082422d33de7c Mon Sep 17 00:00:00 2001 From: ZLY Date: Fri, 5 Dec 2025 14:26:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(params-table):=20=E4=B8=BA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=A1=A8=E6=A0=BC=E6=B7=BB=E5=8A=A0=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=BA=A2=E5=87=BA=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nodeEditors/components/ParamsTable.tsx | 107 ++++++++++++++---- 1 file changed, 83 insertions(+), 24 deletions(-) diff --git a/src/components/FlowEditor/nodeEditors/components/ParamsTable.tsx b/src/components/FlowEditor/nodeEditors/components/ParamsTable.tsx index 1263994..4f2567e 100644 --- a/src/components/FlowEditor/nodeEditors/components/ParamsTable.tsx +++ b/src/components/FlowEditor/nodeEditors/components/ParamsTable.tsx @@ -1,8 +1,39 @@ import React, { useState, useEffect } from 'react'; -import { Input, Select, Table, Button } from '@arco-design/web-react'; +import { Input, Select, Table, Button, Popover } from '@arco-design/web-react'; import { IconDelete } from '@arco-design/web-react/icon'; import { useSelector } from 'react-redux'; +// 文本溢出显示组件,超出时显示 Popover +const EllipsisWithPopover: React.FC<{ text: string; maxWidth?: number }> = ({ text, maxWidth = 100 }) => { + if (!text) return -; + + const style: React.CSSProperties = { + maxWidth, + overflow: 'hidden', + textOverflow: 'ellipsis', + whiteSpace: 'nowrap', + display: 'inline-block', + verticalAlign: 'middle' + }; + + // 简单判断:文本长度超过一定值时显示 Popover + const shouldShowPopover = text.length > maxWidth / 8; + + if (shouldShowPopover) { + return ( + {text}} + position="top" + trigger="hover" + > + {text} + + ); + } + + return {text}; +}; + interface TableDataItem { key: number | string; id: string; @@ -72,13 +103,20 @@ const ParamsTable: React.FC = ({ dataIndex: 'id', render: (_: any, record: TableDataItem) => ( record.id === 'maxTime' ? ( - {record.id} + ) : ( - handleSave({ ...record, id: value })} - /> + {record.id} : null} + position="top" + trigger="hover" + disabled={!record.id || record.id.length <= 12} + > + handleSave({ ...record, id: value })} + /> + ) ) }, @@ -121,12 +159,19 @@ const ParamsTable: React.FC = ({ dataIndex: 'desc', render: (_: any, record: TableDataItem) => ( record.id === 'maxTime' ? ( - {record.desc} + ) : ( - handleSave({ ...record, desc: value })} - /> + {record.desc} : null} + position="top" + trigger="hover" + disabled={!record.desc || record.desc.length <= 15} + > + handleSave({ ...record, desc: value })} + /> + ) ) }, @@ -154,12 +199,19 @@ const ParamsTable: React.FC = ({ style={{ width: '100%', minWidth: 100 }} autoWidth={{ minWidth: 150, maxWidth: 200 }} /> - handleSave({ ...record, defaultValue: value })} - placeholder="请输入默认值" - /> + {record.defaultValue} : null} + position="top" + trigger="hover" + disabled={!record.defaultValue || record.defaultValue.length <= 20} + > + handleSave({ ...record, defaultValue: value })} + placeholder="请输入默认值" + /> + ); } @@ -179,12 +231,19 @@ const ParamsTable: React.FC = ({ } return ( - handleSave({ ...record, defaultValue: value })} - placeholder="请输入默认值" - /> + {record.defaultValue} : null} + position="top" + trigger="hover" + disabled={!record.defaultValue || record.defaultValue.length <= 20} + > + handleSave({ ...record, defaultValue: value })} + placeholder="请输入默认值" + /> + ); } }