Update public-api.js via upload script - 2026-11-12 10:21:18

This commit is contained in:
mike 2026-11-12 10:21:35 +08:00
parent afd9798d43
commit ee8c4d3946
1 changed files with 6 additions and 0 deletions

View File

@ -149,6 +149,9 @@ const DETAIL_FIELD = 'webDetailImages'; // 新增:详情图文件名数组,
// 在模板管理里点"更新到网站"、勾选要同步的模板后,才把它们复制到这里。还没有这份数据时(第一次)用后台的模板。
const LIVE_TEMPLATES_KEY = 'crm:webTemplatesLive';
const TEMPLATES_KEY = 'crm:webDetailTemplates'; // 详情模板:[{ id, name, kind: 'images'|'html', images: [文件名], html }],图片在 uploads/<模板id>/
// 网站栏目 key(和网站 src/lib/catalog.mjs 一致):模板管理里"关联网站类目"可选的值
const SITE_PAGE_KEYS = ['mini', 'offline', 'online', 'aio', 'rack', 'modular', 'industrial', 'inverter', 'homeess', 'ciess',
'wall', 'floor', 'rackbatt', 'hvcab', 'pbr', 'vrla', 'vrla2', 'cab', 'pac', 'idm', 'dem'];
const TEMPLATE_IDS_FIELD = 'webDetailTemplateIds'; // 产品引用的模板id,按顺序显示在详情图下方
// —— 网站管理(非产品内容)——
const SITE_ASSETS_KEY = 'crm:webAssets'; // { 图片位id: [文件名 或 { file, caption:{en,es?,ru?} }] },文件在 uploads/site_assets/
@ -589,6 +592,9 @@ const PACK_KEY = 'crm:webPackSpecs'; // 箱规:[{ id, name, per, nw, gw, l, w,
function toPublic(p, templates = [], packSpecs = [], slugMap = null) {
const slug = (slugMap && slugMap.get(String(p.id))) || slugify(p.name);
const out = { slug };
// 模板选了"网站类目":用这个模板的产品直接放进那些栏目页(网站优先按这个归类,不再按品类名判断)
const pages = [...new Set(templatesOf(p, templates).map((t) => t.webPage).filter((k) => SITE_PAGE_KEYS.includes(k)))];
if (pages.length) out.webPages = pages;
for (const [pub, src] of Object.entries(FIELDS)) {
const v = p[src];
if (v === undefined || v === '' || (Array.isArray(v) && !v.length)) continue;