对接素材列表解决
This commit is contained in:
@@ -403,6 +403,49 @@ export async function deleteOauthApp(id: string): Promise<void> {
|
||||
await api.get(`/admin/user-oauth-apps/delete/${id}`);
|
||||
}
|
||||
|
||||
// ── Open Type ───────────────────────────────────────────────
|
||||
|
||||
export async function getOpenTypeList(params?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
type_name?: string;
|
||||
open_type?: number;
|
||||
}): Promise<{ total: number; items: any[] }> {
|
||||
const q = new URLSearchParams();
|
||||
if (params?.page) q.set('page', String(params.page));
|
||||
if (params?.page_size) q.set('page_size', String(params.page_size));
|
||||
if (params?.type_name) q.set('type_name', params.type_name);
|
||||
if (params?.open_type) q.set('open_type', String(params.open_type));
|
||||
const qs = q.toString();
|
||||
return api.get(`/open-type/list${qs ? `?${qs}` : ''}`);
|
||||
}
|
||||
|
||||
export async function getOpenType(id: string): Promise<any> {
|
||||
return api.get(`/open-type/select/${id}`);
|
||||
}
|
||||
|
||||
export async function createOpenType(data: {
|
||||
open_type: number;
|
||||
description: string;
|
||||
type_name: string;
|
||||
thumb?: string;
|
||||
}): Promise<any> {
|
||||
return api.post('/open-type/create', data);
|
||||
}
|
||||
|
||||
export async function updateOpenType(id: string, data: {
|
||||
open_type?: number;
|
||||
description?: string;
|
||||
type_name?: string;
|
||||
thumb?: string;
|
||||
}): Promise<any> {
|
||||
return api.put(`/open-type/update/${id}`, data);
|
||||
}
|
||||
|
||||
export async function deleteOpenType(id: string): Promise<void> {
|
||||
await api.delete(`/open-type/delete/${id}`);
|
||||
}
|
||||
|
||||
// ── Generation Records (Admin) ─────────────────────────────
|
||||
|
||||
export async function getAdminGenerationRecords(params?: {
|
||||
@@ -566,3 +609,17 @@ export async function getOAuthList(params: OAuthListParams): Promise<any> {
|
||||
if (params.page_size !== undefined) query.set('page_size', String(params.page_size));
|
||||
return api.get(`/user-oauth/oauth_list?${query.toString()}`);
|
||||
}
|
||||
|
||||
export async function uploadImage(file: File): Promise<{ url: string; filename: string }> {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
const token = localStorage.getItem('auth_token');
|
||||
const res = await fetch(`${import.meta.env.VITE_API_BASE || 'http://localhost:8000'}/api/generation-records/upload-image`, {
|
||||
method: 'POST',
|
||||
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
||||
body: form,
|
||||
});
|
||||
if (!res.ok) throw new Error('图片上传失败');
|
||||
const data = await res.json();
|
||||
return { url: data.url, filename: data.filename };
|
||||
}
|
||||
Reference in New Issue
Block a user