From 5a9798d8773797e78c55e3c2ed70241f62bea573 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 18 Nov 2026 17:18:21 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-11-18 17:17:55 --- App.jsx | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/App.jsx b/App.jsx index 8a39a04..0a404f6 100644 --- a/App.jsx +++ b/App.jsx @@ -2463,6 +2463,10 @@ const Styles = () => ( .brand-vis { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; font-weight: 500; } .brand-vis button { display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; font-size: 11px; padding: 1px 8px; cursor: pointer; color: var(--ink-soft); } .brand-vis button.on { background: var(--ink); color: #fff; } + .tpl-link { border: 1px solid transparent; cursor: pointer; font-family: inherit; line-height: 1.5; transition: border-color .15s, background .15s; } + .tpl-link:hover { border-color: #8fb3dd; background: #d3e3f5; } + .tpl-link .tpl-go { opacity: .55; margin-left: 1px; } + .tpl-link:hover .tpl-go { opacity: 1; } .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; } @@ -2861,6 +2865,7 @@ function MainApp({ username, onLogout }) { // 推送消息里的链接 /?visit=预约id → 打开"网站管理 → 预约拜访"并定位到这条 const visitLinkId = useMemo(() => { try { return new URLSearchParams(window.location.search).get('visit') || null; } catch (e) { return null; } }, []); const serviceLinkId = useMemo(() => { try { return new URLSearchParams(window.location.search).get('service') || null; } catch (e) { return null; } }, []); + const [tplFocus, setTplFocus] = useState(null); // 从产品详情点模板徽章跳到模板管理 const [view, setView] = useState(chatLinkSid ? 'chat' : visitLinkId ? 'webvisits' : serviceLinkId ? 'webservice' : 'monitor'); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); @@ -4613,6 +4618,7 @@ function MainApp({ username, onLogout }) { backPanelTemplates={backPanelTemplates} webDetailTemplates={webDetailTemplates} onPatch={(patch) => setProducts(list => list.map(x => (x.id === selectedProduct.id ? { ...x, ...patch } : x)))} onNotify={notify} + onOpenTemplate={(id) => { setTplFocus({ id, n: Date.now() }); setView('templates'); }} /> ) : (
选择左侧产品查看详情,或新建一个产品档案
@@ -4634,7 +4640,7 @@ function MainApp({ username, onLogout }) { )} {view === 'templates' && ( + products={products} setProducts={setProducts} onNotify={notify} savedTick={tplSavedTick} focus={tplFocus} /> )} {view === 'chat' && ( t.id === focus.id)) ? focus.id : (templates[0] ? templates[0].id : null)); const active = templates.find(t => t.id === activeId) || null; const usage = (id) => products.filter(p => Array.isArray(p.webDetailTemplateIds) && p.webDetailTemplateIds.includes(id)).length; const update = (id, patch) => setTemplates(list => list.map(t => (t.id === id ? { ...t, ...patch } : t))); // 搜索:模板名称,或者用了这个模板的产品型号(忽略大小写、空格、斜杠和横线) const [tplQ, setTplQ] = useState(''); + // 从产品详情点模板徽章跳过来:选中该模板并滚动到它 + useEffect(() => { + if (!focus || !templates.some(t => t.id === focus.id)) return; + setActiveId(focus.id); setTplQ(''); + const tm = setTimeout(() => { const el = document.querySelector(`[data-tpl-id="${focus.id}"]`); if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 120); + return () => clearTimeout(tm); + }, [focus && focus.n]); // eslint-disable-line react-hooks/exhaustive-deps const norm = (x) => String(x || '').toLowerCase().replace(/[\s/\-_]+/g, ''); 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))) : []); @@ -9524,7 +9537,7 @@ function DetailTemplateManager({ templates, setTemplates, products, setProducts,
{shownTemplates.map(t => ( -
每个模板可以包含三项内容,分开上传、互不重复:主图(同系列共用,接在产品自己的主图后面)、详情图片(工厂、认证、包装等,显示在详情图下方)、HTML(系列参数表)。选中一个模板后,在下面"使用这个模板的产品"里勾选型号。模板改完自动保存,停止修改约 3 分钟后自动同步到网站,不用手动更新。产品编辑页"网站发布"里也能单独添加或移除,两边是同一份数据。
- +
); @@ -11683,7 +11696,7 @@ function BrochureBulkUpload({ products, setProducts, onNotify }) { ); } -function ProductDetail({ product: p, onEdit, onDelete, onCopy, copying, categories, exportLang, onExportLangChange, exportLabels, exportLoading, onExportPdf, exportPdfBusy, backPanelTemplates, webDetailTemplates, onPatch, onNotify }) { +function ProductDetail({ product: p, onEdit, onDelete, onCopy, copying, categories, exportLang, onExportLangChange, exportLabels, exportLoading, onExportPdf, exportPdfBusy, backPanelTemplates, webDetailTemplates, onPatch, onNotify, onOpenTemplate }) { const usedTemplates = (Array.isArray(p.webDetailTemplateIds) ? p.webDetailTemplateIds : []).map(id => (webDetailTemplates || []).find(t => t.id === id)).filter(Boolean); const cat = (categories || []).find(c => c.id === p.category); const showMachineVariant = isUpsCategory(cat) && p.machineVariant; @@ -11696,7 +11709,7 @@ function ProductDetail({ product: p, onEdit, onDelete, onCopy, copying, categori <>
-
{p.name || '(未命名)'}{p.publishToWeb && 已发布到网站}{usedTemplates.map(t => 1 ? ' bad' : ''}`} title={usedTemplates.length > 1 ? '异常:一个型号只能关联一个模板' : '使用的模板(模板管理里可修改)'}>{t.name || '未命名模板'})}{usedTemplates.length > 1 && ⚠ 异常:关联了 {usedTemplates.length} 个模板}
+
{p.name || '(未命名)'}{p.publishToWeb && 已发布到网站}{usedTemplates.map(t => )}{usedTemplates.length > 1 && ⚠ 异常:关联了 {usedTemplates.length} 个模板}
{p.publishToWeb && }