feat(ide): 添加应用列表刷新监听和运行状态显示功能

master
钟良源 1 month ago
parent e405fce1ff
commit 3df2e62c0a

@ -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(''));

@ -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) {

@ -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<SideBarProps> = ({
);
return (
<Dropdown droplist={dropList} trigger="click">
<IconMore
<>
{node?.dataRef?.scheduled === 1 && <div
style={{
position: 'absolute',
right: 8,
fontSize: 20,
fontWeight: 700,
top: 10,
right: 35,
top: 8,
color: '#000000'
}}
onClick={(e) => {
e.stopPropagation();
}}
/>
</Dropdown>
>
<IconLoading />
</div>}
<Dropdown droplist={dropList} trigger="click">
<IconMore
style={{
position: 'absolute',
right: 8,
fontSize: 20,
fontWeight: 700,
top: 10,
color: '#000000'
}}
onClick={(e) => {
e.stopPropagation();
}}
/>
</Dropdown>
</>
);
};
@ -869,6 +883,10 @@ const SideBar: React.FC<SideBarProps> = ({
if (selected?.parentKey === 'appList') {
await getProjectEnvData(originalData);
// 根据应用的 scheduled 状态更新画布的运行状态
// scheduled === 1 表示应用正在运行中
dispatch(updateIsRunning(originalData?.scheduled === 1));
// 调用外部传入的菜单选择处理函数
originalData.key && onMenuSelect?.({ ...originalData } as Selected);
}

Loading…
Cancel
Save