dsh-plugin-image-workbench 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/app.py +42 -0
- package/server/smoke_check.py +1 -1
- package/server/static/index.html +15 -0
package/package.json
CHANGED
package/server/app.py
CHANGED
|
@@ -425,6 +425,48 @@ async def api_catalog():
|
|
|
425
425
|
return JSONResponse(CATALOG)
|
|
426
426
|
|
|
427
427
|
|
|
428
|
+
_SAMPLES_CACHE = {"at": 0.0, "data": None}
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
def _sample_progress() -> dict:
|
|
432
|
+
"""数一遍缩略图准备到哪了。
|
|
433
|
+
|
|
434
|
+
首次安装时 repo_images 是空的(这 500 多张图不进发布包),插件在后台慢慢补。
|
|
435
|
+
前端拿这个数字决定要不要在顶部提示条里说一句「先看到渐变占位是正常的」,
|
|
436
|
+
补完自动撤掉,不做成永久横幅。
|
|
437
|
+
"""
|
|
438
|
+
expected = have = 0
|
|
439
|
+
for key in ("styles", "layouts", "colors"):
|
|
440
|
+
for item in CATALOG.get(key) or []:
|
|
441
|
+
# catalog 里写成 images/individual/...,落到磁盘时去掉 images/ 前缀,
|
|
442
|
+
# 和前端 imgUrl() 的拼法、/img 路由的取法保持一致,否则永远数成 0 张。
|
|
443
|
+
rel = re.sub(r"^images/", "", str((item or {}).get("img") or "").strip())
|
|
444
|
+
if not rel:
|
|
445
|
+
continue
|
|
446
|
+
expected += 1
|
|
447
|
+
if (REPO_IMAGES / rel).is_file():
|
|
448
|
+
have += 1
|
|
449
|
+
return {
|
|
450
|
+
"total": expected,
|
|
451
|
+
"have": have,
|
|
452
|
+
"missing": expected - have,
|
|
453
|
+
"ready": expected == 0 or have >= expected,
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
@app.get("/api/samples")
|
|
458
|
+
async def api_samples(fresh: int = 0):
|
|
459
|
+
"""缩略图同步进度(只读)。补图是后台进行的,这里只报数。"""
|
|
460
|
+
now = time.time()
|
|
461
|
+
cached = _SAMPLES_CACHE["data"]
|
|
462
|
+
if cached is not None and not fresh and now - _SAMPLES_CACHE["at"] < 10:
|
|
463
|
+
return JSONResponse(cached)
|
|
464
|
+
data = await run_in_threadpool(_sample_progress)
|
|
465
|
+
_SAMPLES_CACHE["at"] = now
|
|
466
|
+
_SAMPLES_CACHE["data"] = data
|
|
467
|
+
return JSONResponse(data)
|
|
468
|
+
|
|
469
|
+
|
|
428
470
|
@app.get("/api/pool")
|
|
429
471
|
async def api_pool():
|
|
430
472
|
# 前端每 10 秒轮询一次,顺手在这里做离线自愈:号池后起也能自己从「离线」翻成在线
|
package/server/smoke_check.py
CHANGED
|
@@ -102,7 +102,7 @@ except Exception as e:
|
|
|
102
102
|
print('\n=== 2. 读接口 ===')
|
|
103
103
|
client = httpx.Client(base_url=BASE, trust_env=False, timeout=30)
|
|
104
104
|
routes = [
|
|
105
|
-
('/', 200), ('/health', 200), ('/api/catalog', 200), ('/api/pool', 200),
|
|
105
|
+
('/', 200), ('/health', 200), ('/api/catalog', 200), ('/api/samples', 200), ('/api/pool', 200),
|
|
106
106
|
('/api/monitor', 200), ('/api/recent', 200), ('/api/history', 200),
|
|
107
107
|
('/api/tasks', 200), ('/api/drafts', 200), ('/api/pool/check', 200),
|
|
108
108
|
('/api/pool/fails', 200), ('/api/pool/panel', 200),
|
package/server/static/index.html
CHANGED
|
@@ -612,6 +612,7 @@
|
|
|
612
612
|
<div class="header-ad" id="headerAd" title="使用提示">
|
|
613
613
|
<span class="ad-tag">提示</span>
|
|
614
614
|
<div class="ad-view"><div class="ad-track" id="adTrack">
|
|
615
|
+
<div class="ad-item" id="adSamples" title="刚安装成功时,缩略图会在后台自动补齐,补完刷新就是真图">缩略图先同步,渐变是占位</div>
|
|
615
616
|
<div class="ad-item">如果不知道怎么上手,可以试着直接点击「批量出图」。</div>
|
|
616
617
|
<div class="ad-item">使用过程中有任何问题,可以多看看公众号详细介绍。</div>
|
|
617
618
|
<div class="ad-item">如果发现其他问题,估计作者也搞不定,就直接问 AI 吧。</div>
|
|
@@ -4694,6 +4695,20 @@ setInterval(refreshPool, 10000);
|
|
|
4694
4695
|
}, EASE);
|
|
4695
4696
|
}
|
|
4696
4697
|
}, HOLD);
|
|
4698
|
+
|
|
4699
|
+
/* 缩略图那条只改 hover 文案、不动文字和节点:条数一变,上面的计数就错位,
|
|
4700
|
+
文字一长就被 440px 的框截成省略号。具体差多少张放在 title 里。 */
|
|
4701
|
+
var el = document.getElementById('adSamples');
|
|
4702
|
+
if(!el) return;
|
|
4703
|
+
fetch('/api/samples', {cache: 'no-store'})
|
|
4704
|
+
.then(function(r){ return r.ok ? r.json() : null; })
|
|
4705
|
+
.then(function(s){
|
|
4706
|
+
if(!s || !s.total) return;
|
|
4707
|
+
el.title = s.missing > 0
|
|
4708
|
+
? '缩略图后台同步中:已 ' + s.have + ' / ' + s.total + ' 张,还差 ' + s.missing + ' 张,补完刷新即可。'
|
|
4709
|
+
: '缩略图已全部就位(共 ' + s.total + ' 张)。';
|
|
4710
|
+
})
|
|
4711
|
+
.catch(function(){}); // 状态读不到就保持默认说明,不影响轮播
|
|
4697
4712
|
})();
|
|
4698
4713
|
</script>
|
|
4699
4714
|
|