Download apps/web-naive/src/api/core/source.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 3.23 kB
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-naive/src/api/core/source.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/apps/web-naive/src/api/core/source.ts
-
curl -L -o source.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-naive/src/api/core/source.ts
3.23 kB
| import type { PaginatedList } from './types'; | |
| import { requestClient } from '#/api/request'; | |
| // ======================== 类型定义 ======================== | |
| export interface SourceListParams { | |
| page?: number; | |
| page_size?: number; | |
| } | |
| export interface SourceHealth { | |
| id: number; | |
| check_type: string; | |
| is_success: boolean; | |
| response_time_ms: null | number; | |
| error_message: null | string; | |
| checked_at: null | string; | |
| } | |
| export interface SourceItem { | |
| id: number; | |
| name: string; | |
| code: string; | |
| base_url: string; | |
| site_url: null | string; | |
| play_from_m3u8: null | string; | |
| play_from_yun: null | string; | |
| parse_url: null | string; | |
| is_active: boolean; | |
| sync_interval: number; | |
| last_sync_at: null | string; | |
| last_sync_status: null | string; | |
| last_sync_count: number; | |
| total_count: number; | |
| sort_order: number; | |
| remark: null | string; | |
| health: null | SourceHealth; | |
| } | |
| export interface SourceCreateParams { | |
| name: string; | |
| /** 字母/数字/下划线/横线,唯一标识 */ | |
| code: string; | |
| base_url: string; | |
| site_url?: string; | |
| play_from_m3u8?: string; | |
| play_from_yun?: string; | |
| parse_url?: string; | |
| /** 同步间隔(分钟),1~10080 */ | |
| sync_interval?: number; | |
| sort_order?: number; | |
| remark?: string; | |
| } | |
| export interface SourceUpdateParams { | |
| name?: string; | |
| base_url?: string; | |
| site_url?: string; | |
| play_from_m3u8?: string; | |
| play_from_yun?: string; | |
| parse_url?: string; | |
| sync_interval?: number; | |
| sort_order?: number; | |
| remark?: string; | |
| } | |
| // ======================== API ======================== | |
| /** 资源站列表 GET /admin/source */ | |
| export function getSourceListApi(params?: SourceListParams) { | |
| return requestClient.get<PaginatedList<SourceItem>>('/admin/source', { | |
| params, | |
| }); | |
| } | |
| /** 资源站详情 GET /admin/source/:id */ | |
| export function getSourceDetailApi(sourceId: number) { | |
| return requestClient.get<SourceItem>(`/admin/source/${sourceId}`); | |
| } | |
| /** 新建资源站 POST /admin/source */ | |
| export function createSourceApi(data: SourceCreateParams) { | |
| return requestClient.post<{ id: number }>('/admin/source', data); | |
| } | |
| /** 更新资源站 PUT /admin/source/:id */ | |
| export function updateSourceApi(sourceId: number, data: SourceUpdateParams) { | |
| return requestClient.put(`/admin/source/${sourceId}`, data); | |
| } | |
| /** 删除资源站 DELETE /admin/source/:id */ | |
| export function deleteSourceApi(sourceId: number) { | |
| return requestClient.delete(`/admin/source/${sourceId}`); | |
| } | |
| /** 连通性测试 POST /admin/source/:id/test */ | |
| export function testSourceApi(sourceId: number) { | |
| return requestClient.post(`/admin/source/${sourceId}/test`); | |
| } | |
| /** 启用/禁用切换 PUT /admin/source/:id/enable */ | |
| export function toggleSourceEnableApi(sourceId: number) { | |
| return requestClient.put<{ is_active: boolean }>( | |
| `/admin/source/${sourceId}/enable`, | |
| ); | |
| } | |
| /** 手动触发健康检查 POST /admin/source/health-check */ | |
| export function triggerHealthCheckApi() { | |
| return requestClient.post('/admin/source/health-check'); | |
| } | |
| /** 健康检查历史 GET /admin/source/:id/health-history */ | |
| export function getHealthHistoryApi(sourceId: number, limit = 20) { | |
| return requestClient.get(`/admin/source/${sourceId}/health-history`, { | |
| params: { limit }, | |
| }); | |
| } | |