From c096108124467ed73732611a3743f46b6ef4d5f9 Mon Sep 17 00:00:00 2001 From: ZLY Date: Thu, 20 Nov 2025 16:11:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(componentDeployment):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=AE=9E=E4=BE=8B=E5=90=AF=E5=81=9C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../componentDeployment/listNode.tsx | 110 +++++++++++++----- 1 file changed, 84 insertions(+), 26 deletions(-) diff --git a/src/pages/componentDevelopment/componentDeployment/listNode.tsx b/src/pages/componentDevelopment/componentDeployment/listNode.tsx index 1a74e5a..0ebb9cb 100644 --- a/src/pages/componentDevelopment/componentDeployment/listNode.tsx +++ b/src/pages/componentDevelopment/componentDeployment/listNode.tsx @@ -1,8 +1,8 @@ import React, { useEffect, useState } from 'react'; -import { Button, Space, Table, TableColumnProps, Tag } from '@arco-design/web-react'; +import { Button, Space, Table, TableColumnProps, Tag, Message } from '@arco-design/web-react'; import styles from '@/pages/componentDevelopment/componentDeployment/style/collapseList.module.less'; -import { getInstanceList } from '@/api/componentInstance'; -import { runStatusDic, runTypeConstant, runTypeDic } from '@/const/isdp/componentDeploy'; +import { getInstanceList, startInstance, stopInstance } from '@/api/componentInstance'; +import { runStatusConstant, runStatusDic, runTypeConstant, runTypeDic } from '@/const/isdp/componentDeploy'; import dayjs from 'dayjs'; interface ListNodeProps { @@ -39,6 +39,40 @@ const ListNode: React.FC = ({ componentData }) => { fetchInstanceList(); }, [componentData]); + // 处理启动实例 + const handleStart = async (record) => { + try { + const res: any = await startInstance(record.id); + if (res.code === 200) { + Message.success('启动成功'); + fetchInstanceList(); // 刷新列表 + } + else { + Message.error(res.msg || '启动失败'); + } + } catch (error) { + console.error('启动实例失败:', error); + Message.error('启动失败'); + } + }; + + // 处理停止实例 + const handleStop = async (record) => { + try { + const res: any = await stopInstance(record.id); + if (res.code === 200) { + Message.success('停止成功'); + fetchInstanceList(); // 刷新列表 + } + else { + Message.error(res.msg || '停止失败'); + } + } catch (error) { + console.error('停止实例失败:', error); + Message.error('停止失败'); + } + }; + const columns: TableColumnProps[] = [ { title: '#', @@ -86,29 +120,53 @@ const ListNode: React.FC = ({ componentData }) => { title: '操作', dataIndex: '', align: 'center', - render: (col, record, index) => ( -
- - - - - - - -
- ) + render: (col, record, index) => { + // 根据运行状态判断显示启动还是停止按钮 + const isRunning = record.runStatus === runStatusConstant.RUN || record.runStatus === runStatusConstant.HEALTHY; + + return ( +
+ + + + + {isRunning ? ( + + ) : ( + + )} + + +
+ ); + } } ];