Update App.jsx via upload script - 2026-10-12 15:23:00
This commit is contained in:
parent
be005c2a35
commit
862f0f0f2b
79
App.jsx
79
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 (
|
||||
<div className="web-section">
|
||||
|
|
@ -5555,9 +5573,21 @@ function WebPublishSection({ draft, set, onNotify }) {
|
|||
)}
|
||||
</div>
|
||||
|
||||
{WEB_DESC_LANGS.map(([code, label]) => (
|
||||
<div className="field">
|
||||
<span className="field-label">网站产品介绍(英文)——西班牙语、俄语在更新网站时自动翻译</span>
|
||||
<textarea
|
||||
className="textarea" style={{ fontFamily: 'inherit', fontSize: 13 }} rows={4}
|
||||
value={desc.en || ''}
|
||||
onChange={e => set({ webDescription: { ...desc, en: e.target.value } })}
|
||||
placeholder="如:Mini UPS with 24V/48V PoE output for routers, ONTs and IP cameras."
|
||||
/>
|
||||
<button type="button" className="btn btn-sm btn-ghost" style={{ alignSelf: 'flex-start' }} onClick={() => setShowManual(v => !v)}>
|
||||
{showManual ? '收起手动译文' : '手动修改译文(可选)'}
|
||||
</button>
|
||||
</div>
|
||||
{showManual && WEB_DESC_AUTO_LANGS.map(([code, label]) => (
|
||||
<div className="field" key={code}>
|
||||
<span className="field-label">网站产品介绍 · {label}</span>
|
||||
<span className="field-label">{label}译文(留空 = 自动翻译;填了就用这里的内容)</span>
|
||||
<textarea
|
||||
className="textarea" style={{ fontFamily: 'inherit', fontSize: 13 }} rows={3}
|
||||
value={desc[code] || ''}
|
||||
|
|
@ -5587,21 +5617,30 @@ function WebPublishSection({ draft, set, onNotify }) {
|
|||
)}
|
||||
</div>
|
||||
|
||||
<div className="grid-2">
|
||||
<div className="field">
|
||||
<span className="field-label">阶梯价(美元/台,数量越大单价越低)</span>
|
||||
{tiers.map((t, idx) => (
|
||||
<div className="web-tier-row" key={idx}>
|
||||
<input className="input" type="number" min="0" style={{ flex: 1 }} value={t.qty ?? ''} onChange={e => updateTier(idx, { qty: e.target.value })} placeholder={sale.mode === 'group' ? '起订数量,如 100' : '起订数量,如 20'} />
|
||||
<span style={{ fontSize: 12.5, color: 'var(--ink-soft)' }}>台起</span>
|
||||
<input className="input" type="number" min="0" step="0.01" style={{ flex: 1 }} value={t.price ?? ''} onChange={e => updateTier(idx, { price: e.target.value })} placeholder="单价 USD" />
|
||||
<button type="button" className="btn btn-sm btn-ghost btn-danger" onClick={() => setSale({ tiers: tiers.filter((_, i) => i !== idx) })}><Trash2 size={12} /></button>
|
||||
<span className="field-label">{moq}台单价(USD,起订量价格)</span>
|
||||
<input className="input" type="number" min="0" step="0.01" value={sale.minPrice ?? ''} onChange={e => setSale({ minPrice: e.target.value })} placeholder="如:19.90" />
|
||||
</div>
|
||||
<div className="field">
|
||||
<span className="field-label">1000台单价(USD)</span>
|
||||
<input className="input" type="number" min="0" step="0.01" value={sale.maxPrice ?? ''} onChange={e => setSale({ maxPrice: e.target.value })} placeholder="如:16.20" />
|
||||
</div>
|
||||
</div>
|
||||
{Number(sale.maxPrice) > 0 && Number(sale.minPrice) > 0 && Number(sale.maxPrice) > Number(sale.minPrice) && (
|
||||
<div style={{ fontSize: 12.5, color: '#a5480b' }}>1000台单价比起订量单价还高,请检查是否填反了。</div>
|
||||
)}
|
||||
{tiers.length > 1 && (
|
||||
<div className="field">
|
||||
<span className="field-label">自动生成的阶梯价(网站上显示的就是这张表)</span>
|
||||
<div className="web-tier-preview">
|
||||
{tiers.map(t => (
|
||||
<div key={t.qty}><span>{t.qty}台起</span><b>${t.price.toFixed(2)}</b></div>
|
||||
))}
|
||||
<button type="button" className="btn btn-sm btn-ghost" onClick={() => setSale({ tiers: [...tiers, { qty: '', price: '' }] })}>
|
||||
<Plus size={12} style={{ verticalAlign: -2, marginRight: 4 }} />添加一档
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue