feat: add task management and progress reporting
- Implemented task and subtask structures with progress tracking. - Added reporting functionality to log progress at various stages in hotel room status management scripts. - Created a task store to manage tasks and their states, including persistence to local storage. - Updated UI components to display task lists and handle task actions (retry, remove). - Removed deprecated TaskCard and TaskList components, replacing them with a new structure for better maintainability. - Enhanced script execution service to emit progress events for UI updates.
This commit is contained in:
@@ -55,6 +55,23 @@ const api: WindowApi = {
|
||||
// 执行脚本
|
||||
executeScript: (params: any) => ipcRenderer.invoke(IPC_EVENTS.EXECUTE_SCRIPT, params),
|
||||
|
||||
// 任务事件
|
||||
onTaskProgress: (cb: (payload: any) => void) => {
|
||||
const subscription = (_event: any, payload: any) => cb(payload);
|
||||
ipcRenderer.on(IPC_EVENTS.TASK_PROGRESS, subscription);
|
||||
return () => ipcRenderer.removeListener(IPC_EVENTS.TASK_PROGRESS, subscription);
|
||||
},
|
||||
onTaskStarted: (cb: (payload: any) => void) => {
|
||||
const subscription = (_event: any, payload: any) => cb(payload);
|
||||
ipcRenderer.on(IPC_EVENTS.TASK_STARTED, subscription);
|
||||
return () => ipcRenderer.removeListener(IPC_EVENTS.TASK_STARTED, subscription);
|
||||
},
|
||||
onTaskCompleted: (cb: (payload: any) => void) => {
|
||||
const subscription = (_event: any, payload: any) => cb(payload);
|
||||
ipcRenderer.on(IPC_EVENTS.TASK_COMPLETED, subscription);
|
||||
return () => ipcRenderer.removeListener(IPC_EVENTS.TASK_COMPLETED, subscription);
|
||||
},
|
||||
|
||||
// 打开渠道
|
||||
openChannel: (channels: any) => ipcRenderer.invoke(IPC_EVENTS.OPEN_CHANNEL, channels),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user