schedule.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // api/schedule.ts:定时任务(增删改查 / 启停 / 立即执行 / 执行记录)。
  2. import { defHttp } from '/@/utils/http/axios/index';
  3. enum Api {
  4. schedules = '/ventAI/api/schedules',
  5. }
  6. /**
  7. * 定时任务接口
  8. */
  9. export const createSchedule = (data: {
  10. name: string;
  11. schedule?: { freq: string; hour?: number; minute?: number; day_of_week?: number; day_of_month?: number };
  12. cron_expr?: string;
  13. prompt: string;
  14. notify_webhook?: string;
  15. }) => defHttp.post({ url: Api.schedules, data }, { isTransformResponse: false });
  16. export const getScheduleList = (include_disabled = true) =>
  17. defHttp.get({ url: Api.schedules, params: { include_disabled } }, { joinParamsToUrl: true, isTransformResponse: false });
  18. export const getScheduleDetail = (task_id: number) => defHttp.get({ url: `${Api.schedules}/${task_id}` }, { isTransformResponse: false });
  19. export const updateSchedule = (
  20. task_id: number,
  21. data: { name?: string; schedule?: Record<string, any>; cron_expr?: string; prompt?: string; notify_webhook?: string }
  22. ) => defHttp.put({ url: `${Api.schedules}/${task_id}`, data }, { isTransformResponse: false });
  23. export const pauseSchedule = (task_id: number) => defHttp.post({ url: `${Api.schedules}/${task_id}/pause` }, { isTransformResponse: false });
  24. export const resumeSchedule = (task_id: number) => defHttp.post({ url: `${Api.schedules}/${task_id}/resume` }, { isTransformResponse: false });
  25. export const deleteSchedule = (id: number) => defHttp.delete({ url: `${Api.schedules}/${id}` }, { isTransformResponse: false });
  26. export const getScheduleRuns = (task_id: number, limit = 50) =>
  27. defHttp.get({ url: `${Api.schedules}/${task_id}/runs`, params: { limit } }, { joinParamsToUrl: true, isTransformResponse: false });
  28. export const runScheduleNow = (task_id: number) => defHttp.post({ url: `${Api.schedules}/${task_id}/run` }, { isTransformResponse: false });