This commit is contained in:
2026-06-25 16:53:46 +08:00
39 changed files with 2943 additions and 866 deletions
+80
View File
@@ -424,6 +424,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?: {
@@ -587,3 +630,40 @@ 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 };
}
// 自定义表头字段
export async function getFields(): Promise<any> {
return api.get('/material-consumption/fields');
}
// 查询素材消耗列表
export interface MaterialConsumpParams {
advertiser_id?: string;
user_id?: string;
consume_date?: [string, string];
page?: number;
page_size?: number;
}
export async function getMaterialConsumpList(params: MaterialConsumpParams): Promise<any> {
const query = new URLSearchParams();
if (params.advertiser_id) query.set('advertiser_id', params.advertiser_id);
if (params.user_id) query.set('user_id', params.user_id);
if (params.consume_date !== undefined) query.set('consume_date', params.consume_date[0] + ',' + params.consume_date[1]);
if (params.page !== undefined) query.set('page', String(params.page));
if (params.page_size !== undefined) query.set('page_size', String(params.page_size));
return api.get(`/material-consumption/admin/list?${query.toString()}`);
}