feat(short-drama-agent-front): 接入人工动作修订与视频版本权限

This commit is contained in:
GJ committed 2026-10-14 13:44:02 +08:00
1 parent 7a60db3ced
commit fa76165960
38 files changed
+2003 -158

No files matched your search

+11 -3
View File
@@ -3,7 +3,9 @@ export class ApiError extends Error {
constructor(
message: string,
public readonly status: number,
public readonly details?: unknown
public readonly details?: unknown,
/** 同步接口的顶层业务错误码;普通 400 或网络错误可缺省。 */
public readonly code?: string
) {
super(message)
this.name = 'ApiError'
@@ -23,7 +25,12 @@ function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}
/** 兼容普通 {data} 响应,以及 POST /projects 的顶层 202 响应。 */
/**
* 解析公开响应及顶层同步错误码,不自动重试写入。
* @param path 不含统一 API 前缀的正式路径
* @param options 方法、请求体及取消信号
* @returns 解包后的公开响应
*/
export async function request<T>(path: string, options: RequestOptions = {}): Promise<T> {
const base = (import.meta.env.VITE_API_BASE_URL || '/api').replace(/\/$/, '')
const multipart = typeof FormData !== 'undefined' && options.body instanceof FormData
@@ -58,7 +65,8 @@ export async function request<T>(path: string, options: RequestOptions = {}): Pr
throw new ApiError(
message,
response.status,
isRecord(data) ? (data.details ?? data.issues ?? data.error) : data
isRecord(data) ? (data.details ?? data.issues ?? data.error) : data,
isRecord(data) && typeof data.code === 'string' ? data.code : undefined
)
}
return (isRecord(data) && 'data' in data ? data.data : data) as T