Update App.jsx via upload script - 2026-11-12 10:21:12
This commit is contained in:
parent
6c71a90f2d
commit
afd9798d43
25
App.jsx
25
App.jsx
|
|
@ -7588,7 +7588,7 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts,
|
|||
const mainImages = await copyFiles(t.mainImages);
|
||||
// 详情图片里的 HTML 片段按"排在第几张图后面"定位,图片顺序不变,直接复制
|
||||
const detailHtml = (t.detailHtml || []).map(b => ({ ...b, id: 'dh_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6) }));
|
||||
const copy = { id, name: `${t.name || '模板'} 副本`, kind: t.kind || 'images', images, mainImages, detailHtml, html: '', htmls: tplHtmlsOf(t).map(h => ({ ...h })) };
|
||||
const copy = { id, name: `${t.name || '模板'} 副本`, webPage: t.webPage || '', kind: t.kind || 'images', images, mainImages, detailHtml, html: '', htmls: tplHtmlsOf(t).map(h => ({ ...h })) };
|
||||
setTemplates(list => {
|
||||
const i = list.findIndex(x => x.id === t.id);
|
||||
const next = [...list];
|
||||
|
|
@ -7613,7 +7613,7 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts,
|
|||
{templates.map(t => (
|
||||
<button type="button" key={t.id} className={`btn btn-sm${t.id === activeId ? ' btn-primary' : ''}`} onClick={() => setActiveId(t.id)}
|
||||
title={syncStatus ? (syncStatus[t.id] === 'synced' ? '已同步到网站' : syncStatus[t.id] === 'new' ? '新模板,还没同步到网站' : '有修改,还没同步到网站') : ''}>
|
||||
{t.name || '未命名模板'}({tplSummary(t)})
|
||||
{t.name || '未命名模板'}({tplSummary(t)}){t.webPage ? ` → ${sitePageLabel(t.webPage)}` : ''}
|
||||
{syncStatus && <span aria-label={syncStatus[t.id] === 'synced' ? '已同步' : '未同步'} style={{ marginLeft: 6, display: 'inline-grid', placeItems: 'center', width: 16, height: 16, borderRadius: 4, fontSize: 11, fontWeight: 700, lineHeight: 1,
|
||||
background: syncStatus[t.id] === 'synced' ? '#16a34a' : 'rgba(127,127,127,.25)', color: syncStatus[t.id] === 'synced' ? '#fff' : 'rgba(127,127,127,.9)' }}>✓</span>}
|
||||
</button>
|
||||
|
|
@ -7626,6 +7626,18 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts,
|
|||
<span className="field-label">模板名称(只在后台显示,网站上不显示)</span>
|
||||
<input className="input" value={active.name} onChange={e => update(active.id, { name: e.target.value })} placeholder="如:公司实力 / 认证证书 / 包装物流" />
|
||||
</div>
|
||||
<div className="field">
|
||||
<span className="field-label">关联网站类目(选了之后,用这个模板的所有型号直接显示在这个栏目页,不再按品类名自动判断)</span>
|
||||
<select className="input" value={active.webPage || ''} onChange={e => update(active.id, { webPage: e.target.value })}>
|
||||
<option value="">不指定(按产品品类自动归类)</option>
|
||||
{SITE_PAGE_GROUPS.map(([g, items]) => (
|
||||
<optgroup key={g} label={g}>
|
||||
{items.map(([k, zh, en]) => <option key={k} value={k}>{zh}|{en}</option>)}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
{active.webPage && <span style={{ fontSize: 12, color: 'var(--ink-soft)' }}>一个型号用了多个选了类目的模板时,会同时出现在这几个栏目。改完约 3 分钟后自动同步到网站。</span>}
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 6, alignItems: 'center', margin: '4px 0 12px' }}>
|
||||
<span className="field-label" style={{ margin: 0 }}>模板内容:</span>
|
||||
<button type="button" className={`btn btn-sm${active.kind === 'main' ? ' btn-primary' : ''}`} onClick={() => update(active.id, { kind: 'main' })}>主图({(active.mainImages || []).length})</button>
|
||||
|
|
@ -7683,6 +7695,15 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts,
|
|||
);
|
||||
}
|
||||
|
||||
// 网站栏目(key 和网站 src/lib/catalog.mjs、服务器 public-api.js 的 SITE_PAGE_KEYS 一致)
|
||||
const SITE_PAGE_GROUPS = [
|
||||
['UPS', [['mini', '迷你 DC UPS', 'Mini DC UPS'], ['offline', '后备式 / 在线互动式 UPS', 'Offline UPS'], ['online', '高频在线 UPS', 'Online UPS'], ['aio', '一体式锂电 UPS', 'All-in-one lithium UPS'], ['rack', '机架式 UPS', 'Rack-mount UPS'], ['modular', '模块化 UPS', 'Modular UPS'], ['industrial', '工频 UPS', 'Industrial UPS']]],
|
||||
['光伏储能', [['inverter', '光伏逆变器', 'Solar inverters'], ['homeess', '户用储能一体机', 'Home ESS'], ['ciess', '工商业储能柜', 'C&I ESS']]],
|
||||
['电池', [['wall', '壁挂式锂电池', 'Wall-mount lithium'], ['floor', '落地式锂电池', 'Floor-standing lithium'], ['rackbatt', '机架式锂电池', 'Rack lithium'], ['hvcab', '高压电池柜', 'HV battery cabinet'], ['pbr', '锂电替换铅酸', 'Lead-acid replacement'], ['vrla', '12V 铅酸电池', '12V VRLA'], ['vrla2', '2V 铅酸单体', '2V VRLA cells'], ['cab', '电池柜', 'Battery cabinets']]],
|
||||
['机房', [['pac', '精密空调', 'Precision AC'], ['idm', '微模块数据中心', 'Micro data center'], ['dem', '动环监控系统', 'DCIM monitoring']]],
|
||||
];
|
||||
const sitePageLabel = (k) => { for (const [, items] of SITE_PAGE_GROUPS) { const x = items.find(i => i[0] === k); if (x) return x[1]; } return ''; };
|
||||
|
||||
// 模板管理(产品管理 → 模板管理):编辑模板 + 给模板勾选使用它的产品(一个系列一次选完,不用逐个产品去编辑)
|
||||
function TemplateCenter({ templates, setTemplates, products, setProducts, onNotify, savedTick }) {
|
||||
// 每个模板是否已经同步到网站:synced / changed / new;deleted = 后台删了、网站上还在
|
||||
|
|
|
|||
Loading…
Reference in New Issue