dsh-plugin-image-workbench 1.1.8 → 1.1.10
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 +37 -0
- package/server/static/index.html +30 -0
package/package.json
CHANGED
package/server/app.py
CHANGED
|
@@ -420,6 +420,43 @@ async def health():
|
|
|
420
420
|
return {"ok": True, "version": VERSION}
|
|
421
421
|
|
|
422
422
|
|
|
423
|
+
def _ver_key(v: str) -> tuple:
|
|
424
|
+
"""把 x.y.z 解析成可比较的元组,非数字段按 0 处理。"""
|
|
425
|
+
out = []
|
|
426
|
+
for seg in (v or "").split("."):
|
|
427
|
+
out.append(int(seg) if seg.isdigit() else 0)
|
|
428
|
+
return tuple(out)
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
_UPGRADE_CACHE: dict = {"at": 0.0, "data": None}
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
@app.get("/api/upgrade")
|
|
435
|
+
async def api_upgrade():
|
|
436
|
+
"""对比 npm 上的最新版本,供左下角出「有新版本」提示。
|
|
437
|
+
|
|
438
|
+
走 npmmirror 直连(国内稳),10 分钟缓存;网络不通就当没有新版本,
|
|
439
|
+
绝不因为查版本失败打扰使用。trust_env=False:不吃代理环境变量,避免被带偏。
|
|
440
|
+
"""
|
|
441
|
+
now = time.time()
|
|
442
|
+
if _UPGRADE_CACHE["data"] is not None and now - _UPGRADE_CACHE["at"] < 600:
|
|
443
|
+
return JSONResponse(_UPGRADE_CACHE["data"])
|
|
444
|
+
data = {"current": VERSION, "latest": "", "has_new": False}
|
|
445
|
+
try:
|
|
446
|
+
import httpx
|
|
447
|
+
async with httpx.AsyncClient(trust_env=False, timeout=6) as c:
|
|
448
|
+
r = await c.get("https://registry.npmmirror.com/dsh-plugin-image-workbench/latest")
|
|
449
|
+
if r.status_code == 200:
|
|
450
|
+
lat = str(r.json().get("version") or "").strip()
|
|
451
|
+
data["latest"] = lat
|
|
452
|
+
data["has_new"] = bool(lat) and _ver_key(lat) > _ver_key(VERSION)
|
|
453
|
+
except Exception:
|
|
454
|
+
pass
|
|
455
|
+
_UPGRADE_CACHE["at"] = now
|
|
456
|
+
_UPGRADE_CACHE["data"] = data
|
|
457
|
+
return JSONResponse(data)
|
|
458
|
+
|
|
459
|
+
|
|
423
460
|
@app.get("/api/catalog")
|
|
424
461
|
async def api_catalog():
|
|
425
462
|
return JSONResponse(CATALOG)
|
package/server/static/index.html
CHANGED
|
@@ -288,6 +288,9 @@
|
|
|
288
288
|
.pill{display:inline-flex;align-items:center;gap:6px;background:#f7f5ff;border:1px solid var(--line);
|
|
289
289
|
border-radius:12px;padding:3px 9px;font-size:11px;color:var(--ink-2)}
|
|
290
290
|
.footer-note{margin-top:12px;font-size:10.5px;color:var(--ink-3);line-height:1.6}
|
|
291
|
+
/* 左栏底部版本号:跟在内容正下方,不与别的栏对齐;有新版本时多一行升级提示 */
|
|
292
|
+
.ver-foot{margin-top:16px;font-size:13px;color:var(--ink-3)}
|
|
293
|
+
.ver-foot .up-new{margin-top:5px;font-size:12px;color:var(--primary);cursor:default}
|
|
291
294
|
.strip-wrap{display:flex;align-items:center;gap:6px}
|
|
292
295
|
.strip{position:relative;flex:1;display:flex;gap:8px;overflow-x:auto;padding:6px 2px;min-height:100px;scroll-behavior:smooth}
|
|
293
296
|
.strip::-webkit-scrollbar{height:8px}
|
|
@@ -671,6 +674,10 @@
|
|
|
671
674
|
</div>
|
|
672
675
|
<div class="status" id="splitStatus"></div>
|
|
673
676
|
<div class="md" id="docRaw" style="display:none"></div>
|
|
677
|
+
<div class="ver-foot">
|
|
678
|
+
<div id="verFoot" title="当前工作台版本"></div>
|
|
679
|
+
<div class="up-new" id="upNote" hidden></div>
|
|
680
|
+
</div>
|
|
674
681
|
</section>
|
|
675
682
|
|
|
676
683
|
<!-- 配图工坊 -->
|
|
@@ -4730,6 +4737,29 @@ setInterval(refreshPool, 10000);
|
|
|
4730
4737
|
})
|
|
4731
4738
|
.catch(function(){}); // 状态读不到就保持默认说明,不影响轮播
|
|
4732
4739
|
})();
|
|
4740
|
+
|
|
4741
|
+
/* 左下角版本号:/health 返回插件版本(取自 package.json),读不到就留空 */
|
|
4742
|
+
(function(){
|
|
4743
|
+
fetch('/health', {cache: 'no-store'})
|
|
4744
|
+
.then(function(r){ return r.ok ? r.json() : null; })
|
|
4745
|
+
.then(function(d){
|
|
4746
|
+
var el = document.getElementById('verFoot');
|
|
4747
|
+
if (el && d && d.version) el.textContent = 'v' + d.version;
|
|
4748
|
+
})
|
|
4749
|
+
.catch(function(){});
|
|
4750
|
+
/* 有新版本就在版本号下面提示一行;查失败就当没有,不打扰使用 */
|
|
4751
|
+
fetch('/api/upgrade', {cache: 'no-store'})
|
|
4752
|
+
.then(function(r){ return r.ok ? r.json() : null; })
|
|
4753
|
+
.then(function(d){
|
|
4754
|
+
var el = document.getElementById('upNote');
|
|
4755
|
+
if (!el || !d || !d.has_new || !d.latest) return;
|
|
4756
|
+
el.hidden = false;
|
|
4757
|
+
el.textContent = '发现新版本 v' + d.latest + ',建议升级 →';
|
|
4758
|
+
el.title = '当前 v' + d.current + '。在 DSH「插件」里更新即可;'
|
|
4759
|
+
+ '或在插件目录执行 npm i dsh-plugin-image-workbench@latest 后重跑 node install.mjs,装完重启 DSH。';
|
|
4760
|
+
})
|
|
4761
|
+
.catch(function(){});
|
|
4762
|
+
})();
|
|
4733
4763
|
</script>
|
|
4734
4764
|
|
|
4735
4765
|
<script>
|