diff --git a/App.jsx b/App.jsx index d3f1e28..13c3ae9 100644 --- a/App.jsx +++ b/App.jsx @@ -848,6 +848,7 @@ function upsertProductByName(list, product) { // 网站字段:AI导入的数据里没有这几项,沿用旧记录的;图片跟着旧记录的id目录走 publishToWeb: product.publishToWeb ?? existing.publishToWeb, webImages: existing.webImages, + webDetailImages: existing.webDetailImages, youtubeUrl: product.youtubeUrl ?? existing.youtubeUrl, webDescription: product.webDescription ?? existing.webDescription, webSale: product.webSale ?? existing.webSale, @@ -1032,6 +1033,7 @@ const blankProduct = () => ({ // —— 网站发布(public-api.js 只会对外输出这一组 + 规格字段,costPrice/notes 永远不输出)—— publishToWeb: false, // 是否发布到网站 webImages: [], // 网站主图文件名,最多6张,第一张为封面;为空时网站用 productImageFileName + webDetailImages: [], // 网站产品详情图,最多20张,显示在规格表下方 youtubeUrl: '', // 网站产品视频(YouTube链接) webDescription: { en: '', es: '', ru: '' }, // 网站产品介绍:只需填英文,其他语言在网站构建时用DeepSeek自动翻译;es/ru填了就用手动译文 webSale: { mode: 'stock', stock: '', minPrice: '', maxPrice: '' }, // 网站销售状态:stock现货 / group拼单;minPrice起订量单价、maxPrice 1000台单价(USD),中间按数量等差自动生成 @@ -1888,6 +1890,8 @@ const Styles = () => ( .web-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; } .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; } + .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; } .web-tier-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; } @@ -2766,7 +2770,7 @@ function MainApp({ username, onLogout }) { ...primary, id: 'p_' + Date.now() + '_' + i + '_' + Math.random().toString(36).slice(2, 7), name: n, - publishToWeb: false, webImages: [], // 网站图片存在原产品的目录下,复制出来的型号需要单独上传、单独发布 + publishToWeb: false, webImages: [], webDetailImages: [], // 网站图片存在原产品的目录下,复制出来的型号需要单独上传、单独发布 })); let working = products; let newCount = 0; @@ -5472,22 +5476,18 @@ function webTiers(sale) { } const WEB_MAX_IMAGES = 6; -function WebPublishSection({ draft, set, onNotify }) { - const images = Array.isArray(draft.webImages) ? draft.webImages : []; - const desc = draft.webDescription || {}; - const sale = draft.webSale || { mode: 'stock', stock: '', tiers: [] }; - const tiers = webTiers(sale); - const moq = webTierPoints(sale.mode).moq; - const [showManual, setShowManual] = useState(!!(desc.es || desc.ru)); +const WEB_MAX_DETAIL_IMAGES = 20; + +// 网站图片列表(主图、详情图共用):多选上传、拖动排序、删除 +function WebImageList({ draft, set, onNotify, field, max, label, cover, tall }) { + const images = Array.isArray(draft[field]) ? draft[field] : []; const [uploading, setUploading] = useState(false); const [dragIdx, setDragIdx] = useState(null); - const ytId = youtubeIdOf(draft.youtubeUrl); - const setSale = (patch) => set({ webSale: { ...sale, ...patch } }); async function handlePick(fileList) { const picked = Array.from(fileList || []); - const room = WEB_MAX_IMAGES - images.length; - if (picked.length > room && onNotify) onNotify(`网站主图最多${WEB_MAX_IMAGES}张,只上传了前${Math.max(room, 0)}张`); + const room = max - images.length; + if (picked.length > room && onNotify) onNotify(`最多${max}张,只上传了前${Math.max(room, 0)}张`); const files = picked.slice(0, Math.max(room, 0)); if (!files.length) return; setUploading(true); @@ -5500,25 +5500,65 @@ function WebPublishSection({ draft, set, onNotify }) { if (onNotify) onNotify(`${f.name} 上传失败,请重试`); } } - set({ webImages: [...images, ...added] }); + set({ [field]: [...images, ...added] }); setUploading(false); } async function handleRemove(idx) { const f = images[idx]; - // 和"产品主图"共用的那张不删文件,只从网站图片列表里移除 + // 和"产品主图"共用的那张不删文件,只从列表里移除 if (f && f !== draft.productImageFileName) { try { await deleteFile(draft.id, f); } catch (e) {} } - set({ webImages: images.filter((_, i) => i !== idx) }); + set({ [field]: images.filter((_, i) => i !== idx) }); } function handleDrop(dropIdx) { if (dragIdx === null || dragIdx === dropIdx) { setDragIdx(null); return; } - set({ webImages: reorderArray(images, dragIdx, dropIdx) }); + set({ [field]: reorderArray(images, dragIdx, dropIdx) }); setDragIdx(null); } + return ( +