暂存修改
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import { api, setToken, clearToken } from './client';
|
||||
import * as mock from './mock';
|
||||
import type {
|
||||
User, CreditRecord, Project, GenerationRecord, OptimizeParams, GenerateParams, OptimizeResult,
|
||||
User, CreditRecord, Project, GenerationRecord, OptimizeParams, OptimizeResult,
|
||||
Industry, IndustryConfig, AdminUser, AdminStats, ModelConfig, SystemConfig, AdminNotification,
|
||||
PrivatePortraitConfig, PrivatePortraitProjectListOut, PrivatePortraitProject, PrivatePortraitValidateSession,
|
||||
PrivatePortraitProjectCreateWithValidateOut, PrivatePortraitAssetListOut, PrivatePortraitAsset, PrivatePortraitSelectableAssetListOut,
|
||||
@@ -112,7 +112,11 @@ export async function optimizePrompt(
|
||||
project_id: projectId,//项目id
|
||||
gen_type:params.genType,//生成类型
|
||||
prompt: params.prompt,
|
||||
engine_id: params.engineId,
|
||||
include_media_references: params.includeMediaReferences ?? false,
|
||||
duration: params.duration,
|
||||
aspect_ratio: params.aspectRatio || null,
|
||||
resolution: params.resolution || null,
|
||||
references: params.references || null,
|
||||
idempotency_key: params.idempotencyKey || null,
|
||||
image_size: params.image_size || null,
|
||||
@@ -266,15 +270,14 @@ export async function deleteUpload(url: string): Promise<void> {
|
||||
export async function updateRecordPrompt(recordId: string, optimizedPrompt: string): Promise<void> {
|
||||
await api.put(`/generation-records/${recordId}/prompt`, { optimized_prompt: optimizedPrompt });
|
||||
}
|
||||
export async function generateVideo(recordId: string, params: GenerateParams): Promise<GenerationRecord> {
|
||||
export async function generateVideo(recordId: string): Promise<GenerationRecord> {
|
||||
if (USE_MOCK) return mock.mockGenerateVideo(recordId);
|
||||
return api.post<GenerationRecord>(`/generation-records/${recordId}/generate`, {
|
||||
engine_id: params.engineId,
|
||||
include_media_references: params.includeMediaReferences ?? false,
|
||||
aspect_ratio: params.aspectRatio,
|
||||
resolution: params.resolution,
|
||||
image_size: params.imageSize,
|
||||
});
|
||||
return api.post<GenerationRecord>(`/generation-records/${recordId}/generate`);
|
||||
}
|
||||
|
||||
export async function retryGeneration(recordId: string): Promise<GenerationRecord> {
|
||||
if (USE_MOCK) return mock.mockGenerateVideo(recordId);
|
||||
return api.post<GenerationRecord>(`/generation-records/${recordId}/retry`);
|
||||
}
|
||||
// ── Credits ───────────────────────────────────────────────
|
||||
export async function getCredits(page = 1, pageSize = 20): Promise<{ credits: number; records: CreditRecord[]; total: number }> {
|
||||
|
||||
@@ -3,7 +3,6 @@ import type {
|
||||
CreditRecord,
|
||||
Project,
|
||||
GenerationRecord,
|
||||
GenerateParams,
|
||||
OptimizeParams,
|
||||
OptimizeResult,
|
||||
LoginParams,
|
||||
@@ -208,7 +207,7 @@ export async function mockOptimizePrompt(
|
||||
await delay(1500);
|
||||
|
||||
const project = MOCK_PROJECTS.find((p) => p.id === projectId);
|
||||
const cost = Math.round(80 + params.prompt.length * 0.5 + params.duration * 2);
|
||||
const cost = Math.round(80 + params.prompt.length * 0.5 + (params.duration || 0) * 2);
|
||||
|
||||
if (currentUser) {
|
||||
currentUser.credits -= cost;
|
||||
@@ -239,18 +238,28 @@ export async function mockOptimizePrompt(
|
||||
projectName: project?.name ?? '未知项目',
|
||||
originalPrompt: params.prompt,
|
||||
optimizedPrompt,
|
||||
duration: params.duration,
|
||||
aspectRatio: params.aspectRatio as any,
|
||||
resolution: params.resolution as any,
|
||||
duration: params.genType === 'video' ? params.duration : undefined,
|
||||
aspectRatio: params.genType === 'video' ? params.aspectRatio as any : undefined,
|
||||
resolution: params.genType === 'video' ? params.resolution as any : undefined,
|
||||
status: 'prompt_optimized',
|
||||
creditsCost: cost,
|
||||
textCreditsCost: cost,
|
||||
textTokensUsed: 0,
|
||||
videoTokensUsed: 0,
|
||||
imageSize: params.resolution || '1080p',
|
||||
imageProportion: params.aspectRatio || '16:9',
|
||||
imagePx: '1920x1080',
|
||||
imageSize: params.genType === 'image' ? params.image_size : undefined,
|
||||
imageProportion: params.genType === 'image' ? params.image_proportion : undefined,
|
||||
imagePx: params.genType === 'image' ? params.image_px : undefined,
|
||||
imageUrl: '',
|
||||
engineId: params.engineId,
|
||||
engineName: params.engineId,
|
||||
engineSnapshot: { id: params.engineId, name: params.engineId },
|
||||
includeMediaReferences: Boolean(params.includeMediaReferences),
|
||||
configComplete: true,
|
||||
canGenerate: true,
|
||||
canRetry: false,
|
||||
shouldPoll: false,
|
||||
clientStatus: 'ready',
|
||||
operationPhase: 'prompt',
|
||||
createdAt: new Date().toLocaleString('zh-CN'),
|
||||
};
|
||||
|
||||
@@ -265,7 +274,18 @@ export async function mockGenerateVideo(recordId: string): Promise<GenerationRec
|
||||
if (!record) throw new Error('记录不存在');
|
||||
|
||||
record.status = 'completed';
|
||||
record.videoUrl = `https://example.com/video-${recordId}.mp4`;
|
||||
record.canGenerate = false;
|
||||
record.canRetry = false;
|
||||
record.shouldPoll = false;
|
||||
record.clientStatus = 'success';
|
||||
record.operationPhase = 'resource';
|
||||
if (record.genType === 'image') {
|
||||
record.imageUrl = `https://example.com/image-${recordId}.png`;
|
||||
record.videoUrl = undefined;
|
||||
} else {
|
||||
record.videoUrl = `https://example.com/video-${recordId}.mp4`;
|
||||
record.imageUrl = undefined;
|
||||
}
|
||||
record.generatedAt = new Date().toLocaleString('zh-CN');
|
||||
|
||||
return record;
|
||||
|
||||
Reference in New Issue
Block a user