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

@@ -52,6 +52,11 @@ export enum IPC_EVENTS {
// 执行脚本
EXECUTE_SCRIPT = 'execute-script',
// 任务事件
TASK_PROGRESS = 'task:progress',
TASK_STARTED = 'task:started',
TASK_COMPLETED = 'task:completed',
// 打开渠道
OPEN_CHANNEL = 'open-channel',
@@ -104,6 +109,7 @@ export enum CONFIG_KEYS {
AUTO_DOWNLOAD_UPDATE = 'autoDownloadUpdate',
SELECTED_CHANNELS = 'selectedChannels',
IMAGE_CACHE = 'imageCache',
TASK_LIST = 'taskList',
}
export enum MENU_IDS {

40
src/lib/task-types.ts Normal file
View File

@@ -0,0 +1,40 @@
export type SubTaskStatus = 'pending' | 'running' | 'success' | 'failed';
export interface SubTask {
id: string;
taskId: string;
scriptId: string;
name: string;
status: SubTaskStatus;
progress: number;
message: string;
stdoutTail: string;
stderrTail: string;
error?: string;
startedAt: string;
completedAt?: string;
}
export type TaskStatus = 'pending' | 'running' | 'success' | 'partial_failed' | 'failed';
export interface Task {
id: string;
title: string;
operation: 'open' | 'close';
roomType: string;
dateRange: [string, string];
status: TaskStatus;
subTasks: SubTask[];
roomList: any[];
createdAt: string;
updatedAt: string;
}
export interface TaskProgressPayload {
taskId: string;
subTaskId: string;
progress?: number;
message?: string;
stdoutTail?: string;
stderrTail?: string;
}