From 5e116bf01b21e844ab04fb1f2b775a06fd45e5a3 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 12 Nov 2026 17:02:45 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-11-12 17:02:24 --- App.jsx | 91 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 29 deletions(-) diff --git a/App.jsx b/App.jsx index 134bad8..26f93e0 100644 --- a/App.jsx +++ b/App.jsx @@ -2184,6 +2184,12 @@ const Styles = () => ( .web-thumb.tall img { object-fit: cover; object-position: top; } .web-thumb-add { width: 88px; height: 88px; border: 1px dashed var(--line); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; color: var(--ink-soft); cursor: pointer; } .web-badge { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; font-size: 11px; font-weight: 500; color: #1d7a3e; background: #dcf1e2; padding: 2px 8px; border-radius: 99px; } + .tpl-badge.bad { color: #b42318 !important; background: #fde4e1 !important; font-weight: 600; } + .tpl-warn { font-size: 12.5px; color: #b42318; background: #fef1ef; border: 1px solid #f5b5ac; border-radius: 8px; padding: 9px 12px; line-height: 1.6; } + .tpl-warn-link { background: none; border: 0; padding: 0; color: #b42318; text-decoration: underline; cursor: pointer; font: inherit; } + .btn.tpl-btn-bad { border-color: #d92d20 !important; color: #b42318 !important; background: #fef1ef !important; } + .btn.btn-primary.tpl-btn-bad { background: #d92d20 !important; color: #fff !important; } + .tpl-chip.bad { border-color: #d92d20 !important; background: #fef1ef !important; } .tpl-badge { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-size: 11px; font-weight: 500; color: #1e4f8a; background: #e1ecf8; padding: 2px 8px; border-radius: 99px; white-space: nowrap; } .web-tier-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; } .web-tier-preview div { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font-variant-numeric: tabular-nums; } @@ -4266,7 +4272,7 @@ function MainApp({ username, onLogout }) {
{ setProductDraft(null); setSelectedProductId(p.id); }}>
-
{p.name || '(未命名)'}
+
{p.name || '(未命名)'}{tplConflict(p, webDetailTemplates) && ⚠ 多个模板}
{categoryBreadcrumb(p, productCategories)}{p.brand ? ` · ${p.brand}` : ''}
@@ -7560,21 +7566,20 @@ function SiteNewsItem({ n, update, remove }) { ); } +// 一个型号只能关联一个模板:关联了多个(还存在的)模板的产品算异常,界面上标红 +const tplIdsOf = (p, templates) => (Array.isArray(p && p.webDetailTemplateIds) ? p.webDetailTemplateIds : []).filter(id => !templates || templates.some(t => t.id === id)); +const tplConflict = (p, templates) => tplIdsOf(p, templates).length > 1; + function DetailTemplatePicker({ draft, set, templates, setTemplates, products, onNotify }) { const [managerOpen, setManagerOpen] = useState(false); const selected = (Array.isArray(draft.webDetailTemplateIds) ? draft.webDetailTemplateIds : []).filter(id => templates.some(t => t.id === id)); - const toggle = (id) => set({ webDetailTemplateIds: selected.includes(id) ? selected.filter(x => x !== id) : [...selected, id] }); - const move = (idx, dir) => { - const j = idx + dir; - if (j < 0 || j >= selected.length) return; - const next = [...selected]; [next[idx], next[j]] = [next[j], next[idx]]; - set({ webDetailTemplateIds: next }); - }; + // 单选:点一个模板就换成这个模板;再点已选的就移除 + const toggle = (id) => set({ webDetailTemplateIds: selected.includes(id) ? selected.filter(x => x !== id) : [id] }); const byId = (id) => templates.find(t => t.id === id); return (
- 模板(主图模板接在网站主图后面;详情图片组、HTML 参数表显示在"产品详情图"下方;点一下添加,再点一下移除) + 模板(一个型号只能关联一个模板;点一下选中,再点一下移除) {templates.length === 0 ? (
还没有模板。可以把公司介绍、工厂、认证、包装物流这类每个产品都要放的图片做成模板。
) : ( @@ -7583,7 +7588,7 @@ function DetailTemplatePicker({ draft, set, templates, setTemplates, products, o const on = selected.includes(t.id); const imgs = [...(t.mainImages || []), ...(t.images || [])]; return ( - @@ -7592,22 +7597,15 @@ function DetailTemplatePicker({ draft, set, templates, setTemplates, products, o
)} {selected.length > 1 && ( -
- 显示顺序: - {selected.map((id, i) => ( - - {i + 1}. {(byId(id) || {}).name} - - - - ))} +
+ ⚠ 异常:这个型号关联了 {selected.length} 个模板({selected.map(id => (byId(id) || {}).name || '未命名模板').join('、')}),只能保留一个。点要去掉的模板移除。
)}
{managerOpen && ( setManagerOpen(false)} - onCreated={(id) => set({ webDetailTemplateIds: [...selected, id] })} /> + onCreated={(id) => set({ webDetailTemplateIds: [id] })} /> )}
); @@ -7624,6 +7622,10 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts, const tq = norm(tplQ); const modelHits = (t) => (tq ? products.filter(p => Array.isArray(p.webDetailTemplateIds) && p.webDetailTemplateIds.includes(t.id) && (norm(p.name).includes(tq) || norm(p.model).includes(tq))) : []); const shownTemplates = tq ? templates.filter(t => norm(t.name).includes(tq) || modelHits(t).length) : templates; + // 异常:同一个型号出现在多个模板里 + const conflicts = products.filter(p => tplConflict(p, templates)); + const tplHasConflict = (id) => conflicts.some(p => p.webDetailTemplateIds.includes(id)); + const tplName = (id) => ((templates.find(t => t.id === id) || {}).name || '未命名模板'); function addTemplate() { const t = { id: newTemplateId(), name: `新模板 ${templates.length + 1}`, kind: 'images', images: [] }; @@ -7677,6 +7679,23 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts, const body = (
+ {conflicts.length > 0 && ( +
+ ⚠ 异常:{conflicts.length} 个型号同时出现在多个模板里(一个型号只能关联一个模板) +
+ {conflicts.slice(0, 12).map(p => ( +
+ {p.name || p.model || '未命名'}: + {tplIdsOf(p, templates).map((id, i) => ( + {i ? '、' : ''} + ))} +
+ ))} + {conflicts.length > 12 &&
…还有 {conflicts.length - 12} 个,搜索型号可以找到
} +
+
点模板名进入该模板,在"使用这个模板的产品"里取消多余的型号(标红的就是)。
+
+ )}
@@ -7687,9 +7706,9 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts,
{shownTemplates.map(t => ( - ); })} @@ -9789,7 +9822,7 @@ function ProductDetail({ product: p, onEdit, onDelete, onCopy, copying, categori <>
-
{p.name || '(未命名)'}{p.publishToWeb && 已发布到网站}{usedTemplates.map(t => {t.name || '未命名模板'})}
+
{p.name || '(未命名)'}{p.publishToWeb && 已发布到网站}{usedTemplates.map(t => 1 ? ' bad' : ''}`} title={usedTemplates.length > 1 ? '异常:一个型号只能关联一个模板' : '使用的模板(模板管理里可修改)'}>{t.name || '未命名模板'})}{usedTemplates.length > 1 && ⚠ 异常:关联了 {usedTemplates.length} 个模板}
{p.publishToWeb && }