收口生成队列与图片预览
将外部生成队列概览移到我的页签展示 移除生成页和进度页中的队列概览区域 新增全屏黑底图片预览器并支持缩放和边界拖拽 补充队列概览和图片预览的聚焦测试 同步更新玩法链路、运维、UI Kit 和团队共享记忆文档
This commit is contained in:
@@ -2,7 +2,24 @@ import type {
|
||||
ExternalGenerationJobStatusRecord,
|
||||
ExternalGenerationQueueOverview,
|
||||
} from '../../../packages/shared/src/contracts/externalGeneration';
|
||||
import type { ExternalGenerationQueueStatus } from '../CustomWorldGenerationView';
|
||||
|
||||
export type ExternalGenerationQueueStatus = {
|
||||
currentStatus?: 'queued' | 'running' | 'completed' | 'failed' | null;
|
||||
currentProgress?: number | null;
|
||||
pendingCount?: number | null;
|
||||
runningCount?: number | null;
|
||||
};
|
||||
|
||||
export type ExternalGenerationQueuePresentation = {
|
||||
statusLabel: string | null;
|
||||
progressLabel: string | null;
|
||||
pendingLabel: string;
|
||||
runningLabel: string;
|
||||
pendingCount: number;
|
||||
runningCount: number;
|
||||
progress: number | null;
|
||||
shouldShow: boolean;
|
||||
};
|
||||
|
||||
export function buildExternalGenerationQueueStatus(
|
||||
overview: ExternalGenerationQueueOverview | null,
|
||||
@@ -19,3 +36,97 @@ export function buildExternalGenerationQueueStatus(
|
||||
runningCount: overview?.runningCount ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveExternalGenerationQueueStatusLabel(
|
||||
status: ExternalGenerationQueueStatus['currentStatus'],
|
||||
) {
|
||||
if (status === 'queued') {
|
||||
return '排队中';
|
||||
}
|
||||
|
||||
if (status === 'running') {
|
||||
return '生成中';
|
||||
}
|
||||
|
||||
if (status === 'failed') {
|
||||
return '生成失败';
|
||||
}
|
||||
|
||||
if (status === 'completed') {
|
||||
return '已完成';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function resolveExternalGenerationQueueOverviewLabel(
|
||||
pendingCount: number,
|
||||
runningCount: number,
|
||||
) {
|
||||
if (runningCount > 0) {
|
||||
return '生成中';
|
||||
}
|
||||
|
||||
if (pendingCount > 0) {
|
||||
return '排队中';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function normalizeExternalGenerationQueueCount(
|
||||
value: number | null | undefined,
|
||||
) {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max(0, Math.round(value));
|
||||
}
|
||||
|
||||
export function normalizeExternalGenerationQueueProgress(
|
||||
value: number | null | undefined,
|
||||
) {
|
||||
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Math.max(0, Math.min(100, Math.round(value)));
|
||||
}
|
||||
|
||||
export function buildExternalGenerationQueuePresentation(
|
||||
status: ExternalGenerationQueueStatus | null | undefined,
|
||||
): ExternalGenerationQueuePresentation {
|
||||
const pendingCount = normalizeExternalGenerationQueueCount(
|
||||
status?.pendingCount,
|
||||
);
|
||||
const runningCount = normalizeExternalGenerationQueueCount(
|
||||
status?.runningCount,
|
||||
);
|
||||
const progress = normalizeExternalGenerationQueueProgress(
|
||||
status?.currentProgress,
|
||||
);
|
||||
const isCompletedCurrentJob = status?.currentStatus === 'completed';
|
||||
const currentStatusLabel = resolveExternalGenerationQueueStatusLabel(
|
||||
status?.currentStatus ?? null,
|
||||
);
|
||||
const overviewStatusLabel = resolveExternalGenerationQueueOverviewLabel(
|
||||
pendingCount,
|
||||
runningCount,
|
||||
);
|
||||
const statusLabel = isCompletedCurrentJob
|
||||
? overviewStatusLabel
|
||||
: (currentStatusLabel ?? overviewStatusLabel);
|
||||
const progressValue = isCompletedCurrentJob ? null : progress;
|
||||
|
||||
return {
|
||||
statusLabel,
|
||||
progressLabel: progressValue == null ? null : `${progressValue}%`,
|
||||
pendingLabel: pendingCount.toString(),
|
||||
runningLabel: runningCount.toString(),
|
||||
pendingCount,
|
||||
runningCount,
|
||||
progress: progressValue,
|
||||
shouldShow: Boolean(statusLabel || pendingCount > 0 || runningCount > 0),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user