feat(admin): 存储管理 - 支持批量引用校验与事务化删除
Adapted from ddcat-ai/open-ai-canvas#339 Original commit: fcdbe2aa833f31f683f709b7f409a0534ed78e20 Refs #339 Co-authored-by: 宇熙 <101980758+yuxiwl@users.noreply.github.com>
This commit is contained in:
@@ -54,6 +54,23 @@ export type AdminResourceQuery = {
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type AdminResourceReference = {
|
||||
kind: string;
|
||||
id: string;
|
||||
title: string;
|
||||
};
|
||||
|
||||
export type AdminResourceDeleteBlocked = {
|
||||
id: string;
|
||||
reason: string;
|
||||
references: AdminResourceReference[];
|
||||
};
|
||||
|
||||
export type AdminResourceDeleteResult = {
|
||||
deleted: string[];
|
||||
blocked: AdminResourceDeleteBlocked[];
|
||||
};
|
||||
|
||||
export async function listAdminResources(query: AdminResourceQuery, signal?: AbortSignal) {
|
||||
return request<AdminResourcePage>(apiClient.get("/admin/resources", { params: compactApiParams(query), signal }));
|
||||
}
|
||||
@@ -63,6 +80,10 @@ export async function getAdminStorageStats(signal?: AbortSignal) {
|
||||
return result.stats;
|
||||
}
|
||||
|
||||
export function deleteAdminResources(resourceIds: string[]) {
|
||||
return request<AdminResourceDeleteResult>(apiClient.post("/admin/resources/delete", { resourceIds }));
|
||||
}
|
||||
|
||||
export function adminResourceFileUrl(id: string, download = false) {
|
||||
const base = String(apiBaseURL).replace(/\/+$/, "");
|
||||
return `${base}/admin/resources/${encodeURIComponent(id)}/file${download ? "?download=1" : ""}`;
|
||||
|
||||
Reference in New Issue
Block a user