前端补上「分件 + 方形布线 / 智能低多边形」的互斥校验

- src/components/image-editor/model3d-generation/Model3dGenerationFormModel.ts:resolveModel3dGenerationParams 增加 generateParts 与 quad / smartLowPoly 的互斥判定,与 provider 的 validate_generation_options 对齐;此前纯几何档位下这两个开关仍可同开,前端能出价、提交后才被后端拒
- src/components/image-editor/model3d-generation/Model3dGenerationFormModel.test.ts:新增该组合被拒的用例

验证:npx vitest run src/components/image-editor/model3d-generation(40 用例全绿)
This commit is contained in:
2026-09-22 13:26:49 +08:00
parent 25fe98836f
commit 73f34ecbc9
2 changed files with 29 additions and 0 deletions
@@ -159,6 +159,27 @@ describe('resolveModel3dGenerationParams', () => {
}).ok,
).toBe(false);
});
it('分件不允许与方形布线 / 智能低多边形同时开,这是后端也会拒的组合', () => {
const conflictingSwitches: Array<{ quad: boolean; smartLowPoly: boolean }> =
[
{ quad: true, smartLowPoly: false },
{ quad: false, smartLowPoly: true },
];
for (const switches of conflictingSwitches) {
expect(
resolveModel3dGenerationParams({
tier: 'geometry-only',
quad: switches.quad,
smartLowPoly: switches.smartLowPoly,
generateParts: true,
}),
).toEqual({
ok: false,
reason: '分件生成不能与方形布线或智能低多边形同时使用',
});
}
});
});
describe('resolveModel3dAddOnKeys', () => {
@@ -105,6 +105,14 @@ export function resolveModel3dGenerationParams({
if (texture && generateParts) {
return { ok: false, reason: '分件生成只支持纯几何档位' };
}
// 与 provider 的 `validate_generation_options` 对齐:generate_parts=true 不能和
// quad / smart_low_poly 同时开,前端先挡住,避免出价成功后才在服务端被拒。
if (generateParts && (quad || smartLowPoly)) {
return {
ok: false,
reason: '分件生成不能与方形布线或智能低多边形同时使用',
};
}
return {
ok: true,
params: {