Skip to content

12 个视觉参考图库与浏览器无限画布 AI 创作台(5,700+ 素材、中英提示词、多图对比、ComfyUI & MCP)· Visual reference library & infinite-canvas AI studio in the browser

fix: 根据 review 反馈优化构建管线、重新生成范围、灯箱快捷键与侧栏缩略图

SamLiu9591ffa7d608
diff --git a/post.py b/post.py
index 361743f..f6339b7 100644
--- a/post.py
+++ b/post.py
@@ -13,22 +13,22 @@ def put(name,data):
base,ext=name.rsplit('.',1);n=f'assets/{base}.{h8(b)}.{ext}';open(f'{D}/{n}','wb').write(b);A[name]=n;return n
put('poses.json',PJ);put('costumes.json',CJ);put('anime.json',AJ);put('portraits.json',RJ);put('depths.json',DJ)
put('expressions.json',EXJ);put('hair.json',HAJ);put('dynasties.json',DYJ);put('scenes.json',SCJ);put('lights.json',LIJ);put('props.json',PRJ);put('furniture.json',FUJ)
-for f in ['style.css','zip.js','extras.js','studio.js']: put(f,open(f'src/{f}','rb').read())
+for f in ['style.css','zip.js','extras.js','studio.js','history.js']: put(f,open(f'src/{f}','rb').read())
app=open('src/app.js').read()
if AH: app=app.replace("const AH='';",f"const AH='{AH}/';")
app=app.replace("'poses.json'","'/"+A['poses.json']+"'").replace("'costumes.json'","'/"+A['costumes.json']+"'").replace("'anime.json'","'/"+A['anime.json']+"'").replace("'portraits.json'","'/"+A['portraits.json']+"'").replace("'depths.json'","'/"+A['depths.json']+"'").replace("'expressions.json'","'/"+A['expressions.json']+"'").replace("'hair.json'","'/"+A['hair.json']+"'").replace("'dynasties.json'","'/"+A['dynasties.json']+"'").replace("'scenes.json'","'/"+A['scenes.json']+"'").replace("'lights.json'","'/"+A['lights.json']+"'").replace("'props.json'","'/"+A['props.json']+"'").replace("'furniture.json'","'/"+A['furniture.json']+"'")
put('app.js',app)
VER='posewear-v10-'+h8(''.join(A.values()))
idx=open('src/index.html').read()
-for f in ['style.css','app.js','zip.js','extras.js','studio.js']:
+for f in ['style.css','app.js','zip.js','extras.js','studio.js','history.js']:
idx=idx.replace(f'"{f}"',f'"/{A[f]}"')
idx=idx.replace('href="poses.json"',f'href="/{A["poses.json"]}"')
if WAT: idx=idx.replace('</body>',f'<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon=\'{{"token": "{WAT}"}}\'></script></body>')
open(f'{D}/index.html','w').write(idx)
-for f in ['style.css','app.js','zip.js','extras.js','studio.js']:
+for f in ['style.css','app.js','zip.js','extras.js','studio.js','history.js']:
if os.path.exists(f'{D}/{f}'): os.remove(f'{D}/{f}')
sw=open('src/sw.js').read().replace("const V='posewear-v9'",f"const V='{VER}'")
-sw=sw.replace("['./','index.html','style.css','app.js','studio.js','extras.js','zip.js','favicon.svg']",json.dumps(['/','/favicon.svg']+['/'+A[f] for f in ['style.css','app.js','studio.js','extras.js','zip.js','poses.json','depths.json']]))
+sw=sw.replace("['./','index.html','style.css','app.js','studio.js','extras.js','zip.js','history.js','favicon.svg']",json.dumps(['/','/favicon.svg']+['/'+A[f] for f in ['style.css','app.js','studio.js','extras.js','zip.js','history.js','poses.json','depths.json']]))
open(f'{D}/sw.js','w').write(sw)
import base64
inl=re.findall(r'<script>(.*?)</script>',idx,re.S)
diff --git a/src/history.js b/src/history.js
index f52b041..2d7709d 100644
--- a/src/history.js
+++ b/src/history.js
@@ -224,20 +224,10 @@
h: 1024
}];
}
- if (r.prompt) {
- const ex = $('#wbExtra');
- if (ex) ex.value = r.orig || r.prompt;
- }
- if (r.neutral != null && $('#wbNeutral')) {
- $('#wbNeutral').checked = !!r.neutral;
- }
- if (r.prov && WB._cfg) {
- WB._cfg.prov = r.prov;
- if (r.model) WB._cfg.model = r.model;
- }
}
+ A.lbClose();
A.setTab('studio');
- toast('已载入生成设置,可在工作台调整或直接生成');
+ toast('已载入照片,可在工作台调整或直接生成');
}
}
@@ -344,7 +334,7 @@
${r.mode != 'gen' && r.after ? '<button data-hlb="person">用作人物照片</button>' : ''}
<button data-hlb="del" class="ghost" style="color:var(--err,#e53e3e)">删除此记录</button>
</div>
- <p class="mu" style="margin-top:22px;line-height:2.1"><kbd>←</kbd><kbd>→</kbd>切换记录 <kbd>Esc</kbd>关闭</p>
+ <p class="mu" style="margin-top:22px;line-height:2.1"><kbd>←</kbd><kbd>→</kbd>切换记录 <kbd>C</kbd>复制提示词 <kbd>Esc</kbd>关闭</p>
`;
const slider = side.querySelector('.hlb-cmp input[type=range]');
@@ -386,15 +376,32 @@
}
}, true);
- // Intercept keyboard arrow keys when in history view
+ // Intercept keyboard shortcuts when in history lightbox view
addEventListener('keydown', e => {
if (A.st.tab == 'history' && !$('#lb')?.hidden) {
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
+ const ae = document.activeElement;
+ if (ae && /^(INPUT|SELECT|TEXTAREA)$/.test(ae.tagName)) return;
+ const k = (e.key || '').toLowerCase();
if (e.key == 'ArrowLeft') {
+ e.preventDefault();
e.stopImmediatePropagation();
stepLb(-1);
} else if (e.key == 'ArrowRight') {
+ e.preventDefault();
e.stopImmediatePropagation();
stepLb(1);
+ } else if (e.key == 'ArrowUp' || e.key == 'ArrowDown') {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ } else if (k == 'c') {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ const r = L[curIndex];
+ if (r?.prompt) A.copy(r.prompt, '提示词');
+ } else if (k == 'f' || k == 'a' || k == 's') {
+ e.preventDefault();
+ e.stopImmediatePropagation();
}
}
}, true);
diff --git a/src/index.html b/src/index.html
index 73fcc86..5167853 100644
--- a/src/index.html
+++ b/src/index.html
@@ -49,7 +49,7 @@
<div class="flow"><span data-f="1">人物</span><i>›</i><span data-f="2">服装</span><i>›</i><span data-f="3">姿势</span><i>›</i><span data-f="4">生成</span></div>
<div class="quick"><div class="lab0">风格</div><div class="chips" id="wbStyles"></div><div class="row q2"><div class="row"><label class="lab">画幅<select id="wbAR"><option value="auto">自动</option><option value="2:3">竖 2:3</option><option value="3:4">竖 3:4</option><option value="9:16">竖 9:16</option><option value="1:1">方 1:1</option><option value="4:3">横 4:3</option><option value="16:9">横 16:9</option></select></label><label class="lab">数量<select id="wbN"><option>1</option><option>2</option><option>3</option><option>4</option></select></label></div></div></div>
<details class="adv"><summary>高级设置</summary><div class="adv-b"><label class="tg mt"><input type="checkbox" id="wbKeepBg"><span><b>保留原照片背景与光线</b></span></label><label class="tg mt"><input type="checkbox" id="wbNeutral"><span><b>减少误拦截</b><small>用更中性的描述发送,减少正常穿搭被误判,不改变服装和姿势</small></span></label><textarea id="wbExtra" rows="2" placeholder="补充要求(可选),例如:海边日落、半身构图、手拿咖啡…"></textarea><div class="row"><div class="seg sm" role="group" aria-label="提示词语言"><button data-pl="en">英文</button><button data-pl="zh">中文</button></div><span class="sp"></span><button class="sm ghost" id="wbCopyP">复制</button><button class="sm ghost" id="wbReP">重置</button></div><textarea id="wbPrompt" rows="8" aria-label="最终提示词"></textarea></div></details>
-<div class="hist"><div class="sh"><b>生成记录</b><span class="sp"></span><button class="sm ghost" id="wbHClr">清空</button></div><div class="hl" id="wbHist"></div></div>
+<div class="hist"><div class="sh"><b>生成记录</b><span class="sp"></span><button class="sm ghost" data-go="history">全部</button><button class="sm ghost" id="wbHClr">清空</button></div><div class="hl" id="wbHist"></div></div>
<span class="sp"></span>
<div class="gobar"><div class="gb-i"><span><b id="wbEst">将生成 1 张</b><small id="wbHint"></small></span><button class="cfgchip" id="wbCfg2" type="button"><span class="dot" id="wbDot2"></span><span id="wbProv2">未配置</span></button></div><button id="wbGo" class="pri big">生成</button></div>
</aside>
diff --git a/src/studio.js b/src/studio.js
index 5659074..a8e50df 100644
--- a/src/studio.js
+++ b/src/studio.js
@@ -230,7 +230,8 @@ let dbp;const db=()=>dbp||(dbp=new Promise((r,j)=>{const q=indexedDB.open('lk-st
const tx=async(m,f)=>{const d=await db();return new Promise((r,j)=>{const t=d.transaction('h',m),s=t.objectStore('h'),q=f(s);t.oncomplete=()=>r(q&&q.result);t.onerror=()=>j(t.error)})};
async function save(rec){try{await tx('readwrite',s=>s.put(rec));const all=await tx('readonly',s=>s.getAllKeys());if(all.length>200)await tx('readwrite',s=>{all.slice(0,all.length-200).forEach(k=>s.delete(k))})}catch(e){}}
let hu=[];async function hist(){let L=[];try{L=(await tx('readonly',s=>s.getAll()))||[]}catch(e){}L.sort((a,b)=>b.t-a.t);hu.forEach(URL.revokeObjectURL);hu=[];
- $('#wbHist').innerHTML=L.length?L.map(r=>{const u=URL.createObjectURL(r.after);hu.push(u);return`<button data-t="${r.t}" title="${esc(new Date(r.t).toLocaleString('zh-CN')+(r.label?' · '+r.label:''))}"><img src="${u}" alt="历史结果"><span>${r.mode=='gen'?'生图':'试穿'} · ${esc(new Date(r.t).toLocaleTimeString('zh-CN',{hour:'2-digit',minute:'2-digit'}))}</span><i data-del="${r.t}" aria-label="删除">×</i></button>`}).join(''):'<p class="fine">还没有生成记录</p>';W.hist=L}
+ const list=L.slice(0,30);
+ $('#wbHist').innerHTML=list.length?(list.map(r=>{const u=URL.createObjectURL(r.after);hu.push(u);return`<button data-t="${r.t}" title="${esc(new Date(r.t).toLocaleString('zh-CN')+(r.label?' · '+r.label:''))}"><img src="${u}" alt="历史结果"><span>${r.mode=='gen'?'生图':'试穿'} · ${esc(new Date(r.t).toLocaleTimeString('zh-CN',{hour:'2-digit',minute:'2-digit'}))}</span><i data-del="${r.t}" aria-label="删除">×</i></button>`}).join('')+(L.length>30?`<button class="hist-more" data-go="history" title="查看全部 ${L.length} 条记录"><b>全部</b><small>${L.length}条 ↗</small></button>`:'')):'<p class="fine">还没有生成记录</p>';W.hist=L}
$('#wbHist').onclick=async e=>{const d=e.target.closest('[data-del]');if(d){e.stopPropagation();const rec=(W.hist||[]).find(x=>x.t==d.dataset.del);await tx('readwrite',s=>s.delete(+d.dataset.del));await hist();if(rec)toast('已删除 1 条记录',async()=>{await tx('readwrite',s=>s.put(rec));hist()});return}const b=e.target.closest('[data-t]');if(!b)return;const r=W.hist.find(x=>x.t==b.dataset.t);if(r){W.results=[r];show(0,(PROV[r.prov]||{name:r.prov}).name+' · '+r.model+' · '+new Date(r.t).toLocaleString('zh-CN'));$('#wbStage').scrollIntoView({behavior:'smooth',block:'nearest'})}};
$('#wbHClr').onclick=async()=>{const all=W.hist||[];if(!all.length)return toast('还没有生成记录');await tx('readwrite',s=>s.clear());await hist();toast(`已清空 ${all.length} 条记录`,async()=>{await tx('readwrite',s=>{all.forEach(r=>s.put(r))});hist()})};
// ---------- 对外 ----------
diff --git a/src/style.css b/src/style.css
index 86f5039..5496409 100644
--- a/src/style.css
+++ b/src/style.css
@@ -539,6 +539,10 @@ button:active:not(:disabled){transform:scale(.97)}.tabs button:active,.chip:acti
#wbSentD{margin:8px 2px 0;font-size:12px;color:var(--tx2)}#wbSentD summary{cursor:pointer;width:max-content}
#wbSentD pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:160px;overflow:auto;background:var(--sf);border-radius:10px;padding:8px 10px;margin:6px 0 0;font-size:11.5px}
#wbHist em{position:absolute;left:4px;top:4px;font-style:normal;font-size:10px;background:rgba(0,0,0,.55);color:#fff;border-radius:6px;padding:0 4px}
+.hl button.hist-more{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:4px;font-size:11px;color:var(--mu);text-align:center;background:var(--card);border:1px dashed var(--line);cursor:pointer}
+.hl button.hist-more:hover{color:var(--tx);border-color:var(--pri);transform:none}
+.hl button.hist-more b{font-size:12px;display:block;color:var(--tx)}
+.hl button.hist-more small{font-size:10px;color:var(--mu);display:block}
.grid:empty{min-height:0}
.ssr .ssl{display:block;height:100%}.ssr .ph{cursor:pointer}.ssr h3 a{color:inherit;text-decoration:none}
diff --git a/src/sw.js b/src/sw.js
index f031e38..3232dcb 100644
--- a/src/sw.js
+++ b/src/sw.js
@@ -1,4 +1,4 @@
-const V='posewear-v9';self.addEventListener('install',e=>{self.skipWaiting();e.waitUntil(caches.open(V).then(c=>c.addAll(['./','index.html','style.css','app.js','studio.js','extras.js','zip.js','favicon.svg'])))});
+const V='posewear-v9';self.addEventListener('install',e=>{self.skipWaiting();e.waitUntil(caches.open(V).then(c=>c.addAll(['./','index.html','style.css','app.js','studio.js','extras.js','zip.js','history.js','favicon.svg'])))});
self.addEventListener('activate',e=>e.waitUntil(caches.keys().then(ks=>Promise.all(ks.filter(k=>k!=V).map(k=>caches.delete(k))))));
self.addEventListener('fetch',e=>{const u=new URL(e.request.url);if(u.origin!=location.origin||u.pathname.startsWith('/api/')||e.request.method!='GET')return;
const img=/\/(p|c)\/(t|i|m)\//.test(u.pathname);e.respondWith(img?caches.match(e.request).then(r=>r||fetch(e.request).then(res=>{const cl=res.clone();caches.open(V+'-img').then(c=>c.put(e.request,cl));return res}))