修复图标规范参考图超限预检

后端在调用 LLM 前按模型上限拒绝超限参考图。
前端在请求发送前限制图标规范参考图数量。
补充超限零请求回归测试与预检顺序断言。
This commit is contained in:
2026-08-06 11:25:48 +08:00
parent c932f5e8fb
commit 3550f046e4
3 changed files with 38 additions and 11 deletions
@@ -1452,6 +1452,20 @@ describe('editorProjectClient', () => {
expect(requestJsonMock).not.toHaveBeenCalled();
});
it('rejects excess icon spec references before dispatch', async () => {
await expect(
generateEditorIconSpec({
playSetting: '回合制占点',
artStyle: '低多边形',
referenceImageSrcs: Array.from(
{ length: 6 },
(_, index) => `resource-reference-${index + 1}`,
),
}),
).rejects.toThrow('图标规范参考图最多允许 5 张,当前选择 6 张');
expect(requestJsonMock).not.toHaveBeenCalled();
});
it('submits icon spec business fields without a client prompt or image kind', async () => {
requestJsonMock.mockResolvedValueOnce({
imageSrc: 'data:image/png;base64,spec',
@@ -1106,6 +1106,11 @@ export async function generateEditorIconSpec(
'美术风格',
);
assertStableEditorMediaReferences(input.referenceImageSrcs, '图标规范参考图');
assertEditorReferenceLimit(
input.referenceImageSrcs,
EDITOR_IMAGE_REFERENCE_LIMIT,
'图标规范参考图',
);
return requestJson<EditorImageGenerationResponse>(
EDITOR_ICON_SPEC_GENERATION_API,
jsonRequest('POST', {