dsh-plugin-image-workbench 1.1.9 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-image-workbench",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "type": "module",
5
5
  "description": "Bluxe手绘工坊 · 生图工作台(图文 / 摄影):DSH 侧栏图像生成工作台,默认使用内置本地账号池,亦支持任意 OpenAI 兼容接口(Base URL / API Key / 模型);可自定义工作台名称与图片存储目录。",
6
6
  "main": "./host.js",
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)
@@ -288,9 +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
- .panel.left{align-self:stretch;display:flex;flex-direction:column}
293
- .ver-foot{margin-top:auto;padding-top:12px;font-size:11px;color:var(--ink-3);opacity:.7}
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}
294
294
  .strip-wrap{display:flex;align-items:center;gap:6px}
295
295
  .strip{position:relative;flex:1;display:flex;gap:8px;overflow-x:auto;padding:6px 2px;min-height:100px;scroll-behavior:smooth}
296
296
  .strip::-webkit-scrollbar{height:8px}
@@ -674,7 +674,10 @@
674
674
  </div>
675
675
  <div class="status" id="splitStatus"></div>
676
676
  <div class="md" id="docRaw" style="display:none"></div>
677
- <div class="ver-foot" id="verFoot" title="当前工作台版本"></div>
677
+ <div class="ver-foot">
678
+ <div id="verFoot" title="当前工作台版本"></div>
679
+ <div class="up-new" id="upNote" hidden></div>
680
+ </div>
678
681
  </section>
679
682
 
680
683
  <!-- 配图工坊 -->
@@ -4744,6 +4747,18 @@ setInterval(refreshPool, 10000);
4744
4747
  if (el && d && d.version) el.textContent = 'v' + d.version;
4745
4748
  })
4746
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(){});
4747
4762
  })();
4748
4763
  </script>
4749
4764