refactor(*): 代码质量治理 - 收敛接口客户端、模型职责与异步计费巡检
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import axios from "axios";
|
||||
|
||||
import type { BackendEnvelope } from "@/services/api/task-center";
|
||||
import type { Asset } from "@/stores/use-asset-store";
|
||||
import type { CanvasProject } from "@/stores/canvas/use-canvas-store";
|
||||
import { apiClient, request } from "@/services/api/request";
|
||||
|
||||
const api = axios.create({ baseURL: import.meta.env.VITE_CANVAS_BACKEND_URL || "/api", withCredentials: true });
|
||||
const api = apiClient;
|
||||
|
||||
export type RemoteUserDataSummary = {
|
||||
id: string;
|
||||
@@ -14,16 +12,6 @@ export type RemoteUserDataSummary = {
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
async function request<T>(promise: Promise<{ data: BackendEnvelope<T> }>) {
|
||||
try {
|
||||
const response = await promise;
|
||||
if (response.data.code !== 0) throw new Error(response.data.msg || "请求失败");
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BackendEnvelope<unknown>>(error)) throw new Error(error.response?.data?.msg || error.message || "请求失败");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export function listRemoteAssets() {
|
||||
return request<{ assets: RemoteUserDataSummary[] }>(api.get("/assets"));
|
||||
|
||||
Reference in New Issue
Block a user