diff --git a/src/pages/componentLibrary/collapseBox.tsx b/src/pages/componentLibrary/collapseBox.tsx index 1e29a38..bf869b3 100644 --- a/src/pages/componentLibrary/collapseBox.tsx +++ b/src/pages/componentLibrary/collapseBox.tsx @@ -1,8 +1,11 @@ import React, { useState, useEffect } from 'react'; -import { Collapse, Tag } from '@arco-design/web-react'; +import { Collapse, Tag, Grid } from '@arco-design/web-react'; import { getLocalStorageData } from '@/utils/storage'; +import CompNode from './compNode'; const CollapseItem = Collapse.Item; +const Row = Grid.Row; +const Col = Grid.Col; interface CollapseBoxProps { componentType: string; @@ -31,13 +34,22 @@ const CollapseBox: React.FC = ({ componentType }) => { } > - {v.children.map((v, i) => { - return ( -
- {v.label} -
- ); - })} + + {v.children.map((v, i) => { + return ( + + + + ); + })} + ); })} diff --git a/src/pages/componentLibrary/compNode.tsx b/src/pages/componentLibrary/compNode.tsx new file mode 100644 index 0000000..1582e23 --- /dev/null +++ b/src/pages/componentLibrary/compNode.tsx @@ -0,0 +1,81 @@ +import React from 'react'; +import styles from './style/compNode.module.less'; +import { Card, Divider, Tag } from '@arco-design/web-react'; +import { IconCaretRight } from '@arco-design/web-react/icon'; +import { formatDataType } from '@/utils/common'; + +type NodeData = { + label: string; + + [key: string]: any +}; + +interface CompNodeProps { + nodeData: NodeData; +} + +const CompNode: React.FC = ({ nodeData }) => { + return ( +
+ + {/*节点渲染*/} +
+ {/*节点标题*/} +
+ {nodeData.label} +
+ {/*节点api相关的输入输出*/} +
+
+ {nodeData.apis.map((v, i) => { + return ( +
+
+
{v.id}
+
+ ); + })} +
+
+
+
{nodeData.apiOut.id}
+
+
+
+
+ + {/*节点data相关的输入输出*/} +
+
+ {nodeData.dataIns.map((v, i) => { + return ( +
+
+
{v.id} {formatDataType(v.dataType)}
+
+ ); + })} +
+
+ {nodeData.dataOuts.map((v, i) => { + return ( +
+
{v.id} {formatDataType(v.dataType)}
+
+
+ ); + })} +
+
+
+ {/*其他信息渲染*/} +
+ {nodeData.comp.codeLanguage} +
{nodeData.comp.description}
+
+
+
+ ); +}; + +export default CompNode; \ No newline at end of file diff --git a/src/pages/componentLibrary/style/compNode.module.less b/src/pages/componentLibrary/style/compNode.module.less new file mode 100644 index 0000000..ba87315 --- /dev/null +++ b/src/pages/componentLibrary/style/compNode.module.less @@ -0,0 +1,82 @@ +.comp-node-container { + + .comp-node-box { + width: 90%; + margin: 0 auto; + border-radius: 10px; + box-shadow: 0 0 10px #cccccc; + padding: 8px 0; + + .comp-node-title { + text-align: center; + font-size: 18px; + margin-bottom: 10px; + } + + .comp-node-api { + display: flex; + align-items: center; + justify-content: space-between; + + .api-in, + .api-out { + display: flex; + flex-direction: column; + font-size: 16px; + font-weight: 700; + + .flex-box { + display: flex; + align-items: center; + + .right-arrow { + width: 0; + height: 0; + border-top: 5px solid transparent; + border-bottom: 5px solid transparent; + border-left: 10px solid #68b25b; /* 箭头颜色 */ + } + } + } + + .api-out { + justify-content: flex-end; + } + } + + .comp-node-data { + + .data-in, + .data-out { + display: flex; + flex-direction: column; + + .flex-box { + display: flex; + align-items: center; + flex: 1; + + .rectangular { + width: 11px; + height: 8px; + background-color: #68b25b; + border-radius: 3px; + } + } + } + + .data-out { + align-items: flex-end; + } + } + } + + + .comp-node-other { + margin-top: 20px; + + .description { + margin-top: 10px; + } + } +} \ No newline at end of file diff --git a/src/utils/common.ts b/src/utils/common.ts index 5bb4fa4..07dddc6 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -87,4 +87,23 @@ export function formatTimestamp(timestamp: number): string { const isMillisecond = timestamp.toString().length >= 13; const millisecondTimestamp = isMillisecond ? timestamp : timestamp * 1000; return dayjs(millisecondTimestamp).format('YYYY-MM-DD HH:mm:ss'); +} + +// 格式化数据类型 +export function formatDataType(value: string): string { + const dataTypeAbbr = new Map([ + ['INTEGER', 'INT'], + ['STRING', 'STR'], + ['FLOAT', 'FLOAT'], + ['DOUBLE', 'DOU'], + ['ARRAY', 'ARR'], + ['BOOLEAN', 'BOOL'], + ['OBJECT', 'OBJECT'], + ['DATE', 'DATE'], + ['DATETIME', 'DT'], + ['TIMESTAMP', 'TS'], + ['JSON', 'JSON'] + ]); + + return dataTypeAbbr.get(value) || value; } \ No newline at end of file