|
|
|
|
@ -3,12 +3,16 @@ 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';
|
|
|
|
|
import ReactMarkdown from 'react-markdown';
|
|
|
|
|
import remarkGfm from 'remark-gfm';
|
|
|
|
|
import CopyComponentModal from './copyComponentModal';
|
|
|
|
|
|
|
|
|
|
const { Row, Col } = Grid;
|
|
|
|
|
|
|
|
|
|
const CompDetails = ({ compInfo }) => {
|
|
|
|
|
const [componentList, setComponentList] = useState([]);
|
|
|
|
|
const [currentCompInfo, setCurrentCompInfo] = useState<any>(compInfo);
|
|
|
|
|
const [copyModalVisible, setCopyModalVisible] = useState(false);
|
|
|
|
|
|
|
|
|
|
// 获取组件市场数据
|
|
|
|
|
const fetchComponentData = async () => {
|
|
|
|
|
@ -24,160 +28,6 @@ const CompDetails = ({ compInfo }) => {
|
|
|
|
|
|
|
|
|
|
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([]);
|
|
|
|
|
@ -192,6 +42,11 @@ const CompDetails = ({ compInfo }) => {
|
|
|
|
|
fetchComponentData();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
// 处理复制组件
|
|
|
|
|
const handleCopyComponent = () => {
|
|
|
|
|
setCopyModalVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染组件外壳
|
|
|
|
|
const renderCompHousing = () => {
|
|
|
|
|
@ -278,11 +133,68 @@ const CompDetails = ({ compInfo }) => {
|
|
|
|
|
{currentCompInfo.description ? currentCompInfo.description : ' - '}
|
|
|
|
|
</div>
|
|
|
|
|
<Divider style={{ borderBottomStyle: 'dashed' }} />
|
|
|
|
|
<div>这里是一坨md语法</div>
|
|
|
|
|
<div className={styles['markdown-content']}>
|
|
|
|
|
<ReactMarkdown
|
|
|
|
|
remarkPlugins={[remarkGfm]}
|
|
|
|
|
components={{
|
|
|
|
|
// 自定义组件样式
|
|
|
|
|
h1: ({ node, ...props }) => <h1
|
|
|
|
|
style={{ fontSize: '24px', fontWeight: 'bold', marginBottom: '16px' }} {...props} />,
|
|
|
|
|
h2: ({ node, ...props }) => <h2
|
|
|
|
|
style={{ fontSize: '20px', fontWeight: 'bold', marginBottom: '14px' }} {...props} />,
|
|
|
|
|
h3: ({ node, ...props }) => <h3
|
|
|
|
|
style={{ fontSize: '18px', fontWeight: 'bold', marginBottom: '12px' }} {...props} />,
|
|
|
|
|
p: ({ node, ...props }) => <p style={{ marginBottom: '12px', lineHeight: '1.6' }} {...props} />,
|
|
|
|
|
code: ({ node, inline, ...props }: any) =>
|
|
|
|
|
inline
|
|
|
|
|
? <code style={{
|
|
|
|
|
backgroundColor: '#f6f6f6',
|
|
|
|
|
padding: '2px 6px',
|
|
|
|
|
borderRadius: '3px',
|
|
|
|
|
fontSize: '0.9em'
|
|
|
|
|
}} {...props} />
|
|
|
|
|
: <code style={{
|
|
|
|
|
display: 'block',
|
|
|
|
|
backgroundColor: '#f6f6f6',
|
|
|
|
|
padding: '12px',
|
|
|
|
|
borderRadius: '4px',
|
|
|
|
|
overflow: 'auto',
|
|
|
|
|
fontSize: '0.9em'
|
|
|
|
|
}} {...props} />,
|
|
|
|
|
pre: ({ node, ...props }) => <pre style={{
|
|
|
|
|
backgroundColor: '#f6f6f6',
|
|
|
|
|
padding: '12px',
|
|
|
|
|
borderRadius: '4px',
|
|
|
|
|
overflow: 'auto'
|
|
|
|
|
}} {...props} />,
|
|
|
|
|
ul: ({ node, ...props }) => <ul style={{ marginLeft: '20px', marginBottom: '12px' }} {...props} />,
|
|
|
|
|
ol: ({ node, ...props }) => <ol style={{ marginLeft: '20px', marginBottom: '12px' }} {...props} />,
|
|
|
|
|
li: ({ node, ...props }) => <li style={{ marginBottom: '6px', lineHeight: '1.6' }} {...props} />,
|
|
|
|
|
blockquote: ({ node, ...props }) => <blockquote style={{
|
|
|
|
|
borderLeft: '4px solid #ddd',
|
|
|
|
|
paddingLeft: '16px',
|
|
|
|
|
color: '#666',
|
|
|
|
|
margin: '12px 0'
|
|
|
|
|
}} {...props} />,
|
|
|
|
|
a: ({ node, ...props }) => <a style={{ color: '#165DFF', textDecoration: 'none' }} {...props} />,
|
|
|
|
|
table: ({ node, ...props }) => <table
|
|
|
|
|
style={{ borderCollapse: 'collapse', width: '100%', marginBottom: '12px' }} {...props} />,
|
|
|
|
|
th: ({ node, ...props }) => <th style={{
|
|
|
|
|
border: '1px solid #ddd',
|
|
|
|
|
padding: '8px',
|
|
|
|
|
backgroundColor: '#f6f6f6',
|
|
|
|
|
fontWeight: 'bold'
|
|
|
|
|
}} {...props} />,
|
|
|
|
|
td: ({ node, ...props }) => <td style={{ border: '1px solid #ddd', padding: '8px' }} {...props} />
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{currentCompInfo.readme || currentCompInfo.desc || '暂无详细说明'}
|
|
|
|
|
</ReactMarkdown>
|
|
|
|
|
</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>
|
|
|
|
|
<Button type="text" onClick={handleCopyComponent}>复制到我的组件</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<Divider style={{ borderBottomStyle: 'dashed' }} />
|
|
|
|
|
</div>
|
|
|
|
|
@ -328,12 +240,22 @@ const CompDetails = ({ compInfo }) => {
|
|
|
|
|
</Card>
|
|
|
|
|
<div className={styles['comp-card-footer']}>
|
|
|
|
|
<div className={styles['comp-type']}>{item.componentClassify || '-'}</div>
|
|
|
|
|
<div className={styles['comp-language']}>{item.deployType || '-'}</div>
|
|
|
|
|
<div className={styles['comp-language']}>{item.codeLanguage || '-'}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Col>
|
|
|
|
|
))}
|
|
|
|
|
</Row>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 复制组件弹窗 */}
|
|
|
|
|
<CopyComponentModal
|
|
|
|
|
visible={copyModalVisible}
|
|
|
|
|
componentInfo={currentCompInfo}
|
|
|
|
|
onCancel={() => setCopyModalVisible(false)}
|
|
|
|
|
onSuccess={() => {
|
|
|
|
|
setCopyModalVisible(false);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|