Update App.jsx via upload script - 2026-10-16 15:49:41

This commit is contained in:
mike 2026-10-16 15:49:49 +08:00
parent 0b2efc532e
commit 1707deb9b3
1 changed files with 228 additions and 12 deletions

240
App.jsx
View File

@ -245,7 +245,7 @@ const COUNTRIES = [
const COUNTRY_BY_NAME = Object.fromEntries(COUNTRIES.map(c => [c.name, c])); const COUNTRY_BY_NAME = Object.fromEntries(COUNTRIES.map(c => [c.name, c]));
const STORAGE_KEYS = { customers: 'crm:customers', products: 'crm:products', quotes: 'crm:quotes', sellerProfiles: 'crm:sellerProfiles', certifications: 'crm:certifications', productCategories: 'crm:productCategories', packingLists: 'crm:packingLists', catalogDocs: 'crm:catalogDocs', jmsLines: 'crm:jmsLines', backPanelTemplates: 'crm:backPanelTemplates', suppliers: 'crm:suppliers', webDetailTemplates: 'crm:webDetailTemplates' }; const STORAGE_KEYS = { customers: 'crm:customers', products: 'crm:products', quotes: 'crm:quotes', sellerProfiles: 'crm:sellerProfiles', certifications: 'crm:certifications', productCategories: 'crm:productCategories', packingLists: 'crm:packingLists', catalogDocs: 'crm:catalogDocs', jmsLines: 'crm:jmsLines', backPanelTemplates: 'crm:backPanelTemplates', suppliers: 'crm:suppliers', webDetailTemplates: 'crm:webDetailTemplates', webAssets: 'crm:webAssets', webNews: 'crm:webNews' };
const blankCustomer = () => ({ const blankCustomer = () => ({
id: 'c_' + Date.now() + '_' + Math.random().toString(36).slice(2, 7), id: 'c_' + Date.now() + '_' + Math.random().toString(36).slice(2, 7),
@ -1598,7 +1598,17 @@ async function loadAll() {
const wdt = await storageGet(STORAGE_KEYS.webDetailTemplates); const wdt = await storageGet(STORAGE_KEYS.webDetailTemplates);
if (wdt && wdt.value) webDetailTemplates = JSON.parse(wdt.value); if (wdt && wdt.value) webDetailTemplates = JSON.parse(wdt.value);
} catch (e) {} } catch (e) {}
return { customers, products, quotes, sellerProfiles, certifications, productCategories, packingLists, catalogDocs, jmsLines, backPanelTemplates, suppliers, webDetailTemplates }; let webAssets = {};
try {
const wa = await storageGet(STORAGE_KEYS.webAssets);
if (wa && wa.value) webAssets = JSON.parse(wa.value) || {};
} catch (e) {}
let webNews = [];
try {
const wn = await storageGet(STORAGE_KEYS.webNews);
if (wn && wn.value) webNews = JSON.parse(wn.value) || [];
} catch (e) {}
return { customers, products, quotes, sellerProfiles, certifications, productCategories, packingLists, catalogDocs, jmsLines, backPanelTemplates, suppliers, webDetailTemplates, webAssets, webNews };
} }
/* -------------------------------- styles -------------------------------- */ /* -------------------------------- styles -------------------------------- */
@ -1898,6 +1908,15 @@ const Styles = () => (
.web-thumb .cover-tag { position: absolute; left: 4px; top: 4px; font-size: 10.5px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 6px; border-radius: 4px; } .web-thumb .cover-tag { position: absolute; left: 4px; top: 4px; font-size: 10.5px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 6px; border-radius: 4px; }
.web-thumb button { position: absolute; right: 3px; top: 3px; border: 0; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; } .web-thumb button { position: absolute; right: 3px; top: 3px; border: 0; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.web-thumb.tall, .web-thumb-add.tall { height: 132px; } .web-thumb.tall, .web-thumb-add.tall { height: 132px; }
.site-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.site-slot { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 6px; align-content: start; }
.site-slot.done { border-style: solid; border-color: var(--led-green); }
.site-slot-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.site-slot-head span { font-size: 12px; color: #a5480b; }
.site-slot-head span.ok { color: var(--led-green); }
.site-slot-meta { font-size: 12px; color: var(--ink-soft); }
.site-slot .field { margin: 0; }
.site-news { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; }
.tpl-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; font-size: 12.5px; color: var(--ink); } .tpl-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; font-size: 12.5px; color: var(--ink); }
.tpl-chip img, .tpl-chip-noimg { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.05); } .tpl-chip img, .tpl-chip-noimg { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.05); }
.tpl-chip em { font-style: normal; color: var(--ink-soft); margin-left: 6px; } .tpl-chip em { font-style: normal; color: var(--ink-soft); margin-left: 6px; }
@ -2157,6 +2176,7 @@ const NAV_GROUPS = [
{ label: '产品', items: [ { label: '产品', items: [
{ id: 'groups', label: '产品分组', icon: FolderTree }, { id: 'groups', label: '产品分组', icon: FolderTree },
{ id: 'products', label: '产品管理', icon: Package }, { id: 'products', label: '产品管理', icon: Package },
{ id: 'website', label: '网站管理', icon: Globe },
{ id: 'backpanel', label: '后板图模板', icon: Settings2 }, { id: 'backpanel', label: '后板图模板', icon: Settings2 },
] }, ] },
]; ];
@ -2351,7 +2371,9 @@ function MainApp({ username, onLogout }) {
const [catalogCategoryFilter, setCatalogCategoryFilter] = useState('all'); const [catalogCategoryFilter, setCatalogCategoryFilter] = useState('all');
const [jmsLines, setJmsLines] = useState([]); const [jmsLines, setJmsLines] = useState([]);
const [backPanelTemplates, setBackPanelTemplates] = useState([]); const [backPanelTemplates, setBackPanelTemplates] = useState([]);
const [webDetailTemplates, setWebDetailTemplates] = useState([]); // 网站详情模板:一组公共图片(工厂、认证、包装等),产品一键引用 const [webDetailTemplates, setWebDetailTemplates] = useState([]);
const [webAssets, setWebAssets] = useState({}); // 网站管理:图片位 → 文件名
const [webNews, setWebNews] = useState([]); // 网站管理:近期动态 // 网站详情模板:一组公共图片(工厂、认证、包装等),产品一键引用
useEffect(() => { useEffect(() => {
getAiConfig().then((res) => { getAiConfig().then((res) => {
@ -2381,6 +2403,8 @@ function MainApp({ username, onLogout }) {
setBackPanelTemplates(data.backPanelTemplates || []); setBackPanelTemplates(data.backPanelTemplates || []);
setSuppliers(data.suppliers || []); setSuppliers(data.suppliers || []);
setWebDetailTemplates(data.webDetailTemplates || []); setWebDetailTemplates(data.webDetailTemplates || []);
setWebAssets(data.webAssets || {});
setWebNews(Array.isArray(data.webNews) ? data.webNews : []);
setLoaded(true); setLoaded(true);
})(); })();
}, []); }, []);
@ -2396,6 +2420,8 @@ function MainApp({ username, onLogout }) {
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.backPanelTemplates, JSON.stringify(backPanelTemplates)).catch(() => {}); }, [backPanelTemplates, loaded]); useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.backPanelTemplates, JSON.stringify(backPanelTemplates)).catch(() => {}); }, [backPanelTemplates, loaded]);
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.suppliers, JSON.stringify(suppliers)).catch(() => {}); }, [suppliers, loaded]); useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.suppliers, JSON.stringify(suppliers)).catch(() => {}); }, [suppliers, loaded]);
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.webDetailTemplates, JSON.stringify(webDetailTemplates)).catch(() => {}); }, [webDetailTemplates, loaded]); useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.webDetailTemplates, JSON.stringify(webDetailTemplates)).catch(() => {}); }, [webDetailTemplates, loaded]);
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.webAssets, JSON.stringify(webAssets)).catch(() => {}); }, [webAssets, loaded]);
useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.webNews, JSON.stringify(webNews)).catch(() => {}); }, [webNews, loaded]);
function notify(msg) { setToast(msg); setTimeout(() => setToast(''), 2200); } function notify(msg) { setToast(msg); setTimeout(() => setToast(''), 2200); }
@ -3806,6 +3832,15 @@ function MainApp({ username, onLogout }) {
</div> </div>
)} )}
{view === 'website' && (
<WebsiteManager
assets={webAssets} setAssets={setWebAssets}
news={webNews} setNews={setWebNews}
templates={webDetailTemplates} setTemplates={setWebDetailTemplates}
products={products} onNotify={notify}
/>
)}
{view === 'backpanel' && ( {view === 'backpanel' && (
<BackPanelStudio templates={backPanelTemplates} setTemplates={setBackPanelTemplates} onNotify={notify} /> <BackPanelStudio templates={backPanelTemplates} setTemplates={setBackPanelTemplates} onNotify={notify} />
)} )}
@ -5656,6 +5691,182 @@ function WebImageList({ draft, set, onNotify, field, max, label, cover, tall })
const WEB_MAX_TEMPLATE_IMAGES = 10; const WEB_MAX_TEMPLATE_IMAGES = 10;
const newTemplateId = () => 'tpl_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 7); const newTemplateId = () => 'tpl_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 7);
/* ------------------------------ 网站管理 ------------------------------ */
// 网站上非产品内容:图片位(About 等页面的照片)、详情模板、近期动态。
// 图片位的 id 必须和网站代码 src/lib/about-i18n.mjs 里用到的一致;以后网站新增图片位,在这里加一行。
const SITE_ASSET_DIR = 'site_assets';
const SITE_SLOT_GROUPS = [
{ page: 'About Us 页面', url: '/en/about/', groups: [
{ title: '首屏', slots: [{ id: 'hero', name: '工厂外景', hint: '首屏右侧大图', size: '1600×1300 横图' }] },
{ title: '公司介绍', slots: [
{ id: 'line', name: '生产线', hint: '公司介绍右侧大图', size: '1200×900 横图' },
{ id: 'rd', name: '研发 / 工程师', hint: '公司介绍右上小图', size: '1200×900 横图' },
{ id: 'warehouse', name: '仓库 / 出货', hint: '公司介绍右下小图', size: '1200×900 横图' },
] },
{ title: '产品线(每个产品家族一张,未上传时显示图标)', slots: [
{ id: 'fam_dc', name: '直流 UPS(Mini UPS)', size: '1200×750 横图' },
{ id: 'fam_backup', name: '后备式 UPS', size: '1200×750 横图' },
{ id: 'fam_hf', name: '高频在线式 UPS', size: '1200×750 横图' },
{ id: 'fam_if', name: '工频 UPS', size: '1200×750 横图' },
{ id: 'fam_modular', name: '模块化 UPS', size: '1200×750 横图' },
{ id: 'fam_rack', name: '机架式 UPS', size: '1200×750 横图' },
{ id: 'fam_inverter', name: '混合逆变器', size: '1200×750 横图' },
{ id: 'fam_battery', name: '储能电池', size: '1200×750 横图' },
] },
{ title: '工厂与质量(4 张都没上传时这一排不显示)', slots: [
{ id: 'smt', name: 'SMT 贴片车间', size: '1200×900 横图' },
{ id: 'assembly', name: '组装线', size: '1200×900 横图' },
{ id: 'aging', name: '老化测试', size: '1200×900 横图' },
{ id: 'qc', name: '质检实验室', size: '1200×900 横图' },
] },
{ title: '证书与荣誉(未上传的证书图不显示)', slots: [
{ id: 'cert_iso9001', name: 'ISO 9001', size: '竖图 3:4' },
{ id: 'cert_iso14001', name: 'ISO 14001', size: '竖图 3:4' },
{ id: 'cert_iso45001', name: 'ISO 45001', size: '竖图 3:4' },
{ id: 'cert_cqc', name: 'CQC 节能认证', size: '竖图 3:4' },
{ id: 'cert_tlc', name: '泰尔认证', size: '竖图 3:4' },
{ id: 'cert_hitech', name: '高新技术企业', size: '竖图 3:4' },
] },
] },
];
const SITE_PUBLIC_BASE = 'https://ups-china.com';
function WebsiteManager({ assets, setAssets, news, setNews, templates, setTemplates, products, onNotify }) {
const [tab, setTab] = useState('assets');
return (
<div className="panel">
<div className="panel-header" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 10, flexWrap: 'wrap' }}>
<div style={{ display: 'flex', gap: 6, flexWrap: 'wrap' }}>
{[['assets', '图片素材'], ['templates', '详情模板'], ['news', '近期动态']].map(([k, label]) => (
<button key={k} type="button" className={`btn btn-sm${tab === k ? ' btn-primary' : ''}`} onClick={() => setTab(k)}>{label}</button>
))}
</div>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}><SiteDeployButton /></div>
</div>
<div className="panel-body" style={{ padding: 18 }}>
{tab === 'assets' && <SiteAssetsEditor assets={assets} setAssets={setAssets} onNotify={onNotify} />}
{tab === 'templates' && (
<>
<div className="disclaimer" style={{ marginBottom: 14 }}>详情模板是一组公共图片(工厂、认证、包装等),在产品编辑页"网站发布"里一键添加到产品,显示在该产品详情图下方。这里和产品编辑页里的"管理模板"是同一份数据。</div>
<DetailTemplateManager inline templates={templates} setTemplates={setTemplates} products={products} onNotify={onNotify} />
</>
)}
{tab === 'news' && <SiteNewsEditor news={news} setNews={setNews} />}
</div>
</div>
);
}
function SiteAssetsEditor({ assets, setAssets, onNotify }) {
const setSlot = (id, list) => setAssets(a => {
const next = { ...(a || {}) };
if (list.length) next[id] = list; else delete next[id];
return next;
});
return (
<div style={{ display: 'grid', gap: 22 }}>
<div className="disclaimer">在下面对应的位置上传图片,然后点右上角"更新到网站"。网站构建时会自动压缩图片;没上传的位置在网站上自动隐藏或显示图标,不会出现空白。建议照片宽度不小于 1200 像素。</div>
{SITE_SLOT_GROUPS.map(pg => {
const all = pg.groups.flatMap(g => g.slots);
const done = all.filter(sl => (assets[sl.id] || []).length).length;
return (
<div key={pg.page} style={{ display: 'grid', gap: 16 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 10, flexWrap: 'wrap' }}>
<div style={{ fontWeight: 700, fontSize: 15 }}>{pg.page} <span style={{ fontWeight: 400, color: 'var(--ink-soft)', fontSize: 13 }}>已上传 {done} / {all.length}</span></div>
<a className="btn btn-sm" href={SITE_PUBLIC_BASE + pg.url} target="_blank" rel="noopener noreferrer"><Globe size={12} />打开网站页面</a>
</div>
{pg.groups.map(g => (
<div key={g.title} style={{ display: 'grid', gap: 10 }}>
<div style={{ fontSize: 13, fontWeight: 600, color: 'var(--ink-soft)' }}>{g.title}</div>
<div className="site-slots">
{g.slots.map(sl => {
const list = assets[sl.id] || [];
return (
<div key={sl.id} className={`site-slot${list.length ? ' done' : ''}`}>
<div className="site-slot-head">
<b>{sl.name}</b>
<span className={list.length ? 'ok' : ''}>{list.length ? '已上传' : '未上传'}</span>
</div>
<div className="site-slot-meta">{sl.hint ? `${sl.hint} · ` : ''}建议 {sl.size}</div>
<WebImageList
draft={{ id: SITE_ASSET_DIR, images: list }}
set={(patch) => setSlot(sl.id, patch.images || [])}
onNotify={onNotify} field="images" max={1} label="" />
</div>
);
})}
</div>
</div>
))}
</div>
);
})}
</div>
);
}
const newNewsId = () => 'n_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
function SiteNewsEditor({ news, setNews }) {
const list = Array.isArray(news) ? news : [];
const update = (id, patch) => setNews(l => l.map(n => (n.id === id ? { ...n, ...patch } : n)));
const add = () => setNews(l => [{ id: newNewsId(), date: new Date().toISOString().slice(0, 7), title: { en: '' }, text: { en: '' }, youtubeUrl: '' }, ...l]);
const remove = (n) => { if (window.confirm(`删除动态"${(n.title && n.title.en) || '未命名'}"?`)) setNews(l => l.filter(x => x.id !== n.id)); };
const sorted = [...list].sort((a, b) => String(b.date || '').localeCompare(String(a.date || '')));
return (
<div style={{ display: 'grid', gap: 14 }}>
<div className="disclaimer">
显示在 About 页面"近期动态",按日期从新到旧排列。标题和说明只需写英文,西语、俄语在更新网站时自动翻译(也可以展开手动填写)。可以附一个 YouTube 视频链接,网站上显示视频封面,点击播放。
{list.length === 0 && <><br /><b>列表为空时,网站显示官网的 3 条默认动态。</b>添加第一条后,网站就只显示这里的内容。</>}
</div>
<div><button type="button" className="btn btn-primary btn-sm" onClick={add}><Plus size={12} />添加动态</button></div>
{sorted.map(n => <SiteNewsItem key={n.id} n={n} update={update} remove={remove} />)}
</div>
);
}
function SiteNewsItem({ n, update, remove }) {
const [showManual, setShowManual] = useState(!!((n.title && (n.title.es || n.title.ru)) || (n.text && (n.text.es || n.text.ru))));
const yt = youtubeIdOf(n.youtubeUrl);
const setT = (field, lang, v) => update(n.id, { [field]: { ...(n[field] || {}), [lang]: v } });
return (
<div className="site-news">
<div style={{ display: 'grid', gridTemplateColumns: '140px minmax(0,1fr)', gap: 12 }}>
<div className="field"><span className="field-label">日期(年-月)</span>
<input className="input" type="month" value={n.date || ''} onChange={e => update(n.id, { date: e.target.value })} />
</div>
<div className="field"><span className="field-label">标题(英文)</span>
<input className="input" value={(n.title && n.title.en) || ''} onChange={e => setT('title', 'en', e.target.value)} placeholder="如:New 60W PoE mini UPS launched" />
</div>
</div>
<div className="field"><span className="field-label">说明(英文,可选)</span>
<textarea className="textarea" rows={2} style={{ fontFamily: 'inherit', fontSize: 13 }} value={(n.text && n.text.en) || ''} onChange={e => setT('text', 'en', e.target.value)} placeholder="一两句话介绍这条动态" />
</div>
<div className="field"><span className="field-label">YouTube 视频链接(可选)</span>
<input className="input" value={n.youtubeUrl || ''} onChange={e => update(n.id, { youtubeUrl: e.target.value })} placeholder="如:https://www.youtube.com/watch?v=xxxxxxxxxxx" />
{n.youtubeUrl && (
<span style={{ fontSize: 12, color: yt ? '#1d7a3e' : '#a5480b', display: 'flex', alignItems: 'center', gap: 8 }}>
{yt ? <><img src={`https://i.ytimg.com/vi/${yt}/mqdefault.jpg`} alt="" style={{ width: 96, borderRadius: 4 }} />✓ 已识别视频</> : '没能识别出视频ID,请粘贴完整的 YouTube 链接'}
</span>
)}
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 10, flexWrap: 'wrap' }}>
<button type="button" className="btn btn-sm btn-ghost" onClick={() => setShowManual(v => !v)}>{showManual ? '收起手动译文' : '手动填写西语 / 俄语(可选)'}</button>
<button type="button" className="btn btn-sm btn-danger" onClick={() => remove(n)}><Trash2 size={12} />删除</button>
</div>
{showManual && (
<div style={{ display: 'grid', gap: 10 }}>
{[['es', '西语'], ['ru', '俄语']].map(([l, name]) => (
<div key={l} style={{ display: 'grid', gap: 6 }}>
<input className="input" value={(n.title && n.title[l]) || ''} onChange={e => setT('title', l, e.target.value)} placeholder={`${name}标题(留空则自动翻译)`} />
<textarea className="textarea" rows={2} style={{ fontFamily: 'inherit', fontSize: 13 }} value={(n.text && n.text[l]) || ''} onChange={e => setT('text', l, e.target.value)} placeholder={`${name}说明(留空则自动翻译)`} />
</div>
))}
</div>
)}
</div>
);
}
function DetailTemplatePicker({ draft, set, templates, setTemplates, products, onNotify }) { function DetailTemplatePicker({ draft, set, templates, setTemplates, products, onNotify }) {
const [managerOpen, setManagerOpen] = useState(false); const [managerOpen, setManagerOpen] = useState(false);
const selected = (Array.isArray(draft.webDetailTemplateIds) ? draft.webDetailTemplateIds : []).filter(id => templates.some(t => t.id === id)); const selected = (Array.isArray(draft.webDetailTemplateIds) ? draft.webDetailTemplateIds : []).filter(id => templates.some(t => t.id === id));
@ -5709,7 +5920,7 @@ function DetailTemplatePicker({ draft, set, templates, setTemplates, products, o
); );
} }
function DetailTemplateManager({ templates, setTemplates, products, onNotify, onClose, onCreated }) { function DetailTemplateManager({ templates, setTemplates, products, onNotify, onClose, onCreated, inline }) {
const [activeId, setActiveId] = useState(templates[0] ? templates[0].id : null); const [activeId, setActiveId] = useState(templates[0] ? templates[0].id : null);
const active = templates.find(t => t.id === activeId) || 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 usage = (id) => products.filter(p => Array.isArray(p.webDetailTemplateIds) && p.webDetailTemplateIds.includes(id)).length;
@ -5729,13 +5940,7 @@ function DetailTemplateManager({ templates, setTemplates, products, onNotify, on
setActiveId(null); setActiveId(null);
} }
return ( const body = (
<div className="modal-overlay" onClick={onClose}>
<div className="modal-box" style={{ maxWidth: 820, width: '94vw' }} onClick={e => e.stopPropagation()}>
<div className="modal-head">
<div className="panel-title">详情模板管理</div>
<button className="btn btn-ghost btn-sm" onClick={onClose}><X size={14} /></button>
</div>
<div className="modal-body"> <div className="modal-body">
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, marginBottom: 14 }}> <div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, marginBottom: 14 }}>
{templates.map(t => ( {templates.map(t => (
@ -5765,6 +5970,17 @@ function DetailTemplateManager({ templates, setTemplates, products, onNotify, on
<div style={{ fontSize: 13, color: 'var(--ink-soft)' }}>点"新建模板"开始,或选择上面一个模板编辑。</div> <div style={{ fontSize: 13, color: 'var(--ink-soft)' }}>点"新建模板"开始,或选择上面一个模板编辑。</div>
)} )}
</div> </div>
);
// inline:在"网站管理 → 详情模板"里直接显示;否则是产品编辑页里的弹窗
if (inline) return body;
return (
<div className="modal-overlay" onClick={onClose}>
<div className="modal-box" style={{ maxWidth: 820, width: '94vw' }} onClick={e => e.stopPropagation()}>
<div className="modal-head">
<div className="panel-title">详情模板管理</div>
<button className="btn btn-ghost btn-sm" onClick={onClose}><X size={14} /></button>
</div>
{body}
<div className="modal-foot"><button className="btn btn-primary" onClick={onClose}>完成</button></div> <div className="modal-foot"><button className="btn btn-primary" onClick={onClose}>完成</button></div>
</div> </div>
</div> </div>
@ -5896,7 +6112,7 @@ function SiteDeployButton() {
const r = await fetch('/api/site/deploy', { method: 'POST' }); const r = await fetch('/api/site/deploy', { method: 'POST' });
const d = await r.json().catch(() => ({})); const d = await r.json().catch(() => ({}));
if (!r.ok) throw new Error(d.error || `HTTP ${r.status}`); if (!r.ok) throw new Error(d.error || `HTTP ${r.status}`);
setState('ok'); setMsg('已通知网站更新,约1分钟后生效'); setState('ok'); setMsg(d.note || '已通知网站更新,约1分钟后生效');
} catch (e) { } catch (e) {
setState('err'); setMsg(`更新失败:${e.message}`); setState('err'); setMsg(`更新失败:${e.message}`);
} }