feat: 支持任务监控系统

This commit is contained in:
richarjiang
2026-07-15 18:50:12 +08:00
parent f8c8c688a1
commit 4b465843a8
16 changed files with 1389 additions and 29 deletions

View File

@@ -101,6 +101,36 @@ export interface PendingBooking {
| 'release-confirmed'
}
export interface MonitorTask {
id: string
courtId: string
targetDate?: string
startTime: string
endTime: string
enabled: boolean
createdAt: string
lastCheckedAt?: string
lastError?: string
availableCount: number
}
export interface CreateMonitorTaskInput {
courtId: string
targetDate?: string
startTime: string
endTime: string
}
export interface MonitorAlert {
taskId: string
courtId: string
targetDate: string
startTime: string
endTime: string
slotLabels: string[]
occurredAt: string
}
export interface TennisBookApi {
listCourts(): Promise<CourtSummary[]>
getAvailability(query: AvailabilityQuery): Promise<AvailabilityDay>
@@ -109,6 +139,12 @@ export interface TennisBookApi {
createBooking(input: CreateBookingInput): Promise<PendingBooking>
cancelBooking(input: CancelBookingInput): Promise<void>
getPendingBooking(courtId: string): Promise<PendingBooking | null>
listMonitorTasks(): Promise<MonitorTask[]>
createMonitorTask(input: CreateMonitorTaskInput): Promise<MonitorTask>
setMonitorTaskEnabled(taskId: string, enabled: boolean): Promise<MonitorTask>
deleteMonitorTask(taskId: string): Promise<void>
takeMonitorAlerts(): Promise<MonitorAlert[]>
onMonitorAlert(listener: () => void): () => void
}
export const IPC_CHANNELS = {
@@ -118,5 +154,11 @@ export const IPC_CHANNELS = {
updateCourtSettings: 'court-settings:update',
createBooking: 'bookings:create',
cancelBooking: 'bookings:cancel',
getPendingBooking: 'bookings:pending'
getPendingBooking: 'bookings:pending',
listMonitorTasks: 'monitors:list',
createMonitorTask: 'monitors:create',
setMonitorTaskEnabled: 'monitors:set-enabled',
deleteMonitorTask: 'monitors:delete',
takeMonitorAlerts: 'monitors:take-alerts',
monitorAlert: 'monitors:alert'
} as const