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:
@@ -41,6 +41,9 @@ var IPC_EVENTS = /* @__PURE__ */ ((IPC_EVENTS2) => {
|
||||
IPC_EVENTS2["IS_DARK_THEME"] = "is-dark-theme";
|
||||
IPC_EVENTS2["THEME_MODE_UPDATED"] = "theme-mode-updated";
|
||||
IPC_EVENTS2["EXECUTE_SCRIPT"] = "execute-script";
|
||||
IPC_EVENTS2["TASK_PROGRESS"] = "task:progress";
|
||||
IPC_EVENTS2["TASK_STARTED"] = "task:started";
|
||||
IPC_EVENTS2["TASK_COMPLETED"] = "task:completed";
|
||||
IPC_EVENTS2["OPEN_CHANNEL"] = "open-channel";
|
||||
IPC_EVENTS2["SCRIPT_LIST"] = "script:list";
|
||||
IPC_EVENTS2["SCRIPT_GET"] = "script:get";
|
||||
@@ -100,6 +103,22 @@ const api = {
|
||||
},
|
||||
// 执行脚本
|
||||
executeScript: (params) => electron.ipcRenderer.invoke(IPC_EVENTS.EXECUTE_SCRIPT, params),
|
||||
// 任务事件
|
||||
onTaskProgress: (cb) => {
|
||||
const subscription = (_event, payload) => cb(payload);
|
||||
electron.ipcRenderer.on(IPC_EVENTS.TASK_PROGRESS, subscription);
|
||||
return () => electron.ipcRenderer.removeListener(IPC_EVENTS.TASK_PROGRESS, subscription);
|
||||
},
|
||||
onTaskStarted: (cb) => {
|
||||
const subscription = (_event, payload) => cb(payload);
|
||||
electron.ipcRenderer.on(IPC_EVENTS.TASK_STARTED, subscription);
|
||||
return () => electron.ipcRenderer.removeListener(IPC_EVENTS.TASK_STARTED, subscription);
|
||||
},
|
||||
onTaskCompleted: (cb) => {
|
||||
const subscription = (_event, payload) => cb(payload);
|
||||
electron.ipcRenderer.on(IPC_EVENTS.TASK_COMPLETED, subscription);
|
||||
return () => electron.ipcRenderer.removeListener(IPC_EVENTS.TASK_COMPLETED, subscription);
|
||||
},
|
||||
// 打开渠道
|
||||
openChannel: (channels) => electron.ipcRenderer.invoke(IPC_EVENTS.OPEN_CHANNEL, channels),
|
||||
// 脚本管理
|
||||
|
||||
Reference in New Issue
Block a user