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:
DEV_DSW
2026-04-16 16:59:49 +08:00
parent b1f589a674
commit 210e8eb363
24 changed files with 788 additions and 237 deletions

View File

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