import React from 'react'; import { Divider, SxProps } from '@mui/material'; import Box from '@mui/material/Box'; import MoreHorizIcon from '@mui/icons-material/MoreHoriz'; import UnfoldLessIcon from '@mui/icons-material/UnfoldLess'; import { IAgentAction, globalStorage } from '@/storage'; import { getActionTypeDisplayText } from '@/storage/plan/action'; // 导入映射函数 export interface IDutyItem { action: IAgentAction; style?: SxProps; } export default React.memo(({ action, style = {} }) => { const [expand, setExpand] = React.useState(false); const _style = { ...action.style, ...style, }; React.useEffect(() => { globalStorage.renderLines({ repeat: 3, delay: 0, interval: 20, }); }, [expand]); if (!expand) { return ( {getActionTypeDisplayText(action.type)} setExpand(true)} sx={{ cursor: 'pointer', userSelect: 'none', height: '14px', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#0002', borderRadius: '8px', marginLeft: '8px', padding: '0 4px', '&:hover': { background: '#0003', }, }} > ); } return ( {getActionTypeDisplayText(action.type)} {action.description} setExpand(false)} sx={{ position: 'absolute', right: '6px', bottom: '6px', cursor: 'pointer', userSelect: 'none', height: '14px', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#0002', borderRadius: '12px', marginLeft: '4px', padding: '0 4px', '&:hover': { background: '#0003', }, }} > ); });