feat: 前端新增图片生成功能
This commit is contained in:
33
Yi.Ai.Vue3/src/api/aiImage/index.ts
Normal file
33
Yi.Ai.Vue3/src/api/aiImage/index.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { get, post } from '@/utils/request';
|
||||
import type {
|
||||
GenerateImageRequest,
|
||||
ImageModel,
|
||||
PublishImageRequest,
|
||||
TaskListRequest,
|
||||
TaskListResponse,
|
||||
TaskStatusResponse,
|
||||
} from './types';
|
||||
|
||||
export function generateImage(data: GenerateImageRequest) {
|
||||
return post<string>('/ai-image/generate', data).json();
|
||||
}
|
||||
|
||||
export function getTaskStatus(taskId: string) {
|
||||
return get<TaskStatusResponse>(`/ai-image/task/${taskId}`).json();
|
||||
}
|
||||
|
||||
export function getMyTasks(params: TaskListRequest) {
|
||||
return get<TaskListResponse>('/ai-image/my-tasks', params).json();
|
||||
}
|
||||
|
||||
export function getImagePlaza(params: TaskListRequest) {
|
||||
return get<TaskListResponse>('/ai-image/plaza', params).json();
|
||||
}
|
||||
|
||||
export function publishImage(data: PublishImageRequest) {
|
||||
return post<void>('/ai-image/publish', data).json();
|
||||
}
|
||||
|
||||
export function getImageModels() {
|
||||
return post<ImageModel[]>('/ai-image/model').json();
|
||||
}
|
||||
53
Yi.Ai.Vue3/src/api/aiImage/types.ts
Normal file
53
Yi.Ai.Vue3/src/api/aiImage/types.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
export interface GenerateImageRequest {
|
||||
tokenId: string;
|
||||
prompt: string;
|
||||
modelId: string;
|
||||
referenceImagesPrefixBase64?: string[];
|
||||
}
|
||||
|
||||
export interface TaskStatusResponse {
|
||||
id: string;
|
||||
prompt: string;
|
||||
storePrefixBase64?: string;
|
||||
storeUrl?: string;
|
||||
taskStatus: 'Processing' | 'Success' | 'Fail';
|
||||
publishStatus: string;
|
||||
categories: string[];
|
||||
creationTime: string;
|
||||
}
|
||||
|
||||
export interface TaskListRequest {
|
||||
PageIndex: number;
|
||||
PageSize: number;
|
||||
TaskStatus?: 'Processing' | 'Success' | 'Fail';
|
||||
}
|
||||
|
||||
export interface TaskItem {
|
||||
id: string;
|
||||
prompt: string;
|
||||
storePrefixBase64?: string;
|
||||
storeUrl?: string;
|
||||
taskStatus: 'Processing' | 'Success' | 'Fail';
|
||||
publishStatus: string;
|
||||
categories: string[];
|
||||
creationTime: string;
|
||||
}
|
||||
|
||||
export interface TaskListResponse {
|
||||
total: number;
|
||||
items: TaskItem[];
|
||||
}
|
||||
|
||||
export interface PublishImageRequest {
|
||||
taskId: string;
|
||||
categories: string[];
|
||||
}
|
||||
|
||||
export interface ImageModel {
|
||||
id: string;
|
||||
modelId: string;
|
||||
modelName: string;
|
||||
modelDescribe: string;
|
||||
remark: string;
|
||||
isPremiumPackage: boolean;
|
||||
}
|
||||
@@ -6,3 +6,4 @@ export * from './model';
|
||||
export * from './pay';
|
||||
export * from './session';
|
||||
export * from './user';
|
||||
export * from './aiImage';
|
||||
|
||||
@@ -138,7 +138,8 @@ export function disableToken(id: string) {
|
||||
// 新增接口2
|
||||
// 获取可选择的token信息
|
||||
export function getSelectableTokenInfo() {
|
||||
return get<any>('/token/select-list').json();
|
||||
// return get<any>('/token/select-list').json();
|
||||
return get<any>('/token/select-list?includeDefault=false').json();
|
||||
}
|
||||
/*
|
||||
返回数据
|
||||
|
||||
Reference in New Issue
Block a user