diff --git a/App.jsx b/App.jsx index 47457cc..48dfeb5 100644 --- a/App.jsx +++ b/App.jsx @@ -1916,6 +1916,13 @@ const Styles = () => ( .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-gallery { grid-column: span 2; } + @media (max-width: 720px) { .site-gallery { grid-column: auto; } } + .site-gal-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 8px; align-items: center; cursor: grab; } + .site-gal-thumb { position: relative; width: 64px; height: 48px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); } + .site-gal-thumb img { width: 100%; height: 100%; object-fit: cover; } + .site-gal-thumb .cover-tag { position: absolute; left: 2px; top: 2px; font-size: 10px; background: rgba(0,0,0,.65); color: #fff; padding: 0 5px; border-radius: 3px; } + .site-gal-btns { display: flex; gap: 2px; } .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 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); } @@ -5698,10 +5705,10 @@ 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: 'line', name: '生产线', hint: '公司介绍右侧大图', size: '1200×900 横图', gallery: true }, + { id: 'rd', name: '研发 / 工程师', hint: '公司介绍右上小图', size: '1200×900 横图', gallery: true }, + { id: 'warehouse', name: '仓库 / 出货', hint: '公司介绍右下小图', size: '1200×900 横图', gallery: true }, ] }, { title: '产品线(每个产品家族一张,未上传时显示图标)', slots: [ { id: 'fam_dc', name: '直流 UPS(Mini UPS)', size: '1200×750 横图' }, @@ -5781,6 +5788,7 @@ function SiteAssetsEditor({ assets, setAssets, onNotify }) {
{g.slots.map(sl => { const list = assets[sl.id] || []; + if (sl.gallery) return setSlot(sl.id, next)} onNotify={onNotify} />; return (
@@ -5805,6 +5813,64 @@ function SiteAssetsEditor({ assets, setAssets, onNotify }) { ); } +// 图集图片位:每张图 + 英文标题(网站自动翻译成西语、俄语),第一张是首图 +const SITE_GALLERY_MAX = 12; +const galleryItem = (x) => (typeof x === 'string' ? { file: x, caption: { en: '' } } : { file: x.file, caption: { en: '', ...(x.caption || {}) } }); +function SiteGalleryEditor({ slot, items, onChange, onNotify }) { + const list = (items || []).map(galleryItem); + const [uploading, setUploading] = useState(false); + const [dragIdx, setDragIdx] = useState(null); + async function pick(fileList) { + const files = Array.from(fileList || []).slice(0, Math.max(0, SITE_GALLERY_MAX - list.length)); + if (!files.length) { onNotify && onNotify(`最多 ${SITE_GALLERY_MAX} 张`); return; } + setUploading(true); + const added = []; + for (const f of files) { + try { const r = await uploadFile(SITE_ASSET_DIR, f); added.push({ file: r.fileName, caption: { en: '' } }); } + catch (e) { onNotify && onNotify(`${f.name} 上传失败,请重试`); } + } + onChange([...list, ...added]); + setUploading(false); + } + async function remove(i) { + try { await deleteFile(SITE_ASSET_DIR, list[i].file); } catch (e) {} + onChange(list.filter((_, j) => j !== i)); + } + const setCaption = (i, v) => onChange(list.map((x, j) => (j === i ? { ...x, caption: { ...x.caption, en: v } } : x))); + const move = (from, to) => { if (to < 0 || to >= list.length || from === to) return; onChange(reorderArray(list, from, to)); }; + return ( +
+
+ {slot.name} · 图集 + {list.length ? `${list.length} 张` : '未上传'} +
+
{slot.hint} · 建议 {slot.size} · 最多 {SITE_GALLERY_MAX} 张,拖动排序
+ {list.map((x, i) => ( +
setDragIdx(i)} onDragOver={e => e.preventDefault()} + onDrop={() => { if (dragIdx !== null) move(dragIdx, i); setDragIdx(null); }} onDragEnd={() => setDragIdx(null)}> +
+ + {i === 0 && 首图} +
+ setCaption(i, e.target.value)} placeholder="英文标题,如:SMT production line" /> +
+ + +
+
+ ))} + {list.length < SITE_GALLERY_MAX && ( + + )} +
+ ); +} + const newNewsId = () => 'n_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6); function SiteNewsEditor({ news, setNews }) { const list = Array.isArray(news) ? news : [];