59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import { requestJson } from './apiClient';
|
|
import type { CustomWorldCoverCropRect, CustomWorldProfile } from '../types';
|
|
|
|
const CUSTOM_WORLD_COVER_API_BASE = '/api/runtime/custom-world';
|
|
|
|
export interface CustomWorldCoverAssetResult {
|
|
imageSrc: string;
|
|
assetId: string;
|
|
sourceType: 'uploaded' | 'generated';
|
|
model?: string;
|
|
size?: string;
|
|
taskId?: string;
|
|
prompt?: string;
|
|
actualPrompt?: string;
|
|
}
|
|
|
|
export interface GenerateCustomWorldCoverImageRequest {
|
|
profile: CustomWorldProfile;
|
|
userPrompt?: string;
|
|
referenceImageSrc?: string;
|
|
characterRoleIds?: string[];
|
|
size?: string;
|
|
}
|
|
|
|
export interface UploadCustomWorldCoverImageRequest {
|
|
profileId: string;
|
|
worldName: string;
|
|
imageDataUrl: string;
|
|
cropRect: CustomWorldCoverCropRect;
|
|
}
|
|
|
|
export async function generateCustomWorldCoverImage(
|
|
payload: GenerateCustomWorldCoverImageRequest,
|
|
) {
|
|
return requestJson<CustomWorldCoverAssetResult>(
|
|
`${CUSTOM_WORLD_COVER_API_BASE}/cover-image`,
|
|
{
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload),
|
|
},
|
|
'生成作品封面失败',
|
|
);
|
|
}
|
|
|
|
export async function uploadCustomWorldCoverImage(
|
|
payload: UploadCustomWorldCoverImageRequest,
|
|
) {
|
|
return requestJson<CustomWorldCoverAssetResult>(
|
|
`${CUSTOM_WORLD_COVER_API_BASE}/cover-upload`,
|
|
{
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload),
|
|
},
|
|
'上传作品封面失败',
|
|
);
|
|
}
|