mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 19:36:36 +08:00
添加strm生成
添加strm
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
import { api } from './client'
|
||||
import type {
|
||||
StrmAccount,
|
||||
StrmAccountInput,
|
||||
StrmQueueSnapshot,
|
||||
StrmSettingsMap,
|
||||
StrmSyncPath,
|
||||
StrmSyncPathInput,
|
||||
StrmSyncRecord,
|
||||
} from '../types/strm'
|
||||
|
||||
export interface StrmRemoteEntry {
|
||||
id: string
|
||||
name: string
|
||||
is_dir: boolean
|
||||
size: number
|
||||
pick_code?: string
|
||||
}
|
||||
|
||||
export interface Strm115Source {
|
||||
auth_source_type: 'built_in_appid' | 'built_in_relay' | 'third_party_service' | 'custom_appid'
|
||||
auth_provider: string
|
||||
app_id: string
|
||||
app_name: string
|
||||
display_name: string
|
||||
auth_server?: string
|
||||
requires_encryption_key?: boolean
|
||||
deprecated?: boolean
|
||||
}
|
||||
|
||||
export interface StrmLocalDirList {
|
||||
roots: boolean
|
||||
parent?: string
|
||||
current?: string
|
||||
children: { name: string; path: string }[]
|
||||
}
|
||||
|
||||
export interface Strm115Sources {
|
||||
built_in: Strm115Source[]
|
||||
relay: Strm115Source[]
|
||||
third_party: Strm115Source[]
|
||||
}
|
||||
|
||||
export interface Strm115OAuthStartResult {
|
||||
session_id: string
|
||||
mode: 'qrcode' | 'url'
|
||||
auth_url?: string
|
||||
state?: string
|
||||
expires_in?: number
|
||||
qrcode?: {
|
||||
uid: string
|
||||
time: number
|
||||
sign: string
|
||||
qrcode: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface Strm115OAuthStatus {
|
||||
status: 'waiting' | 'scanned' | 'confirmed' | 'expired'
|
||||
tip: string
|
||||
}
|
||||
|
||||
export const strmAPI = {
|
||||
// ── 网盘账号 ────────────────────────────────────────────
|
||||
listAccounts: () => api.get<StrmAccount[]>('/admin/strm/accounts').then((r) => r.data),
|
||||
|
||||
createAccount: (payload: StrmAccountInput) =>
|
||||
api.post<StrmAccount>('/admin/strm/accounts', payload).then((r) => r.data),
|
||||
|
||||
updateAccount: (id: string, payload: StrmAccountInput) =>
|
||||
api.put<StrmAccount>(`/admin/strm/accounts/${id}`, payload).then((r) => r.data),
|
||||
|
||||
deleteAccount: (id: string) => api.delete(`/admin/strm/accounts/${id}`).then((r) => r.data),
|
||||
|
||||
testAccount: (id: string) =>
|
||||
api.post<StrmAccount>(`/admin/strm/accounts/${id}/test`).then((r) => r.data),
|
||||
|
||||
listRemoteDir: (accountId: string, dir: string) =>
|
||||
api
|
||||
.get<StrmRemoteEntry[]>(`/admin/strm/accounts/${accountId}/list`, { params: { dir } })
|
||||
.then((r) => r.data),
|
||||
|
||||
list115Sources: () =>
|
||||
api.get<Strm115Sources>('/admin/strm/115/sources').then((r) => r.data),
|
||||
|
||||
start115OAuth: (accountId: string, payload: { auth_source: string; app_id?: string; provider?: string; redirect_url?: string }) =>
|
||||
api.post<Strm115OAuthStartResult>(`/admin/strm/accounts/${accountId}/oauth/start`, payload).then((r) => r.data),
|
||||
|
||||
poll115OAuth: (accountId: string, sessionId: string) =>
|
||||
api.post<Strm115OAuthStatus>(`/admin/strm/accounts/${accountId}/oauth/poll`, { session_id: sessionId }).then((r) => r.data),
|
||||
|
||||
// ── 全局设置 ────────────────────────────────────────────
|
||||
getSettings: () =>
|
||||
api.get<StrmSettingsMap>('/admin/strm/settings').then((r) => r.data),
|
||||
|
||||
updateSettings: (payload: Partial<StrmSettingsMap>) =>
|
||||
api.put('/admin/strm/settings', payload).then((r) => r.data),
|
||||
|
||||
// ── 同步目录 ────────────────────────────────────────────
|
||||
listPaths: () => api.get<StrmSyncPath[]>('/admin/strm/paths').then((r) => r.data),
|
||||
|
||||
createPath: (payload: StrmSyncPathInput) =>
|
||||
api.post<StrmSyncPath>('/admin/strm/paths', payload).then((r) => r.data),
|
||||
|
||||
updatePath: (id: string, payload: StrmSyncPathInput) =>
|
||||
api.put<StrmSyncPath>(`/admin/strm/paths/${id}`, payload).then((r) => r.data),
|
||||
|
||||
deletePath: (id: string) => api.delete(`/admin/strm/paths/${id}`).then((r) => r.data),
|
||||
|
||||
startSync: (id: string) => api.post(`/admin/strm/paths/${id}/sync`).then((r) => r.data),
|
||||
|
||||
cancelSync: (id: string) => api.post(`/admin/strm/paths/${id}/cancel`).then((r) => r.data),
|
||||
|
||||
listRecords: (pathId?: string) =>
|
||||
api
|
||||
.get<StrmSyncRecord[]>('/admin/strm/records', { params: pathId ? { path_id: pathId } : {} })
|
||||
.then((r) => r.data),
|
||||
|
||||
// ── 本地目录浏览(同步目录选择器) ────────────────────────
|
||||
listLocalDirs: (path?: string) =>
|
||||
api
|
||||
.get<StrmLocalDirList>('/admin/strm/local-dirs', { params: path ? { path } : {} })
|
||||
.then((r) => r.data),
|
||||
|
||||
// ── 下载/上传队列 ───────────────────────────────────────
|
||||
downloads: (status?: string, page = 1, pageSize = 50) =>
|
||||
api
|
||||
.get<StrmQueueSnapshot>('/admin/strm/downloads', {
|
||||
params: { status, page, page_size: pageSize },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
cancelDownload: (id: string) =>
|
||||
api.post(`/admin/strm/downloads/${id}/cancel`).then((r) => r.data),
|
||||
|
||||
retryDownload: (id: string) =>
|
||||
api.post(`/admin/strm/downloads/${id}/retry`).then((r) => r.data),
|
||||
|
||||
clearDoneDownloads: () =>
|
||||
api.post<{ deleted: number }>('/admin/strm/downloads/clear-done').then((r) => r.data),
|
||||
|
||||
clearFinishedDownloads: () =>
|
||||
api.post<{ deleted: number }>('/admin/strm/downloads/clear-finished').then((r) => r.data),
|
||||
|
||||
retryFailedDownloads: () =>
|
||||
api.post<{ retried: number }>('/admin/strm/downloads/retry-failed').then((r) => r.data),
|
||||
|
||||
cancelPendingDownloads: () =>
|
||||
api.post<{ canceled: number }>('/admin/strm/downloads/cancel-pending').then((r) => r.data),
|
||||
|
||||
uploads: (status?: string, page = 1, pageSize = 50) =>
|
||||
api
|
||||
.get<StrmQueueSnapshot>('/admin/strm/uploads', {
|
||||
params: { status, page, page_size: pageSize },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
cancelUpload: (id: string) =>
|
||||
api.post(`/admin/strm/uploads/${id}/cancel`).then((r) => r.data),
|
||||
|
||||
retryUpload: (id: string) =>
|
||||
api.post(`/admin/strm/uploads/${id}/retry`).then((r) => r.data),
|
||||
}
|
||||
Reference in New Issue
Block a user