diff --git a/src/hooks/useFlowCallbacks.ts b/src/hooks/useFlowCallbacks.ts index 32f2eb8..f91c3e5 100644 --- a/src/hooks/useFlowCallbacks.ts +++ b/src/hooks/useFlowCallbacks.ts @@ -1396,6 +1396,12 @@ export const useFlowCallbacks = ( if (runId) { await stopApp(runId); } + else { + // 特殊停止逻辑,持久化运行的应用使用这里的入参 + await stopApp(currentAppData.instanceId); + // 特殊停止完成后触发事件,通知刷新应用列表 + document.dispatchEvent(new CustomEvent('refreshAppList')); + } // 更新运行ID dispatch(updateRuntimeId('')); diff --git a/src/pages/ideContainer/index.tsx b/src/pages/ideContainer/index.tsx index 1297edd..0860237 100644 --- a/src/pages/ideContainer/index.tsx +++ b/src/pages/ideContainer/index.tsx @@ -256,6 +256,20 @@ function IDEContainer() { } }, [urlParams.identity]); + // 监听刷新应用列表事件(特殊停止后触发) + useEffect(() => { + const handleRefreshAppList = () => { + if (urlParams.id) { + getAppList(); + } + }; + + document.addEventListener('refreshAppList', handleRefreshAppList); + return () => { + document.removeEventListener('refreshAppList', handleRefreshAppList); + }; + }, [urlParams.id]); + // 页面加载后默认选择第一个菜单项 useEffect(() => { if (urlParams.identity && menuData[urlParams.identity]?.length > 0 && !selected.key) { diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx index 58c33f6..c6372c7 100644 --- a/src/pages/ideContainer/sideBar.tsx +++ b/src/pages/ideContainer/sideBar.tsx @@ -23,7 +23,8 @@ import { IconEyeInvisible, IconExpand, IconShrink, - IconLeft + IconLeft, + IconLoading } from '@arco-design/web-react/icon'; import { menuData1, menuData2 } from './config/menuData'; import { Selected } from '@/pages/ideContainer/types'; @@ -34,7 +35,8 @@ import { updateCanvasDataMap, updateCurrentAppData, updateEventListOld, - updateEventNodeList + updateEventNodeList, + updateIsRunning } from '@/store/ideContainer'; import { addApp, getProjectEnv, editApp, deleteApp } from '@/api/apps'; import _ from 'lodash'; @@ -728,21 +730,33 @@ const SideBar: React.FC = ({ ); return ( - - + {node?.dataRef?.scheduled === 1 &&
{ - e.stopPropagation(); - }} - /> - + > + +
} + + { + e.stopPropagation(); + }} + /> + + ); }; @@ -869,6 +883,10 @@ const SideBar: React.FC = ({ if (selected?.parentKey === 'appList') { await getProjectEnvData(originalData); + // 根据应用的 scheduled 状态更新画布的运行状态 + // scheduled === 1 表示应用正在运行中 + dispatch(updateIsRunning(originalData?.scheduled === 1)); + // 调用外部传入的菜单选择处理函数 originalData.key && onMenuSelect?.({ ...originalData } as Selected); }