self_check.ts 778 B

1234567891011121314151617181920212223242526272829303132333435
  1. import type { Container } from '@/language'
  2. import type { CosyError } from '@/lib/http'
  3. import { http } from '@uozi-admin/request'
  4. import ws from '@/lib/websocket'
  5. export const ReportStatus = {
  6. Success: 'success',
  7. Warning: 'warning',
  8. Error: 'error',
  9. } as const
  10. export type ReportStatusType = typeof ReportStatus[keyof typeof ReportStatus]
  11. export interface TaskReport {
  12. key: string
  13. name: Container
  14. description: Container
  15. fixable?: boolean
  16. err?: CosyError
  17. status: ReportStatusType
  18. }
  19. const selfCheck = {
  20. run(): Promise<TaskReport[]> {
  21. return http.get('/self_check')
  22. },
  23. fix(taskName: string) {
  24. return http.post(`/self_check/${taskName}/fix`)
  25. },
  26. websocket() {
  27. return ws('/api/self_check/websocket', false)
  28. },
  29. }
  30. export default selfCheck