From 862f0f0f2b94edfb06f7799e29ec5e998c0f1269 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 12 Oct 2026 15:23:03 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-10-12 15:23:00 --- App.jsx | 85 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 23 deletions(-) diff --git a/App.jsx b/App.jsx index 08b783c..d3f1e28 100644 --- a/App.jsx +++ b/App.jsx @@ -1033,8 +1033,8 @@ const blankProduct = () => ({ publishToWeb: false, // 是否发布到网站 webImages: [], // 网站主图文件名,最多6张,第一张为封面;为空时网站用 productImageFileName youtubeUrl: '', // 网站产品视频(YouTube链接) - webDescription: { es: '', en: '', ru: '' }, // 网站产品介绍,三种语言 - webSale: { mode: 'stock', stock: '', tiers: [] }, // 网站销售状态:stock现货 / group拼单;tiers阶梯价 [{qty, price}](USD) + webDescription: { en: '', es: '', ru: '' }, // 网站产品介绍:只需填英文,其他语言在网站构建时用DeepSeek自动翻译;es/ru填了就用手动译文 + webSale: { mode: 'stock', stock: '', minPrice: '', maxPrice: '' }, // 网站销售状态:stock现货 / group拼单;minPrice起订量单价、maxPrice 1000台单价(USD),中间按数量等差自动生成 }); function isUpsCategory(cat) { @@ -1890,7 +1890,9 @@ const Styles = () => ( .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-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-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; } + .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; } + .web-tier-preview span { color: var(--ink-soft); } .field-manage-link { font-size: 11.5px; font-weight: 600; color: var(--blue); cursor: pointer; display: inline-flex; align-items: center; gap: 3px; text-transform: none; letter-spacing: 0; @@ -5450,14 +5452,33 @@ function youtubeIdOf(url) { return m ? m[1] : null; } -const WEB_DESC_LANGS = [['es', '西班牙语'], ['en', '英语'], ['ru', '俄语']]; +const WEB_DESC_AUTO_LANGS = [['es', '西班牙语'], ['ru', '俄语']]; // 自动翻译的语言,以后加语言在这里和 public-api.js 的 WEB_TRANSLATE_LANGS 同步加 + +// 阶梯价:只填起订量单价和1000台单价,中间档位按数量线性(等差)插值。 +// 网站端(ups-site/src/i18n.mjs 的 tiersOf)用的是同一套公式,两边要保持一致。 +function webTierPoints(mode) { + const moq = mode === 'group' ? 100 : 20; + const pts = [moq]; + for (let q = 100; q <= 1000; q += 100) if (q > moq) pts.push(q); + return { moq, pts }; +} +function webTiers(sale) { + const s = sale || {}; + const pMin = Number(s.minPrice), pMax = Number(s.maxPrice); + if (!(pMin > 0)) return []; + const { moq, pts } = webTierPoints(s.mode); + if (!(pMax > 0)) return [{ qty: moq, price: pMin }]; + return pts.map(q => ({ qty: q, price: Math.round((pMin + (pMax - pMin) * (q - moq) / (1000 - moq)) * 100) / 100 })); +} 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 = Array.isArray(sale.tiers) ? sale.tiers : []; + const tiers = webTiers(sale); + const moq = webTierPoints(sale.mode).moq; + const [showManual, setShowManual] = useState(!!(desc.es || desc.ru)); const [uploading, setUploading] = useState(false); const [dragIdx, setDragIdx] = useState(null); const ytId = youtubeIdOf(draft.youtubeUrl); @@ -5498,9 +5519,6 @@ function WebPublishSection({ draft, set, onNotify }) { setDragIdx(null); } - function updateTier(idx, patch) { - setSale({ tiers: tiers.map((t, i) => (i === idx ? { ...t, ...patch } : t)) }); - } return (
@@ -5555,9 +5573,21 @@ function WebPublishSection({ draft, set, onNotify }) { )}
- {WEB_DESC_LANGS.map(([code, label]) => ( +
+ 网站产品介绍(英文)——西班牙语、俄语在更新网站时自动翻译 +