mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
refactor(api): 渠道与存储管理调用适配后端通用 manage 接口
- 新增 src/api/manage.ts 通用封装:ManageRequest(target+action+params) 与 manageNotificationChannel/manageStorage 两个调用入口 - 存储类调用全部改走 POST /storage/manage:用量、整理方式、 配置保存/重置、二维码与 OAuth 登录确认(smb/alist/rclone/u115/alipan) - ClawBot 状态查询、二维码刷新、登出与缓存迁移改走 POST /notification/manage,原 query 参数转入 body params - 同步更新 AccountSettingNotification 单测断言,prune 失效 lint 抑制项
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import type { AxiosRequestConfig } from 'axios'
|
||||
import api from './index'
|
||||
|
||||
/** 通用管理请求:目标标识 + 管理动作 + 透传参数,与后端 ManageRequest 一致。 */
|
||||
export interface ManageRequest {
|
||||
target: string
|
||||
action: string
|
||||
params?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用统一管理端点(通知渠道 / 网盘存储)
|
||||
*
|
||||
* 端点层不定义任何目标特定的名称与参数,
|
||||
* 目标标识、管理动作与表单参数原样透传给后端模块
|
||||
*/
|
||||
function manageTarget<T = Record<string, unknown>>(
|
||||
endpoint: 'notification/manage' | 'storage/manage',
|
||||
request: ManageRequest,
|
||||
config?: AxiosRequestConfig,
|
||||
): Promise<T> {
|
||||
return api.post<T>(endpoint, { params: {}, ...request }, config)
|
||||
}
|
||||
|
||||
/** 对指定通知渠道执行管理动作,返回响应中的业务数据。 */
|
||||
export function manageNotificationChannel<T = Record<string, unknown>>(
|
||||
channel: string,
|
||||
action: string,
|
||||
params: Record<string, unknown> = {},
|
||||
config?: AxiosRequestConfig,
|
||||
): Promise<T> {
|
||||
return manageTarget<T>('notification/manage', { target: channel, action, params }, config)
|
||||
}
|
||||
|
||||
/** 对指定网盘存储执行管理动作,返回响应中的业务数据。 */
|
||||
export function manageStorage<T = Record<string, unknown>>(
|
||||
storage: string,
|
||||
action: string,
|
||||
params: Record<string, unknown> = {},
|
||||
config?: AxiosRequestConfig,
|
||||
): Promise<T> {
|
||||
return manageTarget<T>('storage/manage', { target: storage, action, params }, config)
|
||||
}
|
||||
Reference in New Issue
Block a user