落地方洞挑战图片与运行态交互
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
kdletters
2026-05-06 12:51:28 +08:00
parent 60b667a9d1
commit d06107f2c6
51 changed files with 2590 additions and 989 deletions

View File

@@ -95,7 +95,7 @@ const SQUARE_HOLE_STEPS = [
{
id: 'square-hole-draft',
label: '整理玩法草稿',
detail: '收拢题材、形状、洞口与加分选项。',
detail: '收拢题材、展示选项与洞口选项。',
weight: 28,
},
{
@@ -106,8 +106,8 @@ const SQUARE_HOLE_STEPS = [
},
{
id: 'square-hole-shapes',
label: '生成形状贴图',
detail: '为每个可投放形状生成贴图。',
label: '生成选项贴图',
detail: '为展示选项与洞口选项生成贴图。',
weight: 40,
},
] as const satisfies ReadonlyArray<MiniGameStepDefinition>;
@@ -225,7 +225,7 @@ export function buildMiniGameDraftGenerationProgress(
...state,
phase: resolveSquareHolePhaseByElapsedMs(elapsedMs),
}
: state;
: state;
const steps = getStepDefinitions(normalizedState.kind);
const activeStepIndex = getActiveStepIndex(steps, normalizedState.phase);
@@ -248,7 +248,7 @@ export function buildMiniGameDraftGenerationProgress(
? 0.55
: normalizedState.kind === 'square-hole'
? 0.42
: 0;
: 0;
const overallProgress =
normalizedState.phase === 'failed'
? Math.max(1, completedWeight)
@@ -283,7 +283,7 @@ export function buildMiniGameDraftGenerationProgress(
? Math.max(0, 7_000 - elapsedMs)
: normalizedState.kind === 'square-hole'
? Math.max(0, 12_000 - elapsedMs)
: null,
: null,
activeStepIndex,
steps: buildMiniGameProgressSteps(steps, activeStepIndex, normalizedState),
};
@@ -396,7 +396,8 @@ export function buildSquareHoleGenerationAnchorEntries(
{
key: 'square-hole-options',
label: '选项资产',
value: totalShapeCount > 0 ? `形状贴图 ${shapeCount}/${totalShapeCount}` : '',
value:
totalShapeCount > 0 ? `形状贴图 ${shapeCount}/${totalShapeCount}` : '',
},
];

View File

@@ -1,9 +1,16 @@
export {
listSquareHoleHistoryAssets,
squareHoleAssetClient,
type SquareHoleHistoryAsset,
type SquareHoleImageAssetKind,
} from './squareHoleAssetClient';
export {
deleteSquareHoleWork,
getSquareHoleWorkDetail,
listSquareHoleGallery,
listSquareHoleWorks,
publishSquareHoleWork,
regenerateSquareHoleWorkImage,
squareHoleWorksClient,
updateSquareHoleWork,
} from './squareHoleWorksClient';

View File

@@ -0,0 +1,46 @@
import { ASSET_API_PATHS } from '../../editor/shared/editorApiClient';
import { requestJson } from '../apiClient';
export type SquareHoleImageAssetKind =
| 'square_hole_cover_image'
| 'square_hole_background_image'
| 'square_hole_shape_image'
| 'square_hole_hole_image';
export type SquareHoleHistoryAsset = {
assetObjectId: string;
assetKind: SquareHoleImageAssetKind;
imageSrc: string;
ownerUserId?: string | null;
ownerLabel: string;
profileId?: string | null;
entityId?: string | null;
createdAt: string;
updatedAt: string;
};
/**
* 读取当前账号的方洞图片历史素材。
* 素材由后端图片生成链路写入正式资产索引,前端只负责按槽位展示和套用。
*/
export async function listSquareHoleHistoryAssets(payload: {
kind: SquareHoleImageAssetKind;
limit?: number;
}) {
const params = new URLSearchParams({ kind: payload.kind });
if (payload.limit) {
params.set('limit', String(payload.limit));
}
const response = await requestJson<{ assets: SquareHoleHistoryAsset[] }>(
`${ASSET_API_PATHS.assetHistory}?${params.toString()}`,
{ method: 'GET' },
'读取方洞历史图片失败',
);
return response.assets;
}
export const squareHoleAssetClient = {
listHistoryAssets: listSquareHoleHistoryAssets,
};

View File

@@ -1,5 +1,6 @@
import type {
PutSquareHoleWorkRequest,
RegenerateSquareHoleWorkImageRequest,
SquareHoleWorkDetailResponse,
SquareHoleWorkMutationResponse,
SquareHoleWorksResponse,
@@ -91,6 +92,25 @@ export function publishSquareHoleWork(profileId: string) {
);
}
/**
* 只重生成某一个方洞挑战图片槽位,不触发 Agent 草稿编译或整稿图片生成进度页。
*/
export function regenerateSquareHoleWorkImage(
profileId: string,
payload: RegenerateSquareHoleWorkImageRequest,
) {
return requestJson<SquareHoleWorkMutationResponse>(
`${SQUARE_HOLE_WORKS_API_BASE}/${encodeURIComponent(profileId)}/images/regenerate`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
},
'生成方洞挑战图片失败',
{ retry: SQUARE_HOLE_WORKS_WRITE_RETRY },
);
}
/**
* 删除当前用户的方洞挑战作品,并返回删除后的列表。
*/
@@ -109,5 +129,6 @@ export const squareHoleWorksClient = {
listGallery: listSquareHoleGallery,
list: listSquareHoleWorks,
publish: publishSquareHoleWork,
regenerateImage: regenerateSquareHoleWorkImage,
update: updateSquareHoleWork,
};