import type { EditorGenerationModel3dPricingPayload, EditorGenerationModel3dVersionPricePayload, } from '../api/adminApiTypes'; import { EDITOR_MODEL3D_ENDPOINT_SECTIONS, editorModel3dAddOnLabel, updateEditorModel3dEndpointPricing, } from './adminEditorGenerationPricing'; import { parsePositiveInteger } from './pageUtils'; /** * 一个模型版本的两个底价字段。两栏只有字段键与展示名不同,用描述表驱动渲染, * 避免两段近乎相同的 JSX 各自演化。 */ const VERSION_PRICE_FIELDS = [ { key: 'noTexture', label: '无贴图' }, { key: 'texture', label: '带贴图' }, ] as const satisfies ReadonlyArray<{ key: keyof EditorGenerationModel3dVersionPricePayload; label: string; }>; interface AdminEditorGenerationModel3dPricingSectionProps { model3d: EditorGenerationModel3dPricingPayload; onChange: (next: EditorGenerationModel3dPricingPayload) => void; } /** * 3D 生成定价区块:按端点分成「文生 3D」与「图生 3D」两组,每组是该端点自己的 * 「模型版本 × {无贴图, 带贴图}」底价表与加价项单值输入。 * * 键集合全部来自接口返回,后台只能改数值:不能新增、删除键,也不能停用整段。 */ export function AdminEditorGenerationModel3dPricingSection({ model3d, onChange, }: AdminEditorGenerationModel3dPricingSectionProps) { function updateEndpoint( section: (typeof EDITOR_MODEL3D_ENDPOINT_SECTIONS)[number]['key'], updater: Parameters[2], ) { onChange(updateEditorModel3dEndpointPricing(model3d, section, updater)); } return (
3D 生成定价 按次

模型版本与加价项由后端契约给出,只能改数值;两段必须完整给出,缺失即 3D 生成不可提交。

{EDITOR_MODEL3D_ENDPOINT_SECTIONS.map(({ key, label }) => (
{label}
{Object.entries(model3d[key].versionPrices).map( ([version, price]) => (
{version} {VERSION_PRICE_FIELDS.map( ({ key: field, label: fieldLabel }) => ( ), )}
), )}
{Object.entries(model3d[key].addOnPrices).map( ([addOn, price]) => ( ), )}
))}
); }