feat: 完善敲木鱼玩法模板链路

This commit is contained in:
2026-05-24 02:49:13 +08:00
parent 2ba4691bc0
commit 8638397faa
402 changed files with 2329 additions and 1781 deletions

View File

@@ -434,7 +434,15 @@ describe('miniGameDraftGenerationProgress', () => {
workDescription: '敲一下,好事发生。',
themeTags: ['解压'],
hitObjectPrompt: '金色小木鱼',
hitSoundPrompt: '清脆木鱼声',
hitSoundAsset: {
assetId: 'wooden-fish-default-hit-sound',
audioSrc: '/wooden-fish/default-hit-sound.mp3',
audioObjectKey: 'public/wooden-fish/default-hit-sound.mp3',
assetObjectId: 'wooden-fish-default-hit-sound',
source: 'bundled-default',
prompt: '默认木鱼音',
durationMs: 3000,
},
floatingWords: ['幸运+1', '功德+1'],
});
@@ -447,7 +455,7 @@ describe('miniGameDraftGenerationProgress', () => {
{
id: 'wooden-fish-hit-sound',
label: '音效',
value: '清脆木鱼',
value: '默认木鱼',
},
{
id: 'wooden-fish-words',

View File

@@ -427,7 +427,7 @@ const WOODEN_FISH_STEPS = [
{
id: 'wooden-fish-hit-sound',
label: '准备敲击音效',
detail: '生成或写回短促敲击音效资产。',
detail: '写回上传、录音或默认短促敲击音效资产。',
weight: 16,
},
{
@@ -917,8 +917,7 @@ export function buildWoodenFishGenerationAnchorEntries(
key: 'wooden-fish-hit-sound',
label: '音效',
value:
formPayload?.hitSoundPrompt?.trim() ||
draft?.hitSoundPrompt?.trim() ||
formPayload?.hitSoundAsset?.prompt?.trim() ||
draft?.hitSoundAsset?.prompt?.trim() ||
'',
},

View File

@@ -0,0 +1,36 @@
import { beforeEach, expect, test, vi } from 'vitest';
const { createCreationAgentClientMock } = vi.hoisted(() => ({
createCreationAgentClientMock: vi.fn(),
}));
vi.mock('../creation-agent', () => ({
createCreationAgentClient: createCreationAgentClientMock,
}));
vi.mock('../apiClient', () => ({
requestJson: vi.fn(),
}));
beforeEach(() => {
vi.resetModules();
createCreationAgentClientMock.mockReset();
createCreationAgentClientMock.mockReturnValue({
createSession: vi.fn(),
getSession: vi.fn(),
sendMessage: vi.fn(),
streamMessage: vi.fn(),
executeAction: vi.fn(),
});
});
test('wooden fish creation keeps image2 generation requests alive long enough', async () => {
await import('./woodenFishClient');
expect(createCreationAgentClientMock).toHaveBeenCalledWith(
expect.objectContaining({
createSessionTimeoutMs: 20 * 60 * 1000,
executeActionTimeoutMs: 20 * 60 * 1000,
}),
);
});

View File

@@ -22,6 +22,8 @@ import { createCreationAgentClient } from '../creation-agent';
const WOODEN_FISH_API_BASE = '/api/creation/wooden-fish/sessions';
const WOODEN_FISH_WORKS_API_BASE = '/api/creation/wooden-fish/works';
const WOODEN_FISH_RUNTIME_API_BASE = '/api/runtime/wooden-fish';
// 中文注释:敲木鱼创作会串行等待多次 image2 与 OSS 写入,前端请求窗口需要覆盖完整生成链路。
const WOODEN_FISH_GENERATION_TIMEOUT_MS = 20 * 60 * 1000;
const WOODEN_FISH_RUNTIME_READ_RETRY: ApiRetryOptions = {
maxRetries: 1,
baseDelayMs: 120,
@@ -66,6 +68,8 @@ const woodenFishCreationClient = createCreationAgentClient<
streamIncomplete: '敲木鱼共创消息流式结果不完整',
executeAction: '执行敲木鱼共创操作失败',
},
createSessionTimeoutMs: WOODEN_FISH_GENERATION_TIMEOUT_MS,
executeActionTimeoutMs: WOODEN_FISH_GENERATION_TIMEOUT_MS,
});
type FlattenedWoodenFishWorkProfileResponse = Omit<
@@ -108,6 +112,8 @@ function normalizeWoodenFishWorkProfile(
hitObjectAsset: flattened.hitObjectAsset,
backgroundAsset:
flattened.backgroundAsset ?? flattened.draft?.backgroundAsset ?? null,
backButtonAsset:
flattened.backButtonAsset ?? flattened.draft?.backButtonAsset ?? null,
hitSoundAsset: flattened.hitSoundAsset,
floatingWords: flattened.floatingWords,
};

View File

@@ -1,5 +1,20 @@
import type { WoodenFishAudioAsset } from '../../../packages/shared/src/contracts/woodenFish';
export const WOODEN_FISH_DEFAULT_HIT_OBJECT_SRC =
'/wooden-fish/default-hit-object.png';
export const WOODEN_FISH_DEFAULT_HIT_SOUND_SRC =
'/wooden-fish/default-hit-sound.mp3';
export const WOODEN_FISH_DEFAULT_HIT_OBJECT_PROMPT =
'默认敲击物图案,圆润木质质感,透明背景';
export const WOODEN_FISH_DEFAULT_HIT_SOUND_ASSET: WoodenFishAudioAsset = {
assetId: 'wooden-fish-default-hit-sound',
audioSrc: WOODEN_FISH_DEFAULT_HIT_SOUND_SRC,
audioObjectKey: 'public/wooden-fish/default-hit-sound.mp3',
assetObjectId: 'wooden-fish-default-hit-sound',
source: 'bundled-default',
prompt: '默认木鱼音',
durationMs: 3000,
};