|
|
|
|
@ -1,10 +1,340 @@
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import styles from './style/compDetails.module.less';
|
|
|
|
|
import { Space, Divider, Button, Typography, Card, Image, Rate, Grid } from '@arco-design/web-react';
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
import { getComponentMarket } from '@/api/componentMarket';
|
|
|
|
|
|
|
|
|
|
const { Row, Col } = Grid;
|
|
|
|
|
|
|
|
|
|
const CompDetails = ({ compInfo }) => {
|
|
|
|
|
const [componentList, setComponentList] = useState([]);
|
|
|
|
|
const [currentCompInfo, setCurrentCompInfo] = useState<any>(compInfo);
|
|
|
|
|
|
|
|
|
|
// 获取组件市场数据
|
|
|
|
|
const fetchComponentData = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const params = {
|
|
|
|
|
componentClassify: compInfo.componentClassify,
|
|
|
|
|
keyword: '',
|
|
|
|
|
current: 1,
|
|
|
|
|
size: 4
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const res: any = await getComponentMarket(params);
|
|
|
|
|
|
|
|
|
|
if (res?.code === 200 && res?.data) {
|
|
|
|
|
setComponentList(res.data.list || []);
|
|
|
|
|
setComponentList([
|
|
|
|
|
{
|
|
|
|
|
'baseConfigJson': [],
|
|
|
|
|
'codeLanguage': 'Python',
|
|
|
|
|
'collaboratorId': 0,
|
|
|
|
|
'componentBaseId': '1993166956502499330',
|
|
|
|
|
'componentClassify': '设备数采与控制交互组件',
|
|
|
|
|
'componentStatus': 'DEPLOYED',
|
|
|
|
|
'componentVersion': 1,
|
|
|
|
|
'createBy': '1992851580222222338',
|
|
|
|
|
'createTime': 1764228733000,
|
|
|
|
|
'definitionJson': '{"apis":[{"apiType":"EVENT","eventApi":{"topic":"add"},"fieldIns":["a"],"fieldOuts":["v"],"id":"add","restApi":{}}],"dataIns":[{"dataType":"INTEGER","desc":"","id":"a","type":"DATA"}],"dataOuts":[{"dataType":"INTEGER","desc":"","id":"v","type":"DATA"}]}',
|
|
|
|
|
'deployType': 'Python',
|
|
|
|
|
'desc': '',
|
|
|
|
|
'dockerImageId': '',
|
|
|
|
|
'dockerImageName': '',
|
|
|
|
|
'extraSystemId': '',
|
|
|
|
|
'filesName': '',
|
|
|
|
|
'id': '1993945941293449218',
|
|
|
|
|
'identifier': 'admin_add_num_maket1',
|
|
|
|
|
'isDeleted': 0,
|
|
|
|
|
'localProjectPath': '/000000/admin_add_num_maket1/master',
|
|
|
|
|
'logoUrl': '',
|
|
|
|
|
'name': '两数之和2',
|
|
|
|
|
'operatesJson': [],
|
|
|
|
|
'permission': null,
|
|
|
|
|
'projectId': 'add_num_maket1',
|
|
|
|
|
'publicStatus': 1,
|
|
|
|
|
'publishTime': null,
|
|
|
|
|
'reviewOpinion': '',
|
|
|
|
|
'size': '106.30 KB',
|
|
|
|
|
'star': 0,
|
|
|
|
|
'status': 1,
|
|
|
|
|
'tags': [],
|
|
|
|
|
'tenantId': '000000',
|
|
|
|
|
'updateBy': '1992851580222222338',
|
|
|
|
|
'updateTime': 1764232122000,
|
|
|
|
|
'version': 'master'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'baseConfigJson': [],
|
|
|
|
|
'codeLanguage': 'Python',
|
|
|
|
|
'collaboratorId': 0,
|
|
|
|
|
'componentBaseId': '1993166956502499330',
|
|
|
|
|
'componentClassify': '设备数采与控制交互组件',
|
|
|
|
|
'componentStatus': 'DEPLOYED',
|
|
|
|
|
'componentVersion': 1,
|
|
|
|
|
'createBy': '1992851580222222338',
|
|
|
|
|
'createTime': 1764228733000,
|
|
|
|
|
'definitionJson': '{"apis":[{"apiType":"EVENT","eventApi":{"topic":"add"},"fieldIns":["a"],"fieldOuts":["v"],"id":"add","restApi":{}}],"dataIns":[{"dataType":"INTEGER","desc":"","id":"a","type":"DATA"}],"dataOuts":[{"dataType":"INTEGER","desc":"","id":"v","type":"DATA"}]}',
|
|
|
|
|
'deployType': 'Python',
|
|
|
|
|
'desc': '',
|
|
|
|
|
'dockerImageId': '',
|
|
|
|
|
'dockerImageName': '',
|
|
|
|
|
'extraSystemId': '',
|
|
|
|
|
'filesName': '',
|
|
|
|
|
'id': '1993945941293449218',
|
|
|
|
|
'identifier': 'admin_add_num_maket1',
|
|
|
|
|
'isDeleted': 0,
|
|
|
|
|
'localProjectPath': '/000000/admin_add_num_maket1/master',
|
|
|
|
|
'logoUrl': '',
|
|
|
|
|
'name': '两数之和3',
|
|
|
|
|
'operatesJson': [],
|
|
|
|
|
'permission': null,
|
|
|
|
|
'projectId': 'add_num_maket1',
|
|
|
|
|
'publicStatus': 1,
|
|
|
|
|
'publishTime': null,
|
|
|
|
|
'reviewOpinion': '',
|
|
|
|
|
'size': '106.30 KB',
|
|
|
|
|
'star': 0,
|
|
|
|
|
'status': 1,
|
|
|
|
|
'tags': [],
|
|
|
|
|
'tenantId': '000000',
|
|
|
|
|
'updateBy': '1992851580222222338',
|
|
|
|
|
'updateTime': 1764232122000,
|
|
|
|
|
'version': 'master'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'baseConfigJson': [],
|
|
|
|
|
'codeLanguage': 'Python',
|
|
|
|
|
'collaboratorId': 0,
|
|
|
|
|
'componentBaseId': '1993166956502499330',
|
|
|
|
|
'componentClassify': '设备数采与控制交互组件',
|
|
|
|
|
'componentStatus': 'DEPLOYED',
|
|
|
|
|
'componentVersion': 1,
|
|
|
|
|
'createBy': '1992851580222222338',
|
|
|
|
|
'createTime': 1764228733000,
|
|
|
|
|
'definitionJson': '{"apis":[{"apiType":"EVENT","eventApi":{"topic":"add"},"fieldIns":["a"],"fieldOuts":["v"],"id":"add","restApi":{}}],"dataIns":[{"dataType":"INTEGER","desc":"","id":"a","type":"DATA"}],"dataOuts":[{"dataType":"INTEGER","desc":"","id":"v","type":"DATA"}]}',
|
|
|
|
|
'deployType': 'Python',
|
|
|
|
|
'desc': '',
|
|
|
|
|
'dockerImageId': '',
|
|
|
|
|
'dockerImageName': '',
|
|
|
|
|
'extraSystemId': '',
|
|
|
|
|
'filesName': '',
|
|
|
|
|
'id': '1993945941293449218',
|
|
|
|
|
'identifier': 'admin_add_num_maket1',
|
|
|
|
|
'isDeleted': 0,
|
|
|
|
|
'localProjectPath': '/000000/admin_add_num_maket1/master',
|
|
|
|
|
'logoUrl': '',
|
|
|
|
|
'name': '两数之和4',
|
|
|
|
|
'operatesJson': [],
|
|
|
|
|
'permission': null,
|
|
|
|
|
'projectId': 'add_num_maket1',
|
|
|
|
|
'publicStatus': 1,
|
|
|
|
|
'publishTime': null,
|
|
|
|
|
'reviewOpinion': '',
|
|
|
|
|
'size': '106.30 KB',
|
|
|
|
|
'star': 0,
|
|
|
|
|
'status': 1,
|
|
|
|
|
'tags': [],
|
|
|
|
|
'tenantId': '000000',
|
|
|
|
|
'updateBy': '1992851580222222338',
|
|
|
|
|
'updateTime': 1764232122000,
|
|
|
|
|
'version': 'master'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'baseConfigJson': [],
|
|
|
|
|
'codeLanguage': 'Python',
|
|
|
|
|
'collaboratorId': 0,
|
|
|
|
|
'componentBaseId': '1993166956502499330',
|
|
|
|
|
'componentClassify': '设备数采与控制交互组件',
|
|
|
|
|
'componentStatus': 'DEPLOYED',
|
|
|
|
|
'componentVersion': 1,
|
|
|
|
|
'createBy': '1992851580222222338',
|
|
|
|
|
'createTime': 1764228733000,
|
|
|
|
|
'definitionJson': '{"apis":[{"apiType":"EVENT","eventApi":{"topic":"add"},"fieldIns":["a"],"fieldOuts":["v"],"id":"add","restApi":{}}],"dataIns":[{"dataType":"INTEGER","desc":"","id":"a","type":"DATA"}],"dataOuts":[{"dataType":"INTEGER","desc":"","id":"v","type":"DATA"}]}',
|
|
|
|
|
'deployType': 'Python',
|
|
|
|
|
'desc': '',
|
|
|
|
|
'dockerImageId': '',
|
|
|
|
|
'dockerImageName': '',
|
|
|
|
|
'extraSystemId': '',
|
|
|
|
|
'filesName': '',
|
|
|
|
|
'id': '1993945941293449218',
|
|
|
|
|
'identifier': 'admin_add_num_maket1',
|
|
|
|
|
'isDeleted': 0,
|
|
|
|
|
'localProjectPath': '/000000/admin_add_num_maket1/master',
|
|
|
|
|
'logoUrl': '',
|
|
|
|
|
'name': '两数之和5',
|
|
|
|
|
'operatesJson': [],
|
|
|
|
|
'permission': null,
|
|
|
|
|
'projectId': 'add_num_maket1',
|
|
|
|
|
'publicStatus': 1,
|
|
|
|
|
'publishTime': null,
|
|
|
|
|
'reviewOpinion': '',
|
|
|
|
|
'size': '106.30 KB',
|
|
|
|
|
'star': 0,
|
|
|
|
|
'status': 1,
|
|
|
|
|
'tags': [],
|
|
|
|
|
'tenantId': '000000',
|
|
|
|
|
'updateBy': '1992851580222222338',
|
|
|
|
|
'updateTime': 1764232122000,
|
|
|
|
|
'version': 'master'
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setComponentList([]);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取组件市场数据失败:', error);
|
|
|
|
|
setComponentList([]);
|
|
|
|
|
} finally {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetchComponentData();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染组件外壳
|
|
|
|
|
const renderCompHousing = () => {
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles['comp-housing']}>
|
|
|
|
|
<div className={styles['comp-housing-header']}>
|
|
|
|
|
<div className={styles['comp-housing-title']}>{currentCompInfo.name}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['comp-housing-content']}>
|
|
|
|
|
{currentCompInfo.def ? (
|
|
|
|
|
<>
|
|
|
|
|
<div className={styles['comp-housing-content-api']}>
|
|
|
|
|
<div className={styles['comp-housing-content-api-in']}>
|
|
|
|
|
{currentCompInfo.def?.apis?.map((item: any, index) => <div key={index}>{item.id}</div>)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['comp-housing-content-api-out']}>
|
|
|
|
|
<div>{currentCompInfo.def?.apiOut?.id}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Divider style={{ marginTop: 10, marginBottom: 10 }} />
|
|
|
|
|
<div className={styles['comp-housing-content-data']}>
|
|
|
|
|
<div className={styles['comp-housing-content-data-in']}>
|
|
|
|
|
{currentCompInfo.def?.dataIns?.map((item: any, index) => <div key={index}>{item.id}</div>)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['comp-housing-content-data-out']}>
|
|
|
|
|
{currentCompInfo.def?.dataOuts?.map((item: any, index) => <div key={index}>{item.id}</div>)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<div className={styles['comp-housing-content-api']}>
|
|
|
|
|
<div className={styles['comp-housing-content-api-in']}>
|
|
|
|
|
<div>contour</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['comp-housing-content-api-out']}>
|
|
|
|
|
<div>done</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Divider style={{ marginTop: 10, marginBottom: 10 }} />
|
|
|
|
|
<div className={styles['comp-housing-content-data']}>
|
|
|
|
|
<div className={styles['comp-housing-content-data-in']}>
|
|
|
|
|
{currentCompInfo.flowHousVO?.dataIns?.map((item: any, index) => <div key={index}>{item.id}</div>)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['comp-housing-content-data-out']}>
|
|
|
|
|
{currentCompInfo.flowHousVO?.dataOuts?.map((item: any, index) => <div key={index}>{item.id}</div>)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CompDetails = () => {
|
|
|
|
|
return (
|
|
|
|
|
<div className="comp-details">
|
|
|
|
|
组件详情
|
|
|
|
|
</div>
|
|
|
|
|
<>
|
|
|
|
|
<div className={styles['comp-container']}>
|
|
|
|
|
<div className={styles['comp-preview']}>
|
|
|
|
|
<h3>组件预览</h3>
|
|
|
|
|
{renderCompHousing()}
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['comp-info']}>
|
|
|
|
|
<div className={styles['header']}>
|
|
|
|
|
<Space size={40}>
|
|
|
|
|
<div className={styles['title']}>{currentCompInfo.name}</div>
|
|
|
|
|
<div
|
|
|
|
|
className={styles['update-time']}>更新时间: {dayjs(currentCompInfo.updateTime).format('YYYY-MM-DD HH:mm:ss')}</div>
|
|
|
|
|
<div className={styles['update-time']}>组件大小: {currentCompInfo.size}</div>
|
|
|
|
|
<div className={styles['update-time']}>组件版本: V_{currentCompInfo.status}</div>
|
|
|
|
|
<div className={styles['update-time']}>组件评分: {currentCompInfo.star}分</div>
|
|
|
|
|
</Space>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['extra']}>
|
|
|
|
|
<Divider style={{ borderColor: '#5484ff', marginTop: 0, marginBottom: 30 }} />
|
|
|
|
|
<Space size={30}>
|
|
|
|
|
<div className={styles['extra-font']}>{currentCompInfo.identifier}</div>
|
|
|
|
|
<div className={styles['extra-font']}>分类:{currentCompInfo.componentClassify}</div>
|
|
|
|
|
<div className={styles['extra-font']}>语言:{currentCompInfo.codeLanguage}</div>
|
|
|
|
|
</Space>
|
|
|
|
|
</div>
|
|
|
|
|
<Divider style={{ marginTop: 15, borderBottomStyle: 'dashed' }} />
|
|
|
|
|
<div className={styles['description']}>
|
|
|
|
|
{currentCompInfo.description ? currentCompInfo.description : ' - '}
|
|
|
|
|
</div>
|
|
|
|
|
<Divider style={{ borderBottomStyle: 'dashed' }} />
|
|
|
|
|
<div>这里是一坨md语法</div>
|
|
|
|
|
<Divider style={{ borderBottomStyle: 'dashed' }} />
|
|
|
|
|
<div className={styles['handel-box']}>
|
|
|
|
|
<Button type="text">更新时间: {dayjs(currentCompInfo.updateTime).format('YYYY-MM-DD HH:mm:ss')}</Button>
|
|
|
|
|
<Button type="text">复制到我的组件</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<Divider style={{ borderBottomStyle: 'dashed' }} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles['recommend']}>
|
|
|
|
|
<Typography.Title heading={5}>相关推荐</Typography.Title>
|
|
|
|
|
|
|
|
|
|
<Row style={{ marginBottom: 16 }}>
|
|
|
|
|
{componentList.map((item) => (
|
|
|
|
|
<Col
|
|
|
|
|
xs={12}
|
|
|
|
|
sm={12}
|
|
|
|
|
md={12}
|
|
|
|
|
lg={6}
|
|
|
|
|
xl={6}
|
|
|
|
|
xxl={6}
|
|
|
|
|
key={item.id}
|
|
|
|
|
style={{ marginBottom: 16 }}
|
|
|
|
|
>
|
|
|
|
|
<Card
|
|
|
|
|
style={{ cursor: 'pointer', border: '1px solid #d9d9d9' }}
|
|
|
|
|
onClick={() => setCurrentCompInfo(item)}
|
|
|
|
|
hoverable
|
|
|
|
|
>
|
|
|
|
|
{/*左侧图片*/}
|
|
|
|
|
<div className={styles['img-box']}>
|
|
|
|
|
<Image width={'100%'} height={'100%'} src={item.logoUrl} alt="暂无图片"></Image>
|
|
|
|
|
</div>
|
|
|
|
|
{/*右侧数据*/}
|
|
|
|
|
<div className={styles['info-box']}>
|
|
|
|
|
<div className={styles['info-title']}>{item.name || '未命名组件'}</div>
|
|
|
|
|
<div className={styles['info-author']}>{item.identifier || '-'}</div>
|
|
|
|
|
<div className={styles['info-score']}>
|
|
|
|
|
<div>组件评分:</div>
|
|
|
|
|
<div className={styles['info-rate']}>
|
|
|
|
|
<Rate readonly allowHalf value={item.star || 5} />
|
|
|
|
|
<Typography.Text style={{ margin: '0 5px', fontSize: 16 }}>
|
|
|
|
|
{item.star || 5}分
|
|
|
|
|
</Typography.Text>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
<div className={styles['comp-card-footer']}>
|
|
|
|
|
<div className={styles['comp-type']}>{item.componentClassify || '-'}</div>
|
|
|
|
|
<div className={styles['comp-language']}>{item.deployType || '-'}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Col>
|
|
|
|
|
))}
|
|
|
|
|
</Row>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|