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'; import { getCurrentAppKey } from '@/features/workflow/runtime/flowRuntime'; 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 currentAppKey = getCurrentAppKey(currentAppData); 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;