gongxiangp2/lib/desktop-client/test-presets.ts

120 lines
6.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import imageData from './test-preset-images.json'
import intakeSchema from './test-preset-intake.json'
const template = {
id: 'QA-FAST-001',
brandId: 'ekb:brand:小壹测试',
brandName: '小壹测试',
categoryId: 'ekb:category:链路验收',
categoryName: '链路验收',
} as const
type PresetVariant = {
id: string
barcode: string
name: string
colorName: string
size: [length: string, width: string, height: string]
material: string
boardType: string
photo: keyof typeof imageData
}
type Preset = {
id: string
label: string
spu: string
name: string
productBrand: string
description: string
sellingPoints: string[]
specifications: string[]
variants: [PresetVariant, ...PresetVariant[]]
}
const presets: Preset[] = [
{
id: 'oak-entryway-stool', label: '单条码 · 橡木换鞋凳', spu: 'XYQA-ST-001', name: '圆角橡木换鞋凳',
productBrand: '栖序家居(演示)',
description: '适合窄玄关的矮凳,四脚略向外张,保留浅橡木的天然色差与纹理。',
sellingPoints: ['40 cm 宽的座面,可沿玄关墙摆放', '圆角座面,边缘打磨顺滑', '开箱即用,凳脚配防滑垫'],
specifications: ['成品尺寸:400 × 280 × 420 mm', '材质:橡木拼板与橡木凳脚', '表面:哑光清漆', '净重:3.6 kg', '安装:整装'],
variants: [{ id: 'dd6f9c0b-6f6a-4a0e-9fb2-88d50aa7d001', barcode: '0200000010010', name: '原木色 · 标准款',
colorName: '浅橡木色', size: ['400', '280', '420'], material: '橡木', boardType: '橡木实木拼板', photo: 'oak-stool' }],
},
{
id: 'linen-storage-ottoman', label: '双花色 · 亚麻储物凳', spu: 'XYQA-OT-002', name: '翻盖亚麻储物凳',
productBrand: '栖序家居(演示)',
description: '同款软包储物凳分窄版和宽版。掀起坐盖可收纳毯子、靠垫或入户杂物。',
sellingPoints: ['软包坐盖可开启,合上后可作换鞋凳', '粗织纹理在近景中可辨识', '燕麦米窄版与岩灰宽版各有独立条码'],
specifications: ['燕麦米窄版:480 × 380 × 420 mm', '岩灰宽版:600 × 400 × 420 mm',
'面料:亚麻混纺', '填充:聚氨酯海绵', '底脚:黑色聚丙烯脚垫'],
variants: [
{ id: 'dd6f9c0b-6f6a-4a0e-9fb2-88d50aa7d002', barcode: '0200000020019', name: '燕麦米 · 48 cm',
colorName: '燕麦米', size: ['480', '380', '420'], material: '亚麻混纺、木质框架', boardType: '多层胶合板', photo: 'linen-sand' },
{ id: 'dd6f9c0b-6f6a-4a0e-9fb2-88d50aa7d003', barcode: '0200000020026', name: '岩灰 · 60 cm',
colorName: '岩灰', size: ['600', '400', '420'], material: '亚麻混纺、木质框架', boardType: '多层胶合板', photo: 'linen-charcoal' },
],
},
{
id: 'electric-standing-desk', label: '长卖点与规格表 · 电动升降桌', spu: 'XYQA-SD-003', name: '双电机电动升降桌',
productBrand: '衡间工位(演示)',
description: '面向家庭办公的坐站两用桌。胡桃木纹桌面配黑色钢架,升降手控器安装在右前方。',
sellingPoints: [
'两侧桌腿由双电机同步驱动,切换坐姿与站姿时,可让显示器、键盘和桌面收纳用品随桌面一同升降。',
'手控器提供三组高度记忆,共用工位的人可以分别记录坐姿和站姿的高度,也可用按键微调。',
'后侧理线托盘集中容纳插线板和电源适配器,预留随桌面运动的线缆长度,便于离地清理。',
'桌面前角采用圆角,胡桃木纹饰面便于日常擦拭。钢制 T 形底脚可微调,以适应轻微不平的地面。',
'遇阻检测用于升降过程中降低夹碰风险,摆放时仍需在桌面上下留出移动空间。',
],
specifications: [
'桌面:1200 × 600 mm,厚 25 mm', '高度:720–1180 mm', '升降速度:25 mm/s', '额定均布负载:70 kg',
'驱动:双电机,两节升降立柱', '手控器:数显,3 组高度记忆', '电源:AC 220 V / 50 Hz', '饰面:胡桃木纹三聚氰胺饰面',
'桌架:黑色粉末涂层冷轧钢', '净重:30.5 kg', '包装:桌板和桌架分箱,需组装', '随箱配件:理线托盘、紧固件、内六角扳手',
],
variants: [{ id: 'dd6f9c0b-6f6a-4a0e-9fb2-88d50aa7d004', barcode: '0200000030018', name: '胡桃木纹 · 120 cm',
colorName: '胡桃木色/黑色', size: ['1200', '600', '720'], material: '饰面板、冷轧钢', boardType: '三聚氰胺饰面刨花板', photo: 'standing-desk' }],
},
]
export function desktopTestProductPresets() {
return {
presets: presets.map(({ id, label, spu, name, productBrand, description, sellingPoints, specifications, variants }) => {
const { id: templateId, ...catalog } = template
const barcodeEntries = variants.map(({ id, barcode, colorName, material, boardType, size: [length, width, height] }) => ({
id: barcode, variantId: id, barcode, colorName, material, boardType,
dimensions: { length, width, height, unit: 'mm' as const },
}))
const [primary] = barcodeEntries
const imageAssets = variants.map(({ photo, colorName }) => ({
source: `local:${imageData[photo].sha256}`, name: `${name} ${colorName}.jpg`,
contentType: 'image/jpeg' as const, base64: imageData[photo].base64,
}))
return {
id, label, imageAssets,
productBrief: {
...catalog, source: 'upload' as const, name, identifierType: 'spu' as const, identifier: spu,
variant: variants[0].name, colorName: primary.colorName, colorMaterialId: '',
dimensions: primary.dimensions, note: description, detailBarcode: primary.barcode,
variants: variants.map(({ id, name, colorName }) => ({ id, name, colorName, colorMaterialId: '', images: [] })),
barcodeBindings: Object.fromEntries(barcodeEntries.map(({ variantId, barcode }) => [variantId, [barcode]])),
barcodeEntries,
// Import each imageAsset into the project and replace this transport reference
// with the local source returned by the existing image import.
images: imageAssets.map(({ source, name }, index) => ({
source, name, purpose: 'product' as const, kind: 'whiteBackground' as const, barcode: barcodeEntries[index].barcode,
})),
intake: {
templateId, schema: intakeSchema,
productValues: { productBrand, description, sellingPoints: sellingPoints.join('\n'), specifications: specifications.join('\n') },
barcodeValues: Object.fromEntries(barcodeEntries.map(({ barcode, colorName, material, boardType, dimensions }) => [
barcode, { colorName, material, boardType, length: dimensions.length, width: dimensions.width, height: dimensions.height },
])),
},
},
}
}),
}
}