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

@@ -8,6 +8,8 @@ export class executeScriptService extends EventEmitter {
async executeScript(
scriptPath: string,
options: Record<string, any>,
taskId?: string,
subTaskId?: string,
): Promise<{ success: boolean; exitCode: number | null; stdoutTail: string; stderrTail: string; error?: string }> {
const MAX_TAIL = 32 * 1024;
@@ -48,6 +50,20 @@ export class executeScriptService extends EventEmitter {
const text = data.toString();
stdoutTail = appendTail(stdoutTail, text);
log.info(`stdout: ${text}`);
if (text.includes('__ZN_PROGRESS__')) {
try {
const jsonStr = text.split('__ZN_PROGRESS__')[1]?.trim();
if (jsonStr) {
const parsed = JSON.parse(jsonStr);
this.emit('progress', { taskId, subTaskId, ...parsed });
}
} catch {
// ignore invalid JSON
}
}
this.emit('stdout', { taskId, subTaskId, text });
});
}
@@ -56,6 +72,7 @@ export class executeScriptService extends EventEmitter {
const text = data.toString();
stderrTail = appendTail(stderrTail, text);
log.info(`stderr: ${text}`);
this.emit('stderr', { taskId, subTaskId, text });
});
}