diff --git a/App.jsx b/App.jsx index e501195..64b381c 100644 --- a/App.jsx +++ b/App.jsx @@ -245,7 +245,7 @@ const COUNTRIES = [ 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' }; +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 blankCustomer = () => ({ id: 'c_' + Date.now() + '_' + Math.random().toString(36).slice(2, 7), @@ -849,6 +849,7 @@ function upsertProductByName(list, product) { publishToWeb: product.publishToWeb ?? existing.publishToWeb, webImages: existing.webImages, webDetailImages: existing.webDetailImages, + webDetailTemplateIds: existing.webDetailTemplateIds, youtubeUrl: product.youtubeUrl ?? existing.youtubeUrl, webDescription: product.webDescription ?? existing.webDescription, webSale: product.webSale ?? existing.webSale, @@ -1034,6 +1035,7 @@ const blankProduct = () => ({ publishToWeb: false, // 是否发布到网站 webImages: [], // 网站主图文件名,最多6张,第一张为封面;为空时网站用 productImageFileName webDetailImages: [], // 网站产品详情图,最多20张,显示在规格表下方 + webDetailTemplateIds: [], // 引用的详情模板id,按顺序显示在详情图下方(模板改了,所有引用它的产品下次更新网站时一起变) youtubeUrl: '', // 网站产品视频(YouTube链接) webDescription: { en: '', es: '', ru: '' }, // 网站产品介绍:只需填英文,其他语言在网站构建时用DeepSeek自动翻译;es/ru填了就用手动译文 webSale: { mode: 'group', stock: '', minPrice: '', maxPrice: '' }, // 网站销售状态:group拼单(默认)/ stock现货;minPrice起订量单价、maxPrice 1000台单价(USD),中间按数量等差自动生成 @@ -1591,7 +1593,12 @@ async function loadAll() { const sup = await storageGet(STORAGE_KEYS.suppliers); if (sup && sup.value) suppliers = JSON.parse(sup.value); } catch (e) {} - return { customers, products, quotes, sellerProfiles, certifications, productCategories, packingLists, catalogDocs, jmsLines, backPanelTemplates, suppliers }; + let webDetailTemplates = []; + try { + const wdt = await storageGet(STORAGE_KEYS.webDetailTemplates); + if (wdt && wdt.value) webDetailTemplates = JSON.parse(wdt.value); + } catch (e) {} + return { customers, products, quotes, sellerProfiles, certifications, productCategories, packingLists, catalogDocs, jmsLines, backPanelTemplates, suppliers, webDetailTemplates }; } /* -------------------------------- styles -------------------------------- */ @@ -1891,6 +1898,10 @@ 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 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; } + .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 em { font-style: normal; color: var(--ink-soft); margin-left: 6px; } + .tpl-chip.on { border-color: var(--led-green); background: rgba(29,122,62,.08); font-weight: 600; } .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; } @@ -2340,6 +2351,7 @@ function MainApp({ username, onLogout }) { const [catalogCategoryFilter, setCatalogCategoryFilter] = useState('all'); const [jmsLines, setJmsLines] = useState([]); const [backPanelTemplates, setBackPanelTemplates] = useState([]); + const [webDetailTemplates, setWebDetailTemplates] = useState([]); // 网站详情模板:一组公共图片(工厂、认证、包装等),产品一键引用 useEffect(() => { getAiConfig().then((res) => { @@ -2368,6 +2380,7 @@ function MainApp({ username, onLogout }) { setJmsLines(data.jmsLines || []); setBackPanelTemplates(data.backPanelTemplates || []); setSuppliers(data.suppliers || []); + setWebDetailTemplates(data.webDetailTemplates || []); setLoaded(true); })(); }, []); @@ -2382,6 +2395,7 @@ function MainApp({ username, onLogout }) { useEffect(() => { if (loaded) storageSet(STORAGE_KEYS.jmsLines, JSON.stringify(jmsLines)).catch(() => {}); }, [jmsLines, 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.webDetailTemplates, JSON.stringify(webDetailTemplates)).catch(() => {}); }, [webDetailTemplates, loaded]); function notify(msg) { setToast(msg); setTimeout(() => setToast(''), 2200); } @@ -3774,7 +3788,8 @@ function MainApp({ username, onLogout }) {