import React from 'react'; import { Button, Message } from '@arco-design/web-react'; import { IconSave, IconPlayArrow, IconCodeSquare, IconPause, IconSync, IconUndo, IconRedo } from '@arco-design/web-react/icon'; import { updateLogBarStatus } from '@/store/ideContainer'; import { useSelector, useDispatch } from 'react-redux'; const ButtonGroup = Button.Group; interface ActionBarProps { useDefault: boolean; onSave?: () => void; onUndo?: () => void; onRedo?: () => void; canUndo?: boolean; canRedo?: boolean; onRun?: (isRunning: boolean) => void; onPause?: (isPaused: boolean) => void; onReRun?: () => void; isRunning?: boolean; } const ActionBar: React.FC = ({ useDefault, onSave, onUndo, onRedo, canUndo = false, canRedo = false, onRun, onPause, onReRun, isRunning = false }) => { const { logBarStatus, appRuntimeData, currentAppData } = useSelector((state: any) => state.ideContainer); const dispatch = useDispatch(); // 辅助函数:获取当前应用/子流程的唯一标识符 const getCurrentAppKey = () => { if (!currentAppData) return null; // 如果是子流程(key包含'sub'),使用key作为标识符 if (currentAppData.key && currentAppData.key.includes('sub')) { return currentAppData.key; } // 否则使用id return currentAppData.id; }; // 获取当前应用的运行状态 const currentAppKey = getCurrentAppKey(); const currentAppIsRunning = currentAppKey && appRuntimeData[currentAppKey] ? appRuntimeData[currentAppKey].isRunning : false; // 获取当前应用的暂停状态(如果有的话) const currentAppIsPaused = currentAppKey && appRuntimeData[currentAppKey] ? appRuntimeData[currentAppKey].isPaused : false; const changeLogBarStatus = () => { dispatch(updateLogBarStatus(!logBarStatus)); }; const handleRun = () => { onRun?.(!currentAppIsRunning); }; // 暂停/恢复应用 const handlePause = () => { onPause?.(currentAppIsPaused); }; // 重跑应用 const handleReRun = () => { onReRun?.(); }; return (
{useDefault && ( <> {/*}*/} {/* onClick={() => handleReRun()}*/} {/* style={{ padding: '0 8px', backgroundColor: '#fff' }}*/} {/* disabled={!currentAppIsRunning}*/} {/*>*/} {/* 重跑*/} {/**/} {/**/} {/* }*/} {/* onClick={onUndo}*/} {/* disabled={!canUndo}*/} {/* status="danger"*/} {/* style={{ padding: '0 8px', backgroundColor: '#fff' }}*/} {/* >*/} {/* 撤销*/} {/* */} {/* }*/} {/* onClick={onRedo}*/} {/* disabled={!canRedo}*/} {/* style={{ padding: '0 8px', backgroundColor: '#fff' }}*/} {/* >*/} {/* 重做*/} {/* */} {/**/} )}
); }; export default ActionBar;