From 877113e211fc5ef066e93389e2310962046e3a85 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 27 Oct 2026 15:55:46 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-10-27 15:55:43 --- App.jsx | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/App.jsx b/App.jsx index 3dcefb5..6165be7 100644 --- a/App.jsx +++ b/App.jsx @@ -6204,7 +6204,9 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts, try { const images = await copyFiles(t.images); const mainImages = await copyFiles(t.mainImages); - const copy = { id, name: `${t.name || '模板'} 副本`, kind: t.kind || 'images', images, mainImages, html: t.html || '' }; + // 详情图片里的 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: t.html || '' }; setTemplates(list => { const i = list.findIndex(x => x.id === t.id); const next = [...list]; @@ -6242,7 +6244,7 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts,
模板内容: - +
主图、详情图片、HTML 分开上传、分开保存,互不影响;一个模板可以只填其中一项,也可以三项都填(比如一个系列一个模板)。
@@ -6265,6 +6267,7 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts, onNotify={onNotify} field="images" max={WEB_MAX_TEMPLATE_IMAGES} tall label={`模板图片(最多${WEB_MAX_TEMPLATE_IMAGES}张,建议宽1200像素,按顺序从上到下拼接显示,拖动可调整顺序)`} /> )} + {(active.kind || 'images') === 'images' && update(active.id, patch)} />} {setProducts && }
{usage(active.id) ? `${usage(active.id)} 个产品在用这个模板;修改后点"更新到网站"生效` : '还没有产品使用这个模板'} @@ -6446,11 +6449,66 @@ function TemplateMainCoverPicker({ tpl, products, update }) { ); } +// 详情图片里的 HTML 片段:原样显示(保留自己的排版、颜色、字体),穿插在详情图片之间。 +// 存在模板的 detailHtml:[{ id, html, pos }],pos = 排在第几张图后面(0 = 最上面)。网站上放在隔离的 iframe 里,英文以外的语言自动翻译文字。 +function DetailHtmlBlocks({ tpl, update }) { + const blocks = Array.isArray(tpl.detailHtml) ? tpl.detailHtml : []; + const n = (tpl.images || []).length; + const [preview, setPreview] = useState(''); + const set = (list) => update({ detailHtml: list }); + const patch = (id, p) => set(blocks.map(b => (b.id === id ? { ...b, ...p } : b))); + const add = () => set([...blocks, { id: 'dh_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6), html: '', pos: n }]); + const posLabel = (i) => (i === 0 ? '最上面(第 1 张图前面)' : i >= n ? `最下面(第 ${n} 张图后面)` : `第 ${i} 张图后面`); + async function pickFile(id, file) { + if (!file) return; + const text = await file.text(); + patch(id, { html: text }); + } + return ( +
+
+ 详情 HTML 片段({blocks.length}) + +
+
+ 粘贴 HTML 代码或上传 .html 文件(比如用 Gemini 做的图文详情页),网站上原样显示:保留自己的排版、颜色和字体,像一张长图一样插在详情图片之间。英文写的文字会自动翻译成西语、俄语。 +
+ {blocks.map((b, k) => { + const len = String(b.html || '').trim().length; + return ( +
+
+ 片段 {k + 1} + 位置 + + + + + {len ? `${len.toLocaleString()} 字符` : '空'} +
+