fix(deploy): 把 V2.1 设计稿挪进 电商AI平台/ · Docker 构建上下文是这里

This commit is contained in:
UI 设计
2026-05-21 16:30:37 +08:00
parent e293aa43be
commit e7c0a14f75
22 changed files with 23431 additions and 2283 deletions
+578
View File
@@ -0,0 +1,578 @@
/* ============================================================
新建商品 · 共享 Drawer 模块
----------------------------------------------------------
在任意页面只需 <script src="assets/new-product-drawer.js"> 引入,
然后调用 NewProductDrawer.open({ onSave: fn }) 即可在当前页之上
弹出右侧 Drawer。点击遮罩 / X / 取消 / ESC 关闭后,用户停在原页面。
提供:
window.NewProductDrawer.open(opts?)
window.NewProductDrawer.close()
opts 字段:
onSave(product) — 保存时回调,product = { id, name, cat, target,
points: string[], images: { id, dataUrl, name }[] }
============================================================ */
(function () {
'use strict';
if (window.NewProductDrawer) return; // idempotent
const DRAWER_ID = 'npd-drawer';
const DRAWER_BG_ID = 'npd-drawer-bg';
/* ---------- 注入样式(独立 namespace 以免与 products.html 冲突) ---------- */
const CSS = `
/* drawer base (相同尺寸/动画) */
#${DRAWER_BG_ID} {
position: fixed; inset: 0;
background: rgba(21, 20, 15, .32);
display: none; z-index: 1100;
}
#${DRAWER_BG_ID}.show { display: block; }
#${DRAWER_ID} {
position: fixed; right: 0; top: 0; bottom: 0;
width: 820px; max-width: 100vw;
background: var(--surface);
border-left: 1px solid var(--border-faint);
z-index: 1101;
transform: translateX(100%);
transition: transform .25s cubic-bezier(.32, .72, 0, 1);
display: flex; flex-direction: column;
box-shadow: -4px 0 24px rgba(21, 20, 15, .04);
}
#${DRAWER_ID}.show { transform: translateX(0); }
#${DRAWER_ID} .drawer-h {
padding: 20px 24px;
border-bottom: 1px solid var(--border-faint);
display: flex; align-items: center;
}
#${DRAWER_ID} .drawer-h h3 { font-size: 16px; font-weight: 600; color: var(--accent-black); }
#${DRAWER_ID} .drawer-h .x {
margin-left: auto; width: 32px; height: 32px;
border-radius: var(--r-md);
display: grid; place-items: center;
color: var(--black-alpha-56); cursor: pointer;
background: transparent; border: 0;
transition: background var(--t-base);
}
#${DRAWER_ID} .drawer-h .x:hover { background: var(--black-alpha-4); color: var(--accent-black); }
#${DRAWER_ID} .drawer-b { padding: 24px 28px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
#${DRAWER_ID} .drawer-f {
padding: 14px 24px;
border-top: 1px solid var(--border-faint);
display: flex; gap: 10px; align-items: center;
background: var(--surface);
}
#${DRAWER_ID} .drawer-f .btn-guide {
margin-right: auto;
display: inline-flex; align-items: center; gap: 6px;
font-size: 13px; color: var(--black-alpha-56);
background: transparent; border: 0; cursor: pointer;
padding: 8px 10px; border-radius: var(--r-md);
font-family: inherit;
transition: background var(--t-base), color var(--t-base);
}
#${DRAWER_ID} .drawer-f .btn-guide:hover { color: var(--accent-black); background: var(--black-alpha-4); }
#${DRAWER_ID} .drawer-f .btn-guide svg { width: 14px; height: 14px; }
/* form-card */
#${DRAWER_ID} .form-h {
font-size: 15px; font-weight: 600; color: var(--accent-black);
margin-bottom: 18px; padding-bottom: 12px;
border-bottom: 1px solid var(--border-faint);
}
#${DRAWER_ID} .field { margin-bottom: 16px; }
#${DRAWER_ID} .field:last-child { margin-bottom: 0; }
#${DRAWER_ID} .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
#${DRAWER_ID} .field-label {
display: block; font-size: 13px; font-weight: 500;
color: var(--accent-black); margin-bottom: 6px;
}
#${DRAWER_ID} .field-label .req { color: var(--heat); margin-left: 2px; }
#${DRAWER_ID} .field-label .opt {
color: var(--black-alpha-48); font-weight: 400; font-size: 12px; margin-left: 6px;
}
#${DRAWER_ID} .input,
#${DRAWER_ID} .select {
width: 100%; height: 38px;
background: var(--background-lighter);
border: 1px solid var(--black-alpha-12);
border-radius: var(--r-md);
padding: 0 14px;
font-size: 13.5px; color: var(--accent-black);
outline: none; font-family: inherit;
transition: border-color var(--t-base);
}
#${DRAWER_ID} .input:focus,
#${DRAWER_ID} .select:focus {
border-color: var(--heat-40);
box-shadow: inset 0 0 0 1px var(--heat-40);
}
/* upload */
#${DRAWER_ID} .pf-upload-row {
display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
gap: 16px; align-items: stretch;
}
#${DRAWER_ID} .pf-upload-zone {
border: 1.5px dashed var(--black-alpha-24);
border-radius: var(--r-md);
padding: 28px 20px;
background: var(--background-lighter);
cursor: pointer; text-align: center;
transition: border-color var(--t-base), background var(--t-base);
display: flex; flex-direction: column; align-items: center; justify-content: center;
min-height: 180px;
}
#${DRAWER_ID} .pf-upload-zone:hover { border-color: var(--heat); background: var(--heat-8); }
#${DRAWER_ID} .pf-upload-zone .uz-ic {
width: 44px; height: 44px;
margin: 0 auto 10px;
background: var(--surface);
border: 1px solid var(--heat-20);
border-radius: var(--r-md);
color: var(--heat);
display: grid; place-items: center;
}
#${DRAWER_ID} .pf-upload-zone .uz-ic svg { width: 20px; height: 20px; }
#${DRAWER_ID} .pf-upload-zone .uz-t { font-size: 14px; color: var(--accent-black); font-weight: 500; }
#${DRAWER_ID} .pf-upload-zone .uz-t strong { color: var(--heat); font-weight: 600; }
#${DRAWER_ID} .pf-upload-zone .uz-d {
margin-top: 8px;
font-family: var(--font-mono); font-size: 11.5px;
color: var(--black-alpha-48); letter-spacing: .02em;
}
#${DRAWER_ID} .pf-example {
background: var(--background-lighter);
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
padding: 16px;
display: flex; flex-direction: column; gap: 10px;
}
#${DRAWER_ID} .pf-example .ex-h { font-size: 13px; font-weight: 600; color: var(--accent-black); }
#${DRAWER_ID} .pf-example .ex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#${DRAWER_ID} .pf-example .ex-grid .ex-thumb {
aspect-ratio: 1;
background: var(--surface);
border: 1px solid var(--border-faint);
border-radius: var(--r-sm);
overflow: hidden; position: relative;
display: grid; place-items: center;
color: var(--black-alpha-32);
}
#${DRAWER_ID} .pf-example .ex-grid .ex-thumb svg { width: 22px; height: 22px; }
#${DRAWER_ID} .pf-example .ex-grid .ex-thumb::after {
content: ''; position: absolute; inset: 0;
background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0,0,0,.03) 6px 7px);
pointer-events: none;
}
#${DRAWER_ID} .pf-example .ex-d { font-size: 12px; color: var(--black-alpha-56); line-height: 1.5; }
#${DRAWER_ID} .pf-grid {
display: grid; grid-template-columns: repeat(5, 1fr);
gap: 8px; margin-top: 12px;
}
#${DRAWER_ID} .pf-grid:empty { display: none; }
#${DRAWER_ID} .pf-thumb {
aspect-ratio: 1;
background: var(--background-lighter);
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
position: relative; overflow: hidden; cursor: pointer;
}
#${DRAWER_ID} .pf-thumb img { width: 100%; height: 100%; object-fit: cover; }
#${DRAWER_ID} .pf-thumb .pf-x {
position: absolute; top: 4px; right: 4px;
width: 22px; height: 22px;
background: rgba(0,0,0,.7); color: var(--accent-white);
border: 0; border-radius: 50%; cursor: pointer;
display: grid; place-items: center;
opacity: 0; transition: opacity var(--t-base);
}
#${DRAWER_ID} .pf-thumb:hover .pf-x { opacity: 1; }
#${DRAWER_ID} .pf-thumb .pf-x svg { width: 11px; height: 11px; }
/* bullet-list */
#${DRAWER_ID} .bullet-list { list-style: none; padding: 0; margin: 0; }
#${DRAWER_ID} .bullet-list .bl-item,
#${DRAWER_ID} .bullet-list .bl-add {
display: flex; align-items: center; gap: 10px;
padding: 8px 12px;
background: var(--background-lighter);
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
margin-bottom: 6px;
font-size: 13.5px;
}
#${DRAWER_ID} .bullet-list .bl-add { background: transparent; border-style: dashed; }
#${DRAWER_ID} .bullet-list .num {
width: 22px; height: 22px;
background: var(--surface);
border: 1px solid var(--border-faint);
border-radius: var(--r-sm);
font-family: var(--font-mono);
font-size: 11px; color: var(--heat); font-weight: 700;
display: grid; place-items: center; flex-shrink: 0;
}
#${DRAWER_ID} .bullet-list .bl-text { flex: 1; color: var(--accent-black); }
#${DRAWER_ID} .bullet-list .bl-input {
flex: 1; background: transparent; border: 0; outline: none;
font-size: 13.5px; color: var(--accent-black); font-family: inherit;
}
#${DRAWER_ID} .bullet-list .bl-x {
width: 22px; height: 22px;
color: var(--black-alpha-48);
cursor: pointer; display: grid; place-items: center;
border-radius: var(--r-sm);
transition: color var(--t-base), background var(--t-base);
}
#${DRAWER_ID} .bullet-list .bl-x:hover { color: var(--accent-crimson); background: var(--crimson-bg); }
#${DRAWER_ID} .bullet-list .bl-x svg { width: 11px; height: 11px; }
@media (max-width: 900px) {
#${DRAWER_ID} .pf-upload-row { grid-template-columns: 1fr; }
}
`;
const HTML = `
<div id="${DRAWER_BG_ID}"></div>
<aside id="${DRAWER_ID}" role="dialog" aria-label="新建商品" aria-hidden="true">
<div class="drawer-h">
<h3>新建商品</h3>
<button class="x" type="button" data-act="close" aria-label="关闭">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 6l12 12M6 18L18 6"/></svg>
</button>
</div>
<div class="drawer-b">
<div class="form-card">
<div class="form-h">基础信息</div>
<div class="field">
<label class="field-label">商品名称<span class="req">*</span></label>
<input class="input" data-f="name" placeholder="请输入商品名称(必填)" maxlength="100">
</div>
<div class="field-row">
<div>
<label class="field-label">品类<span class="req">*</span></label>
<select class="select" data-f="cat">
<option>美妆个护</option>
<option>服饰内衣</option>
<option>食品饮料</option>
<option>家居家电</option>
<option>数码 3C</option>
<option>个护清洁</option>
<option>运动户外</option>
<option>母婴亲子</option>
</select>
</div>
<div>
<label class="field-label">目标人群<span class="opt">(选填)</span></label>
<input class="input" data-f="target" placeholder="例: 22-32 岁女性、敏感肌、办公室通勤">
</div>
</div>
<div class="field">
<label class="field-label">商品主图<span class="req">*</span></label>
<input type="file" data-f="file" accept="image/*" multiple hidden>
<div class="pf-upload-row">
<div class="pf-upload-zone" data-act="upload-zone">
<div class="uz-ic">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12"/></svg>
</div>
<div class="uz-t">点击上传或<strong>拖拽图片</strong>到此处</div>
<div class="uz-d">// 支持 JPG、PNG 格式,建议尺寸 800×800 以上,大小不超过 10MB</div>
</div>
<div class="pf-example">
<div class="ex-h">示例图</div>
<div class="ex-grid">
<div class="ex-thumb"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M7 4h10l1 4v12H6V8l1-4z"/><path d="M9 4v3M15 4v3M9 11h6M9 14h6"/></svg></div>
<div class="ex-thumb"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="5" width="12" height="15" rx="2"/><path d="M9 9h6M9 12h6M9 15h4"/></svg></div>
<div class="ex-thumb"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3h8l1 5v12H7V8l1-5z"/><circle cx="12" cy="13" r="2.5"/></svg></div>
</div>
<div class="ex-d">优质的商品图有助于生成更好的素材效果</div>
</div>
</div>
<div class="pf-grid" data-f="grid"></div>
</div>
<div class="field" style="margin-bottom: 0;">
<label class="field-label">核心卖点<span class="req">*</span></label>
<ul class="bullet-list" data-f="bullets">
<li class="bl-add"><span class="num">+</span><input class="bl-input" placeholder="添加新卖点 · 回车确认"></li>
</ul>
</div>
</div>
</div>
<div class="drawer-f">
<button class="btn-guide" type="button" data-act="guide">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M9.5 9a2.5 2.5 0 015 0c0 1.5-2.5 2-2.5 4M12 17h.01"/></svg>
使用指南
</button>
<button class="btn" type="button" data-act="cancel">取消</button>
<button class="btn btn-primary" type="button" data-act="save">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12l5 5L20 6"/></svg>
创建商品
</button>
</div>
</aside>
`;
/* ---------- DOM refs (populated by ensureInjected) ---------- */
let injected = false;
let bg, drawer, $f, $grid, $bullets, $blInput;
let currentOpts = {};
const PF_MAX = 5;
let pfFiles = []; // { id, dataUrl, name }
const blXSvg = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M4 4l8 8M12 4l-8 8"/></svg>';
function esc(s) { return String(s == null ? '' : s).replace(/[<>&"]/g, c => ({ '<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;' })[c]); }
function uid() { return Date.now().toString(36) + Math.random().toString(36).slice(2, 5); }
function toast(msg, sub) {
if (typeof Shell !== 'undefined' && Shell && Shell.toast) Shell.toast(msg, sub);
}
function ensureInjected() {
if (injected) return;
// style
const styleEl = document.createElement('style');
styleEl.textContent = CSS;
document.head.appendChild(styleEl);
// html
const wrap = document.createElement('div');
wrap.innerHTML = HTML;
while (wrap.firstChild) document.body.appendChild(wrap.firstChild);
bg = document.getElementById(DRAWER_BG_ID);
drawer = document.getElementById(DRAWER_ID);
$f = {
name: drawer.querySelector('[data-f="name"]'),
cat: drawer.querySelector('[data-f="cat"]'),
target: drawer.querySelector('[data-f="target"]'),
file: drawer.querySelector('[data-f="file"]'),
};
$grid = drawer.querySelector('[data-f="grid"]');
$bullets = drawer.querySelector('[data-f="bullets"]');
$blInput = $bullets.querySelector('.bl-add .bl-input');
bindEvents();
injected = true;
}
function bindEvents() {
// 关闭交互
bg.addEventListener('click', close);
drawer.addEventListener('click', e => {
const a = e.target.closest('[data-act]');
if (!a) return;
const act = a.dataset.act;
if (act === 'close') return close();
if (act === 'cancel') return close();
if (act === 'guide') return toast('使用指南', '点击查看完整填写指南');
if (act === 'save') return save();
if (act === 'upload-zone') return openFilePicker();
});
document.addEventListener('keydown', e => {
if (e.key === 'Escape' && drawer.classList.contains('show')) close();
});
// 上传
$f.file.addEventListener('change', e => { addFiles(e.target.files); e.target.value = ''; });
const zone = drawer.querySelector('[data-act="upload-zone"]');
zone.addEventListener('dragover', e => { e.preventDefault(); zone.style.borderColor = 'var(--heat)'; });
zone.addEventListener('dragleave', () => { zone.style.borderColor = ''; });
zone.addEventListener('drop', e => {
e.preventDefault(); zone.style.borderColor = '';
if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length) addFiles(e.dataTransfer.files);
});
// 卖点 bullet-list
$blInput.addEventListener('keydown', e => {
if (e.key === 'Enter') { e.preventDefault(); blAdd($blInput.value); $blInput.value = ''; }
});
}
function openFilePicker() { if (pfFiles.length < PF_MAX) $f.file.click(); }
function pfRender() {
$grid.innerHTML = pfFiles.map(u => `
<div class="pf-thumb" data-id="${u.id}">
<img src="${u.dataUrl}" alt="${esc(u.name)}">
<button class="pf-x" type="button" title="删除">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 4l8 8M12 4l-8 8"/></svg>
</button>
</div>
`).join('');
$grid.querySelectorAll('.pf-thumb .pf-x').forEach(b => {
b.onclick = e => {
e.stopPropagation();
const id = b.closest('.pf-thumb').dataset.id;
const i = pfFiles.findIndex(f => f.id === id);
if (i >= 0) { pfFiles.splice(i, 1); pfRender(); }
};
});
}
function addFiles(fileList) {
const room = PF_MAX - pfFiles.length;
if (room <= 0) { toast('已达上限', PF_MAX + ' / ' + PF_MAX + ' 张'); return; }
const incoming = [...fileList].filter(f => f.type.startsWith('image/')).slice(0, room);
let done = 0;
incoming.forEach(f => {
const r = new FileReader();
r.onload = e => {
pfFiles.push({ id: uid(), dataUrl: e.target.result, name: f.name });
if (++done === incoming.length) {
pfRender();
toast('已上传', '+ ' + done + ' 张 · 共 ' + pfFiles.length + ' / ' + PF_MAX);
}
};
r.readAsDataURL(f);
});
}
function blRenumber() {
[...$bullets.querySelectorAll('.bl-item')].forEach((li, i) => {
li.querySelector('.num').textContent = i + 1;
});
}
function blAdd(text) {
const t = (text || '').trim();
if (!t) return;
const li = document.createElement('li');
li.className = 'bl-item';
li.innerHTML = '<span class="num">0</span><span class="bl-text">' + esc(t) + '</span><span class="bl-x" title="删除">' + blXSvg + '</span>';
$bullets.querySelector('.bl-add').before(li);
li.querySelector('.bl-x').addEventListener('click', () => {
li.style.transition = 'opacity .15s, transform .15s';
li.style.opacity = 0;
li.style.transform = 'translateX(-8px)';
setTimeout(() => { li.remove(); blRenumber(); }, 150);
});
blRenumber();
}
function getBullets() {
return [...$bullets.querySelectorAll('.bl-item .bl-text')].map(t => t.textContent.trim()).filter(Boolean);
}
/* ---------- API ---------- */
function resetForm() {
$f.name.value = '';
$f.cat.value = $f.cat.options[0].value;
$f.target.value = '';
pfFiles = [];
pfRender();
[...$bullets.querySelectorAll('.bl-item')].forEach(li => li.remove());
$blInput.value = '';
}
function lockBody() {
// 优先用 Shell 的引用计数实现(避免多 overlay 互相解锁)
if (typeof Shell !== 'undefined' && Shell && typeof Shell.lockScroll === 'function') {
Shell.lockScroll();
return;
}
// 兜底: Shell 未加载时本地锁
const docEl = document.documentElement;
const sbw = window.innerWidth - docEl.clientWidth;
drawer._lockSnap = {
bodyOverflow: document.body.style.overflow,
bodyPaddingRight: document.body.style.paddingRight,
htmlOverflow: docEl.style.overflow,
};
document.body.style.overflow = 'hidden';
docEl.style.overflow = 'hidden';
if (sbw > 0) document.body.style.paddingRight = sbw + 'px';
}
function unlockBody() {
if (typeof Shell !== 'undefined' && Shell && typeof Shell.unlockScroll === 'function') {
Shell.unlockScroll();
return;
}
const s = drawer._lockSnap;
if (s) {
document.body.style.overflow = s.bodyOverflow;
document.body.style.paddingRight = s.bodyPaddingRight;
document.documentElement.style.overflow = s.htmlOverflow;
drawer._lockSnap = null;
}
}
function open(opts) {
ensureInjected();
if (drawer.classList.contains('show')) return; // 已开则不重复锁
currentOpts = opts || {};
resetForm();
bg.classList.add('show');
drawer.classList.add('show');
drawer.setAttribute('aria-hidden', 'false');
lockBody();
setTimeout(() => $f.name.focus(), 280);
}
function close() {
if (!injected) return;
if (!drawer.classList.contains('show')) return; // 已关则不重复解锁
bg.classList.remove('show');
drawer.classList.remove('show');
drawer.setAttribute('aria-hidden', 'true');
unlockBody();
if (typeof currentOpts.onClose === 'function') currentOpts.onClose();
}
function save() {
const name = ($f.name.value || '').trim();
const cat = $f.cat.value;
const target = ($f.target.value || '').trim();
const points = getBullets();
const images = pfFiles.slice();
if (!name) {
toast('请填写商品名称');
$f.name.focus();
return;
}
if (images.length === 0) {
toast('请上传商品主图', '至少 1 张');
return;
}
if (points.length === 0) {
toast('请添加核心卖点', '至少 1 条');
$blInput.focus();
return;
}
const product = {
id: 'np-' + uid(),
name, cat, target,
points,
images,
imgs: images.length,
};
toast('商品已创建', '+ ' + name);
if (typeof currentOpts.onSave === 'function') currentOpts.onSave(product);
close();
}
window.NewProductDrawer = { open, close };
/* ---------- sessionStorage 自动打开钩子 ---------- */
// 任何页面只要在跳转前 sessionStorage.setItem('npd-auto-open','1') 即可,
// 落地页加载完模块后,会自动 open() 一次并清掉 flag。
// 用于:product-create.html 重定向后让落地页弹出 drawer,而不是用户重新点击。
function checkAutoOpen() {
try {
if (sessionStorage.getItem('npd-auto-open') === '1') {
sessionStorage.removeItem('npd-auto-open');
// 延后一拍,确保宿主页面自己的 init 已经跑完
setTimeout(() => open(), 50);
}
} catch (e) { /* sessionStorage 不可用就静默放弃 */ }
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', checkAutoOpen);
} else {
checkAutoOpen();
}
})();
+564 -7
View File
@@ -276,7 +276,7 @@ nav a.disabled:hover { background: transparent; color: var(--black-alpha-32); }
.user .em { font-size: 13px; color: var(--accent-black); }
/* ─── Main + grid background ─── */
main { position: relative; overflow: hidden; background: var(--background-base); }
main { position: relative; background: var(--background-base); min-width: 0; }
.grid-bg {
position: absolute; inset: 0; pointer-events: none;
background-image:
@@ -308,7 +308,7 @@ main { position: relative; overflow: hidden; background: var(--background-base);
padding: 14px 28px;
border-bottom: 1px solid var(--border-faint);
background: var(--background-base);
position: relative; z-index: 2;
position: sticky; top: 0; z-index: 50;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--black-alpha-48); }
.crumbs .sep { color: var(--black-alpha-32); }
@@ -348,14 +348,70 @@ main { position: relative; overflow: hidden; background: var(--background-base);
width: 7px; height: 7px; border-radius: 50%;
background: var(--heat); border: 1.5px solid var(--surface);
}
.icon-btn .count-noti {
position: absolute; top: -4px; right: -4px;
min-width: 16px; height: 16px; padding: 0 4px;
display: inline-flex; align-items: center; justify-content: center;
background: var(--accent-crimson); color: var(--accent-white);
border: 1.5px solid var(--surface);
border-radius: var(--r-pill);
font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
letter-spacing: .02em; line-height: 1;
pointer-events: none;
}
/* ─── Topbar · 任务队列 chip ─── */
.queue-chip {
display: inline-flex; align-items: center; gap: 7px;
height: 36px;
padding: 0 8px 0 12px;
background: var(--surface);
border: 1px solid var(--border-faint);
border-radius: var(--r-pill);
font-size: 13px;
color: var(--accent-black);
cursor: pointer;
transition: background var(--t-base), border-color var(--t-base);
}
.queue-chip:hover { background: var(--black-alpha-4); border-color: var(--black-alpha-24); }
.queue-chip svg { width: 14px; height: 14px; color: var(--black-alpha-56); }
.queue-chip .count {
display: inline-flex; align-items: center; justify-content: center;
height: 20px; min-width: 20px; padding: 0 6px;
background: var(--heat-12); color: var(--heat);
border: 1px solid var(--heat-20);
border-radius: var(--r-pill);
font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
letter-spacing: .02em;
}
/* ─── Topbar · 头像 ─── */
.topbar-avatar {
width: 36px; height: 36px;
border-radius: var(--r-pill);
background: var(--accent-black);
color: var(--accent-white);
display: inline-flex; align-items: center; justify-content: center;
font-size: 13px; font-weight: 600;
cursor: pointer;
border: 1px solid var(--border-faint);
transition: transform var(--t-fast), box-shadow var(--t-base);
flex-shrink: 0;
overflow: hidden;
}
.topbar-avatar:hover {
transform: scale(1.04);
box-shadow: 0 0 0 3px var(--heat-12);
}
.topbar-avatar img {
width: 100%; height: 100%; object-fit: cover;
}
/* ─── Content ─── */
.content {
padding: 48px 56px 72px;
padding: 48px 28px 72px;
position: relative;
z-index: 1;
max-width: 1480px;
margin: 0 auto;
min-height: calc(100vh - 64px);
}
@@ -633,6 +689,454 @@ main { position: relative; overflow: hidden; background: var(--background-base);
}
.toolbar .search-inline input { padding-left: 36px; }
/* ─── Chip dropdown · 共享组件 ─── */
.chip-wrap { position: relative; display: inline-flex; }
.chip-wrap .chip svg.caret { transition: transform .15s; }
.chip-wrap.open .chip svg.caret { transform: rotate(180deg); }
.chip-menu {
position: absolute; top: calc(100% + 4px); left: 0;
min-width: 200px;
background: var(--surface);
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
box-shadow: 0 8px 24px rgba(0,0,0,.08);
padding: 4px;
z-index: 50;
display: none;
max-height: 320px;
overflow-y: auto;
}
.chip-wrap.open .chip-menu { display: block; }
.chip-menu.align-right { left: auto; right: 0; }
.chip-menu .mi {
height: 32px; padding: 0 10px;
font-size: 13px; color: var(--accent-black);
display: flex; align-items: center; gap: 8px;
border-radius: var(--r-sm);
cursor: pointer;
white-space: nowrap;
}
.chip-menu .mi:hover { background: var(--black-alpha-4); }
.chip-menu .mi.selected { color: var(--heat); background: var(--heat-12); }
.chip-menu .mi .mi-check { width: 13px; height: 13px; color: var(--heat); opacity: 0; flex-shrink: 0; }
.chip-menu .mi.selected .mi-check { opacity: 1; }
.chip-menu .mi-sep { height: 1px; background: var(--border-faint); margin: 4px 6px; }
/* ─── Clear-filters btn · 共享组件 ─── */
.clear-filters {
height: 36px; padding: 0 12px;
background: transparent; border: 0; border-radius: var(--r-md);
color: var(--black-alpha-56); font-size: 13px; font-family: inherit;
display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
transition: background var(--t-base), color var(--t-base);
}
.clear-filters:hover { background: var(--black-alpha-4); color: var(--heat); }
.clear-filters svg { width: 13px; height: 13px; }
.clear-filters[hidden] { display: none; }
/* ─── Result count · 共享组件 ─── */
.result-meta {
font-family: var(--font-mono);
font-size: 11px;
color: var(--black-alpha-48);
margin-bottom: 14px;
letter-spacing: .04em;
}
.result-meta .count { color: var(--heat); font-weight: 600; }
/* ─── 新建商品 Modal (Upload Form · 居中弹窗) ─── */
.new-product-modal {
max-width: 1080px !important;
width: 94%;
max-height: 90vh;
display: flex;
flex-direction: column;
}
/* 左图右文 双栏 · 等宽 */
.np-body-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 32px;
align-items: start;
}
.np-left, .np-right { min-width: 0; }
@media (max-width: 880px) {
.np-body-grid { grid-template-columns: 1fr; gap: 20px; }
}
.np-header {
padding: 18px 24px 16px;
border-bottom: 1px solid var(--border-faint);
display: flex; align-items: center; gap: 14px;
flex-shrink: 0;
}
.np-header .np-title-ic {
width: 36px; height: 36px;
background: var(--heat-12);
color: var(--heat);
border-radius: var(--r-md);
display: grid; place-items: center;
flex-shrink: 0;
}
.np-header .np-title-ic svg { width: 17px; height: 17px; }
.np-header h2 {
font-size: 16px; font-weight: 600; color: var(--accent-black);
margin: 0;
}
.np-header .np-mode-pill {
font-family: var(--font-mono);
font-size: 10.5px;
color: var(--heat);
background: var(--heat-12);
border: 1px solid var(--heat-20);
border-radius: var(--r-sm);
padding: 2px 8px;
letter-spacing: .04em;
font-weight: 500;
}
.np-header .np-x {
margin-left: auto;
width: 32px; height: 32px;
display: grid; place-items: center;
background: transparent; border: 0;
border-radius: var(--r-md);
color: var(--black-alpha-56);
cursor: pointer;
transition: background var(--t-base), color var(--t-base);
}
.np-header .np-x:hover { background: var(--crimson-bg); color: var(--accent-crimson); }
.np-header .np-x svg { width: 14px; height: 14px; }
.np-body {
flex: 1;
overflow-y: auto;
padding: 22px 24px;
}
/* AI CTA · 独立全宽 CTA 区域 · 放在"商品图册"上方 */
.np-ai-cta {
display: flex; align-items: center; gap: 10px;
width: 100%;
height: 40px;
padding: 0 14px;
margin-bottom: 14px;
background: transparent;
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
font-size: 13px;
color: var(--black-alpha-72);
cursor: pointer;
text-decoration: none;
font-family: inherit;
transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
}
.np-ai-cta:hover { background: var(--heat-8); border-color: var(--heat); color: var(--accent-black); }
.np-ai-cta .ai-icon { color: var(--heat); display: grid; place-items: center; flex-shrink: 0; }
.np-ai-cta .ai-icon svg { width: 14px; height: 14px; }
.np-ai-cta .ai-label { font-weight: 500; color: var(--accent-black); flex: 1; }
.np-ai-cta .ai-arrow { color: var(--black-alpha-48); transition: transform var(--t-fast), color var(--t-base); flex-shrink: 0; display: grid; place-items: center; }
.np-ai-cta .ai-arrow svg { width: 14px; height: 14px; }
.np-ai-cta:hover .ai-arrow { color: var(--heat); transform: translateX(2px); }
/* 主推态: 用户还没上传图 → 醒目橙色描边 */
.np-ai-cta.primary { border-color: var(--heat-40); background: var(--heat-8); }
.np-ai-cta.primary .ai-label { color: var(--heat); font-weight: 600; }
.np-ai-cta.primary .ai-arrow { color: var(--heat); }
.np-ai-cta.primary:hover { background: var(--heat-12); border-color: var(--heat); }
/* Footer (sticky inside modal) */
.np-footer {
border-top: 1px solid var(--border-faint);
padding: 14px 24px;
display: flex; align-items: center; gap: 12px;
flex-shrink: 0;
background: var(--background-lighter);
}
.np-footer .np-meta {
font-family: var(--font-mono);
font-size: 11.5px;
color: var(--black-alpha-48);
letter-spacing: .02em;
margin-right: auto;
}
.np-footer .np-meta .accent { color: var(--heat); font-weight: 600; }
/* Upload zone · 弹窗内尺寸略缩 */
.np-body .upload-zone {
border: 1.5px dashed var(--black-alpha-24);
border-radius: var(--r-md);
padding: 22px 20px;
text-align: center;
background: var(--background-lighter);
color: var(--black-alpha-56);
font-size: 13px;
cursor: pointer;
display: flex; flex-direction: column; align-items: center; gap: 4px;
transition: border-color var(--t-base), background var(--t-base), color var(--t-base);
}
.np-body .upload-zone:hover { border-color: var(--heat); background: var(--heat-8); color: var(--heat); }
.np-body .upload-zone:hover .uz-ic { background: var(--heat); color: #fff; border-color: var(--heat); }
.np-body .upload-zone strong { color: var(--heat); font-weight: 600; }
.np-body .upload-zone .uz-ic {
width: 40px; height: 40px;
border-radius: var(--r-md);
background: var(--surface);
color: var(--heat);
border: 1px solid var(--heat-20);
display: grid; place-items: center;
margin-bottom: 8px;
transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
}
.np-body .upload-zone .uz-ic svg { width: 18px; height: 18px; }
.np-body .upload-zone .uz-hint { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 11px; color: var(--black-alpha-48); letter-spacing: .02em; }
/* 上传子区域标题 (图片案例 / 我的上传) */
.np-section-h {
display: flex; align-items: center; gap: 6px;
font-size: 12px; font-weight: 500;
color: var(--accent-black);
margin: 12px 0 4px;
}
.np-section-h .check-ic {
width: 14px; height: 14px;
border-radius: 50%;
background: var(--accent-forest);
color: #fff;
display: grid; place-items: center;
flex-shrink: 0;
}
.np-section-h .check-ic svg { width: 8px; height: 8px; }
.np-section-h .counter {
margin-left: auto;
font-family: var(--font-mono);
font-size: 11px;
color: var(--black-alpha-48);
letter-spacing: .04em;
font-weight: 400;
}
.np-section-h .counter .num { color: var(--heat); font-weight: 600; }
.np-section-sub {
font-size: 11.5px;
color: var(--black-alpha-56);
margin-bottom: 8px;
line-height: 1.5;
}
/* 图片案例 grid (静态展示) */
.np-examples {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 5px;
}
.np-examples .ex {
aspect-ratio: 1;
border-radius: var(--r-sm);
background: var(--background-lighter);
border: 1px solid var(--border-faint);
position: relative;
display: grid;
place-items: center;
font-size: 9.5px;
color: var(--black-alpha-48);
font-family: var(--font-mono);
letter-spacing: .04em;
text-align: center;
padding: 4px;
overflow: hidden;
}
.np-examples .ex-badge {
position: absolute;
bottom: 3px; right: 3px;
width: 15px; height: 15px;
background: var(--accent-forest);
color: #fff;
border-radius: 50%;
display: grid; place-items: center;
z-index: 2;
}
.np-examples .ex-badge svg { width: 9px; height: 9px; }
/* 我的上传 grid · 始终 5 列, 含填充和空插槽 */
.np-body .upload-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 5px;
}
.up-slot-empty {
aspect-ratio: 1;
border-radius: var(--r-sm);
background: var(--background-lighter);
border: 1px dashed var(--border-faint);
cursor: pointer;
display: grid;
place-items: center;
font-size: 9.5px;
color: var(--black-alpha-32);
font-family: var(--font-mono);
letter-spacing: .04em;
transition: border-color var(--t-base), background var(--t-base), color var(--t-base);
}
.up-slot-empty:hover {
border-color: var(--heat);
background: var(--heat-8);
color: var(--heat);
}
/* dropzone 满 5 张时禁用态 */
.np-body .upload-zone.full {
cursor: not-allowed;
opacity: .55;
pointer-events: none;
}
.np-body .upload-zone.full .uz-ic { background: var(--background-lighter); color: var(--black-alpha-32); border-color: var(--border-faint); }
.up-thumb {
aspect-ratio: 1;
border-radius: var(--r-md);
overflow: hidden;
position: relative;
background: var(--background-lighter);
border: 1px solid var(--border-faint);
cursor: zoom-in;
transition: transform var(--t-fast), border-color var(--t-base);
}
.up-thumb:hover { transform: scale(1.02); border-color: var(--heat); }
.up-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.up-thumb .slot-x {
position: absolute;
top: 3px; right: 3px;
width: 18px; height: 18px;
background: rgba(0, 0, 0, .7);
color: #fff;
border-radius: 50%;
display: none;
place-items: center;
cursor: pointer;
z-index: 3;
border: 0;
padding: 0;
transition: background var(--t-base), transform var(--t-fast);
}
.up-thumb:hover .slot-x { display: grid; }
.up-thumb .slot-x:hover { background: var(--accent-crimson); transform: scale(1.1); }
.up-thumb .slot-x svg { width: 9px; height: 9px; }
/* 5 列尺寸太小,文件名 overlay 仅在 lightbox 显示,缩略图上隐藏 */
.up-thumb .slot-name { display: none; }
/* Lightbox: 点击缩略图全屏预览 */
.np-lightbox {
position: fixed; inset: 0;
background: rgba(0, 0, 0, .9);
display: none;
align-items: center;
justify-content: center;
z-index: 9999;
cursor: zoom-out;
opacity: 0;
transition: opacity .2s;
}
.np-lightbox.show { display: flex; opacity: 1; }
.np-lightbox img {
max-width: 90vw;
max-height: 88vh;
border-radius: var(--r-md);
box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.np-lightbox .lb-x {
position: fixed;
top: 24px; right: 24px;
width: 44px; height: 44px;
border-radius: 50%;
background: rgba(255, 255, 255, .12);
color: #fff;
border: 0;
cursor: pointer;
display: grid;
place-items: center;
transition: background var(--t-base);
}
.np-lightbox .lb-x:hover { background: rgba(255, 255, 255, .24); }
.np-lightbox .lb-x svg { width: 18px; height: 18px; }
.np-lightbox .lb-name {
position: fixed;
bottom: 24px; left: 50%;
transform: translateX(-50%);
font-family: var(--font-mono);
font-size: 12px;
color: rgba(255, 255, 255, .7);
letter-spacing: .04em;
}
/* Bullet list · 弹窗内 (复用样式) */
.np-body .bullet-list { list-style: none; padding: 0; }
.np-body .bullet-list li {
display: flex; gap: 10px; align-items: center;
padding: 10px 12px;
background: var(--background-lighter);
border: 1px solid var(--border-faint);
border-radius: var(--r-sm);
margin-bottom: 6px;
font-size: 13px;
color: var(--accent-black);
transition: border-color var(--t-base), background var(--t-base);
}
.np-body .bullet-list li.bl-item:hover { border-color: var(--black-alpha-24); }
.np-body .bullet-list li.bl-add { background: var(--surface); border-style: dashed; }
.np-body .bullet-list li.bl-add:focus-within { border-color: var(--heat-40); }
.np-body .bullet-list .num {
width: 20px; height: 20px;
background: var(--surface);
border: 1px solid var(--border-faint);
border-radius: var(--r-sm);
font-size: 11px; color: var(--black-alpha-56);
display: grid; place-items: center;
flex-shrink: 0;
font-family: var(--font-mono);
font-weight: 600;
}
.np-body .bullet-list li.bl-add .num { background: transparent; color: var(--heat); border-color: var(--heat-40); }
.np-body .bullet-list .bl-text { flex: 1; min-width: 0; }
.np-body .bullet-list .bl-input {
flex: 1; min-width: 0;
height: 24px; border: 0; padding: 0 4px;
background: transparent; font-size: 13px;
color: var(--accent-black); font-family: inherit;
outline: none;
}
.np-body .bullet-list .bl-input::placeholder { color: var(--black-alpha-48); }
.np-body .bullet-list .bl-x {
width: 24px; height: 24px;
display: grid; place-items: center;
color: var(--black-alpha-32);
border-radius: var(--r-sm);
cursor: pointer;
flex-shrink: 0;
opacity: 0;
transition: opacity var(--t-base), background var(--t-base), color var(--t-base);
}
.np-body .bullet-list li.bl-item:hover .bl-x { opacity: 1; }
.np-body .bullet-list .bl-x:hover { background: var(--crimson-bg); color: var(--accent-crimson); }
.np-body .bullet-list .bl-x svg { width: 11px; height: 11px; }
/* ─── Empty state · 共享组件 ─── */
.empty-state {
background: var(--surface);
border: 1px dashed var(--border-faint);
border-radius: var(--r-md);
padding: 80px 40px;
text-align: center;
color: var(--black-alpha-56);
display: none;
}
.empty-state.show { display: block; }
.empty-state .ic-empty {
width: 48px; height: 48px;
margin: 0 auto 14px;
background: var(--background-lighter);
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
display: grid; place-items: center;
color: var(--black-alpha-48);
}
.empty-state h3 { font-size: 14px; font-weight: 600; color: var(--accent-black); margin-bottom: 6px; }
.empty-state p { font-size: 12.5px; color: var(--black-alpha-48); font-family: var(--font-mono); letter-spacing: .02em; }
/* ─── Progress (5 段流水线 · V2.1 语义色 + 脉动) ─── */
.prog { display: flex; gap: 3px; }
.prog span {
@@ -761,6 +1265,10 @@ table.t tbody tr:hover { background: var(--black-alpha-4); }
position: relative;
transform: scale(.96);
transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1);
max-height: 90vh;
overflow: hidden;
display: flex;
flex-direction: column;
}
.modal-bg.show .modal { transform: scale(1); }
.modal::before, .modal::after {
@@ -789,6 +1297,7 @@ table.t tbody tr:hover { background: var(--black-alpha-4); }
padding: 22px 24px 16px;
border-bottom: 1px solid var(--border-faint);
display: flex; align-items: center; gap: 14px;
flex-shrink: 0;
}
.modal-h .ic-m {
width: 36px; height: 36px;
@@ -804,7 +1313,16 @@ table.t tbody tr:hover { background: var(--black-alpha-4); }
display: block; font-family: var(--font-mono); font-size: 11px;
color: var(--black-alpha-48); font-weight: 400; margin-top: 4px; letter-spacing: .04em;
}
.modal-b { padding: 20px 24px; font-size: 13.5px; color: var(--black-alpha-72); line-height: 1.75; }
.modal-b {
padding: 20px 24px;
font-size: 13.5px;
color: var(--black-alpha-72);
line-height: 1.75;
overflow-y: auto;
overscroll-behavior: contain;
flex: 1 1 auto;
min-height: 0;
}
.modal-b .mono-acc {
font-family: var(--font-mono); color: var(--heat);
background: var(--heat-12); padding: 2px 6px;
@@ -814,8 +1332,47 @@ table.t tbody tr:hover { background: var(--black-alpha-4); }
padding: 16px 24px;
border-top: 1px solid var(--border-faint);
display: flex; justify-content: flex-end; gap: 10px;
flex-shrink: 0;
}
/* ─── 统一卡片删除按钮 ────────────────────────────────────────
矩形 + 删除 icon, hover 卡片才显示
用法: 卡片内放 <button class="card-del-btn">[icon]</button>
外层卡片需 position: relative
触发: .product-card / .asset-card / .project-card / .task-card / .model-card hover
--------------------------------------------------------- */
.card-del-btn {
position: absolute;
top: 8px; right: 8px;
width: 32px; height: 32px;
background: rgba(255,255,255,.95);
border: 1px solid var(--black-alpha-12);
border-radius: var(--r-md);
display: grid; place-items: center;
color: var(--black-alpha-56);
cursor: pointer;
opacity: 0;
transition: opacity .18s, color .18s, border-color .18s, background .18s;
box-shadow: 0 2px 6px rgba(0,0,0,.06);
z-index: 5;
padding: 0;
font-family: inherit;
}
.card-del-btn svg { width: 14px; height: 14px; }
.product-card:hover .card-del-btn,
.asset-card:hover .card-del-btn,
.project-card:hover .card-del-btn,
.task-card:hover .card-del-btn,
.model-card:hover .card-del-btn {
opacity: 1;
}
.card-del-btn:hover {
color: var(--accent-crimson);
border-color: var(--accent-crimson);
background: var(--surface);
}
.card-del-btn:active { transform: scale(.95); }
/* ─── Drawer ─── */
.drawer-bg {
position: fixed; inset: 0;
@@ -850,7 +1407,7 @@ table.t tbody tr:hover { background: var(--black-alpha-4); }
transition: background var(--t-base);
}
.drawer-h .x:hover { background: var(--black-alpha-4); color: var(--accent-black); }
.drawer-b { padding: 24px; overflow-y: auto; flex: 1; }
.drawer-b { padding: 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.drawer-f {
padding: 16px 24px;
border-top: 1px solid var(--border-faint);
+452 -45
View File
@@ -13,33 +13,35 @@ const NAV = [
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 12 12 3l9 9"/><path d="M5 10v10h14V10"/></svg>'
},
{
id: 'products', label: '商品库', href: 'products.html', badge: '12',
id: 'products', label: '商品库', href: 'products.html', badge: '7',
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="m3 7 9-4 9 4-9 4-9-4z"/><path d="m3 12 9 4 9-4M3 17l9 4 9-4"/></svg>'
},
{
id: 'projects', label: '视频项目', href: 'projects.html',
id: 'projects', label: '视频项目', href: 'projects.html', badge: '8',
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="4" width="18" height="16"/><path d="M7 4v16M16 4v16M3 9h18M3 15h18"/></svg>'
},
{
id: 'asset-factory', label: '图片生成', href: 'asset-factory.html',
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3l1.7 4.6L18 9l-4.3 1.4L12 15l-1.7-4.6L6 9l4.3-1.4L12 3z"/><path d="M19 16l.85 2.3L22 19l-2.15.7L19 22l-.85-2.3L16 19l2.15-.7L19 16z"/></svg>'
},
{
id: 'library', label: '资产库', href: 'library.html',
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="4" width="6" height="16"/><rect x="11" y="4" width="4" height="16"/><rect x="17" y="6" width="4" height="14"/></svg>'
},
{
id: 'team', label: '团队', href: 'team.html', badge: '5',
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 19c0-3 2.7-5 6-5s6 2 6 5M14 19c.5-2.4 2.4-4 5-4 .8 0 1.5.2 2 .5"/></svg>'
},
{
id: 'account', label: '账户', href: 'account.html',
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="6" width="18" height="13" rx="2"/><path d="M3 10h18M16 14h2"/></svg>'
},
{
id: 'settings', label: '设置', href: '#',
id: 'settings', label: '设置', href: 'settings.html',
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8 2 2 0 0 1-2.8 2.8 1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5 2 2 0 0 1-4 0 1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3 2 2 0 0 1-2.8-2.8 1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1 2 2 0 0 1 0-4 1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8 2 2 0 0 1 2.8-2.8 1.7 1.7 0 0 0 1.8.3 1.7 1.7 0 0 0 1-1.5 2 2 0 0 1 4 0 1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3 2 2 0 0 1 2.8 2.8 1.7 1.7 0 0 0-.3 1.8 1.7 1.7 0 0 0 1.5 1 2 2 0 0 1 0 4 1.7 1.7 0 0 0-1.5 1.1Z"/></svg>'
}
];
const TEAM_NAV = {
label: '团队', icon:
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2.5"/><path d="M3 19c0-3 2.7-5 6-5s6 2 6 5M14 19c.5-2.4 2.4-4 5-4 .8 0 1.5.2 2 .5"/></svg>',
badge: 'V1.5'
};
window.Shell = {
render({ active = '', crumbs = [], balance = '¥327.40', topActions = '' } = {}) {
const navHtml = NAV.map(n => `
@@ -63,14 +65,6 @@ window.Shell = {
</div>
<div class="nav-section">主要</div>
<nav>${navHtml}</nav>
<div class="nav-section">协作</div>
<nav>
<a class="disabled" title="V1.5 上线,敬请期待">
${TEAM_NAV.icon}
<span>${TEAM_NAV.label}</span>
<span class="pill-mini">${TEAM_NAV.badge}</span>
</a>
</nav>
<div class="aside-foot">
<div class="user" onclick="Shell.toast('账户菜单', 'li@shop.com')">
<div class="av">李</div>
@@ -99,10 +93,18 @@ window.Shell = {
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="9"/><path d="M12 7v10M9 10h4a1.5 1.5 0 0 1 0 3h-3a1.5 1.5 0 0 0 0 3h4"/></svg>
余额 <strong>${balance}</strong>
</span>
<button class="icon-btn" onclick="Shell.toast('通知中心', '3 条未读')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10 21a2 2 0 0 0 4 0"/></svg>
<span class="dot-noti"></span>
<button class="queue-chip" onclick="Shell.toast('任务队列', '3 个进行中')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18M3 12h18M3 18h18"/></svg>
任务队列
<span class="count">3</span>
</button>
<button class="icon-btn" onclick="Shell.toast('通知中心', '12 条未读')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10 21a2 2 0 0 0 4 0"/></svg>
<span class="count-noti">12</span>
</button>
<div class="topbar-avatar" onclick="Shell.toast('账户菜单', '李 · li@shop.com')" title="账户">
<span>李</span>
</div>
${topActions}
</div>
</header>
@@ -110,29 +112,10 @@ window.Shell = {
const decorations = `
<div class="grid-bg"></div>
<pre class="scatter" style="top:96px;left:280px"> · · +
· +XX+
+XXXX·
+X· </pre>
<pre class="scatter" style="top:340px;right:96px">+ · ·
XX· ·
·XXXX·+
·++· </pre>
<pre class="scatter" style="bottom:160px;left:42%"> · +
+·XX·
·X+ ·
· </pre>
<pre class="scatter" style="top:580px;left:60px"> +X·
·XX·
+·X·+</pre>
<span class="sq-mark" style="top:238px;left:478px"></span>
<span class="sq-mark" style="top:478px;left:1198px"></span>
<span class="sq-mark" style="bottom:300px;left:238px"></span>
<span class="sq-mark" style="top:718px;right:240px"></span>
<span class="tag-corner" style="top:158px;left:34px">[ 200 OK ]</span>
<span class="tag-corner" style="top:158px;right:34px">[ /v2 ]</span>
<span class="tag-corner" style="bottom:36px;left:34px">[ .MP4 · 9:16 ]</span>
<span class="tag-corner" style="bottom:36px;right:34px">[ STUDIO ]</span>
`;
const toastHtml = `
@@ -142,6 +125,142 @@ window.Shell = {
</div>
`;
// ─── 全局 Lightbox · 任意页面可用 Shell._openLightbox(src, name) ──
const lightboxHtml = `
<div class="np-lightbox" id="np-lightbox" onclick="Shell._closeLightbox()">
<button class="lb-x" type="button" onclick="event.stopPropagation();Shell._closeLightbox()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M18 6L6 18M6 6l12 12"/></svg>
</button>
<img id="np-lightbox-img" alt="">
<span class="lb-name" id="np-lightbox-name"></span>
</div>
`;
// [DEPRECATED · 弹窗已废弃,创建商品直接进 product-create.html]
const _deprecatedModalHtml = `
<div class="modal-bg" id="new-product-bg" onclick="if(event.target===this)Shell.closeModal('new-product-bg')">
<div class="modal new-product-modal">
<span class="corner-tr"></span>
<span class="corner-bl"></span>
<div class="np-header">
<div class="np-title-ic">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m3 7 9-4 9 4-9 4-9-4z"/><path d="m3 12 9 4 9-4M3 17l9 4 9-4"/></svg>
</div>
<h2>新建商品</h2>
<span class="np-mode-pill">[ UPLOAD MODE ]</span>
<button class="np-x" type="button" onclick="Shell.closeModal('new-product-bg')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M18 6L6 18M6 6l12 12"/></svg>
</button>
</div>
<div class="np-body">
<div class="np-body-grid">
<!-- 左栏: 图片 -->
<div class="np-left">
<!-- AI CTA: 独立全宽区域,放在 商品图册 上方 -->
<a class="np-ai-cta primary" id="np-ai-cta" title="不上传也能用 AI 生成图">
<span class="ai-icon">
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l1.5 4.5L18 8l-4.5 1.5L12 14l-1.5-4.5L6 8l4.5-1.5L12 2zM19 14l.9 2.7 2.6.8-2.6.8L19 21l-.9-2.7-2.6-.8 2.6-.8L19 14zM5 14l.7 2.1L7.8 17l-2.1.7L5 20l-.7-2.3-2.1-.7 2.1-.7L5 14z"/></svg>
</span>
<span class="ai-label" id="np-ai-label">没有图? 让 AI 帮我生成</span>
<span class="ai-arrow">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</span>
</a>
<div class="field" style="margin-bottom: 12px;">
<label class="field-label">商品图册<span class="req">*</span></label>
<input type="file" id="np-file" accept="image/*" multiple hidden>
<!-- 图片案例 (静态示例) -->
<div class="np-section-h">
<span class="check-ic"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 8 7 12 13 4"/></svg></span>
图片案例
</div>
<div class="np-section-sub">上传您的商品的多角度白底图和使用图</div>
<div class="np-examples">
<div class="ex"><span>白底主图</span><span class="ex-badge"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M2 21h4V9H2v12zM23 10c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"/></svg></span></div>
<div class="ex"><span>多角度</span><span class="ex-badge"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M2 21h4V9H2v12zM23 10c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"/></svg></span></div>
<div class="ex"><span>细节图</span><span class="ex-badge"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M2 21h4V9H2v12zM23 10c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"/></svg></span></div>
<div class="ex"><span>使用图</span><span class="ex-badge"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M2 21h4V9H2v12zM23 10c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"/></svg></span></div>
<div class="ex"><span>包装图</span><span class="ex-badge"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M2 21h4V9H2v12zM23 10c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2z"/></svg></span></div>
</div>
<!-- 我的上传 (动态 5 槽) -->
<div class="np-section-h">
我的上传
<span class="counter">( <span class="num" id="np-upload-count">0</span> / 5 )</span>
</div>
<div class="upload-grid" id="np-grid"></div>
<!-- Dropzone (放在 grid 之后, 满 5 张时禁用) -->
<div class="upload-zone" id="np-zone" style="margin-top: 10px;">
<span class="uz-ic">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12"/></svg>
</span>
<span id="np-zone-text">点击或拖拽上传图片</span>
<span class="uz-hint">// 支持多选 · 最多 5 张 · JPG / PNG / WEBP</span>
</div>
</div>
</div>
<!-- 右栏: 文案 -->
<div class="np-right">
<div class="field">
<label class="field-label">商品名称<span class="req">*</span></label>
<input class="input" id="np-name" placeholder="例: 透真玻尿酸补水面膜">
</div>
<div class="field">
<label class="field-label">品类</label>
<select class="select" id="np-cat">
<option>美妆个护</option>
<option>服饰内衣</option>
<option>食品饮料</option>
<option>家居家电</option>
<option>数码 3C</option>
<option>个护清洁</option>
<option>运动户外</option>
<option>母婴亲子</option>
</select>
</div>
<div class="field">
<label class="field-label">核心卖点<span class="req">*</span></label>
<ul class="bullet-list" id="np-bullets" data-bl>
<li class="bl-add"><span class="num">+</span><input class="bl-input" placeholder="添加新卖点 · 回车确认"></li>
</ul>
</div>
<div class="field" style="margin-bottom:0;">
<label class="field-label">目标人群</label>
<input class="input" id="np-target" placeholder="例: 22-32 岁女性、敏感肌、办公室通勤">
</div>
</div>
</div>
</div>
<div class="np-footer">
<span class="np-meta">// 上传模式 · <span class="accent">不消耗 token</span> · 一次性创建</span>
<button class="btn" type="button" onclick="Shell.closeModal('new-product-bg')">取消</button>
<button class="btn btn-primary" type="button" id="np-create" disabled style="opacity:.5;cursor:not-allowed;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12l5 5L20 6"/></svg>
创建商品
</button>
</div>
</div>
</div>
<!-- Lightbox · 缩略图全屏预览 -->
<div class="np-lightbox" id="np-lightbox" onclick="Shell._closeLightbox()">
<button class="lb-x" type="button" onclick="event.stopPropagation();Shell._closeLightbox()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M18 6L6 18M6 6l12 12"/></svg>
</button>
<img id="np-lightbox-img" alt="">
<span class="lb-name" id="np-lightbox-name"></span>
</div>
`;
// 装订线 SVG 准星 · V2.1 签名元素(圆弧内凹的"+")
const cornerSvg = `<path d="M10.5 4C10.5 7.31371 7.81371 10 4.5 10H0.5V11H4.5C7.81371 11 10.5 13.6863 10.5 17V21H11.5V17C11.5 13.6863 14.1863 11 17.5 11H21.5V10H17.5C14.1863 10 11.5 7.31371 11.5 4V0H10.5V4Z" fill="currentColor"/>`;
const cornerMarks = `
@@ -163,6 +282,7 @@ window.Shell = {
src.remove();
}
document.body.insertAdjacentHTML('beforeend', toastHtml);
document.body.insertAdjacentHTML('beforeend', lightboxHtml);
document.addEventListener('keydown', e => {
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
@@ -172,6 +292,247 @@ window.Shell = {
});
},
// [DEPRECATED] 新建商品弹窗 · 已废弃,创建商品改为直跳 product-create.html
_bindNewProductModal_DEPRECATED() {
const modal = document.getElementById('new-product-bg');
if (!modal) return;
// 上传图册的内存状态 (供 collect 和 AI CTA 用)
const uploads = []; // { id, dataUrl, name, type, size }
// 收集表单状态(供 AI CTA 和创建按钮用)
const collect = () => {
const get = (id) => document.getElementById(id)?.value?.trim() || '';
return {
name: get('np-name'),
cat: get('np-cat'),
target: get('np-target'),
bullets: [...document.querySelectorAll('#np-bullets .bl-item .bl-text')].map(el => el.textContent),
uploadedCount: uploads.length,
uploads: uploads.map(u => ({ name: u.name, type: u.type })),
};
};
const MAX_UPLOADS = 5;
// 创建按钮: 商品名 + 至少 1 张图
const nameInput = document.getElementById('np-name');
const createBtn = document.getElementById('np-create');
const updateCreateBtn = () => {
const nameOk = (nameInput.value || '').trim().length > 0;
const uploadOk = uploads.length >= 1;
const ok = nameOk && uploadOk;
createBtn.disabled = !ok;
createBtn.style.opacity = ok ? '' : '.5';
createBtn.style.cursor = ok ? '' : 'not-allowed';
// 提示用户缺什么
if (!nameOk) createBtn.title = '请填写商品名称';
else if (!uploadOk) createBtn.title = '请至少上传 1 张商品图';
else createBtn.title = '';
};
nameInput.addEventListener('input', updateCreateBtn);
createBtn.addEventListener('click', () => {
if (createBtn.disabled) return;
const s = collect();
Shell.toast('商品已创建', `+ ${s.name}`);
Shell.closeModal('new-product-bg');
});
// 核心卖点: bullet-list
const list = document.getElementById('np-bullets');
const addInput = list.querySelector('.bl-add .bl-input');
const xSvg = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M4 4l8 8M12 4l-8 8"/></svg>';
const renumber = () => {
[...list.querySelectorAll('.bl-item')].forEach((li, i) => {
li.querySelector('.num').textContent = i + 1;
});
};
const bindX = (x) => {
x.addEventListener('click', () => {
const li = x.closest('li');
li.style.transition = 'opacity .15s, transform .15s';
li.style.opacity = 0;
li.style.transform = 'translateX(-8px)';
setTimeout(() => { li.remove(); renumber(); }, 150);
});
};
const addBullet = (text) => {
const t = (text || '').trim();
if (!t) return;
const li = document.createElement('li');
li.className = 'bl-item';
li.innerHTML = `<span class="num">0</span><span class="bl-text">${t.replace(/[<>&]/g, c => ({ '<':'&lt;','>':'&gt;','&':'&amp;' })[c])}</span><span class="bl-x" title="删除">${xSvg}</span>`;
list.querySelector('.bl-add').before(li);
bindX(li.querySelector('.bl-x'));
renumber();
};
addInput?.addEventListener('keydown', e => {
if (e.key === 'Enter') {
e.preventDefault();
addBullet(addInput.value);
addInput.value = '';
}
});
// 上传组件: 批量上传(MAX 5) + 5 固定槽 + 预览/删除 + AI CTA 联动
const zone = document.getElementById('np-zone');
const zoneText = document.getElementById('np-zone-text');
const grid = document.getElementById('np-grid');
const fileInput = document.getElementById('np-file');
const aiCtaEl = document.getElementById('np-ai-cta');
const aiLabel = document.getElementById('np-ai-label');
const uploadCount = document.getElementById('np-upload-count');
const syncAiCta = () => {
if (uploads.length === 0) {
aiCtaEl.classList.add('primary');
aiLabel.textContent = '没有图? 让 AI 帮我生成';
} else {
aiCtaEl.classList.remove('primary');
aiLabel.textContent = '用 AI 加工 / 生成模特上身图';
}
};
const syncZone = () => {
const full = uploads.length >= MAX_UPLOADS;
zone.classList.toggle('full', full);
zoneText.textContent = full ? `已达上限 (${MAX_UPLOADS} / ${MAX_UPLOADS})` : '点击或拖拽上传图片';
};
const syncCounter = () => {
uploadCount.textContent = uploads.length;
};
const thumbXSvg = '<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 4l8 8M12 4l-8 8"/></svg>';
const esc = (s) => s.replace(/[<>&"]/g, c => ({ '<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;' })[c]);
const renderGrid = () => {
const filledHtml = uploads.map(u => `
<div class="up-thumb" data-id="${u.id}">
<img src="${u.dataUrl}" alt="${esc(u.name)}">
<button class="slot-x" type="button" title="删除">${thumbXSvg}</button>
</div>
`).join('');
const emptyCount = MAX_UPLOADS - uploads.length;
const emptyHtml = Array.from({ length: emptyCount }, () => `<div class="up-slot-empty" data-action="add">无预览</div>`).join('');
grid.innerHTML = filledHtml + emptyHtml;
// 已填充槽: 点击预览 + X 删除
grid.querySelectorAll('.up-thumb').forEach(thumb => {
const id = thumb.dataset.id;
thumb.querySelector('.slot-x').addEventListener('click', (e) => {
e.stopPropagation();
const idx = uploads.findIndex(u => u.id === id);
if (idx >= 0) {
const removed = uploads.splice(idx, 1)[0];
Shell.toast('已删除', removed.name);
refreshAll();
}
});
thumb.addEventListener('click', () => {
const u = uploads.find(x => x.id === id);
if (u) Shell._openLightbox(u.dataUrl, u.name);
});
});
// 空槽: 点击触发上传
grid.querySelectorAll('[data-action="add"]').forEach(slot => {
slot.addEventListener('click', () => fileInput.click());
});
};
const refreshAll = () => {
renderGrid();
syncAiCta();
syncZone();
syncCounter();
updateCreateBtn();
};
const addFiles = (fileList) => {
const remaining = MAX_UPLOADS - uploads.length;
if (remaining <= 0) {
Shell.toast('已达上传上限', `${MAX_UPLOADS} / ${MAX_UPLOADS} 张`);
return;
}
const incoming = [...fileList].filter(f => f.type.startsWith('image/'));
if (!incoming.length) return;
const accepted = incoming.slice(0, remaining);
const overflow = incoming.length - accepted.length;
let added = 0;
accepted.forEach(f => {
const reader = new FileReader();
reader.onload = (e) => {
uploads.push({
id: Date.now().toString(36) + Math.random().toString(36).slice(2, 6),
dataUrl: e.target.result,
name: f.name,
type: f.type,
size: f.size,
});
added++;
if (added === accepted.length) {
refreshAll();
const msg = overflow > 0
? `+ ${added} 张 · 超出 ${overflow} 张已忽略`
: `+ ${added} 张 · 共 ${uploads.length} / ${MAX_UPLOADS}`;
Shell.toast('图片已上传', msg);
}
};
reader.readAsDataURL(f);
});
};
fileInput.addEventListener('change', (e) => {
addFiles(e.target.files);
e.target.value = '';
});
zone.addEventListener('click', () => {
if (uploads.length < MAX_UPLOADS) fileInput.click();
});
zone.addEventListener('dragover', e => {
e.preventDefault();
if (uploads.length < MAX_UPLOADS) zone.style.borderColor = 'var(--heat)';
});
zone.addEventListener('dragleave', () => { zone.style.borderColor = ''; });
zone.addEventListener('drop', e => {
e.preventDefault();
zone.style.borderColor = '';
if (e.dataTransfer?.files?.length) addFiles(e.dataTransfer.files);
});
refreshAll();
// AI CTA: 把已填表单 + 上传图册存到 sessionStorage,跳到 AI 工作台
const aiCta = document.getElementById('np-ai-cta');
aiCta.addEventListener('click', (e) => {
e.preventDefault();
const s = collect();
sessionStorage.setItem('pending-product', JSON.stringify(s));
Shell.toast('正在跳转 AI 工作台', `带入 ${s.uploadedCount} 张图`);
setTimeout(() => { location.href = 'product-create.html'; }, 350);
});
updateCreateBtn();
},
_openLightbox(src, name) {
const lb = document.getElementById('np-lightbox');
const img = document.getElementById('np-lightbox-img');
const nm = document.getElementById('np-lightbox-name');
if (!lb || !img || lb.classList.contains('show')) return;
img.src = src;
if (nm) nm.textContent = name || '';
lb.classList.add('show');
this.lockScroll();
},
_closeLightbox() {
const lb = document.getElementById('np-lightbox');
if (!lb || !lb.classList.contains('show')) return;
lb.classList.remove('show');
this.unlockScroll();
},
toast(text, mono) {
const t = document.getElementById('__toast');
const txt = document.getElementById('__toast-txt');
@@ -182,14 +543,60 @@ window.Shell = {
this._tt = setTimeout(() => t.classList.remove('show'), 2400);
},
openModal(id) { document.getElementById(id)?.classList.add('show'); },
closeModal(id) { document.getElementById(id)?.classList.remove('show'); },
/* ─── Body scroll lock (引用计数 · 多 overlay 叠加安全) ─── */
_scrollLockCount: 0,
_scrollLockSnapshot: null,
lockScroll() {
if (++this._scrollLockCount > 1) return;
const docEl = document.documentElement;
const sbw = window.innerWidth - docEl.clientWidth;
this._scrollLockSnapshot = {
bodyOverflow: document.body.style.overflow,
bodyPaddingRight: document.body.style.paddingRight,
htmlOverflow: docEl.style.overflow,
};
document.body.style.overflow = 'hidden';
docEl.style.overflow = 'hidden';
if (sbw > 0) document.body.style.paddingRight = sbw + 'px';
},
unlockScroll() {
if (--this._scrollLockCount > 0) return;
this._scrollLockCount = 0;
const s = this._scrollLockSnapshot;
if (s) {
document.body.style.overflow = s.bodyOverflow;
document.body.style.paddingRight = s.bodyPaddingRight;
document.documentElement.style.overflow = s.htmlOverflow;
this._scrollLockSnapshot = null;
}
},
openModal(id) {
const el = document.getElementById(id);
if (!el || el.classList.contains('show')) return;
el.classList.add('show');
this.lockScroll();
},
closeModal(id) {
const el = document.getElementById(id);
if (!el || !el.classList.contains('show')) return;
el.classList.remove('show');
this.unlockScroll();
},
openDrawer(id) {
document.getElementById(id)?.classList.add('show');
document.getElementById(id + '-bg')?.classList.add('show');
const el = document.getElementById(id);
const bg = document.getElementById(id + '-bg');
if (!el || el.classList.contains('show')) return;
el.classList.add('show');
if (bg) bg.classList.add('show');
this.lockScroll();
},
closeDrawer(id) {
document.getElementById(id)?.classList.remove('show');
document.getElementById(id + '-bg')?.classList.remove('show');
const el = document.getElementById(id);
const bg = document.getElementById(id + '-bg');
if (!el || !el.classList.contains('show')) return;
el.classList.remove('show');
if (bg) bg.classList.remove('show');
this.unlockScroll();
}
};