@lls-a1/dsh-balance-float 1.1.44 → 1.1.45

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/client.js +27 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ Host 半边自己维护本地用量账本(按轮记账 + 余额轮询),浏
11
11
  @lls-a1/dsh-balance-float
12
12
  ```
13
13
 
14
- 在 DSH 的插件管理里**只输入包名**即可安装和更新(安装源可选国内镜像)。GitHub 仓库仅作为源码地址:https://github.com/ming-a1/dsh-balance-float
14
+ 在 DSH 的插件管理里**只输入包名**即可安装和更新(安装源可选国内镜像)。注意两点:① 本机 Host 进程的 `GIT_CONFIG_*` 环境变量已损坏,`github:` 形式的安装会失败,请用上面的 npm 包名;② 由 `pluginManager` 管理的 profile 里若存在其它 `link:` 依赖,安装前请先完成 pnpm 解析,否则 `npm install` 会因 `link:` 协议报 EUNSUPPORTEDPROTOCOL。GitHub 仓库仅作为源码地址:https://github.com/ming-a1/dsh-balance-float
15
15
  本地开发可以用 `link:/path/to/balance-float`,改完刷新页面即可生效。
16
16
 
17
17
  启用后 profile 里会多出一行 `id: balance-float`,可在 `config` 里覆盖账本路径、轮询间隔和 `apiKeyRef`(默认 `DEEPSEEK_API_KEY`,取不到时余额相关数字保持不动,不会归零)。
package/client.js CHANGED
@@ -30,6 +30,9 @@ window.__ModuleLoader__.load({
30
30
  const ROUTE = '/balance-float/snapshot';
31
31
  const ROUTE_UPDATE = '/balance-float/update';
32
32
  const NPM_SPEC = '@lls-a1/dsh-balance-float';
33
+ // Native modal support decides whether the mask lives in the top layer.
34
+ const DIALOG_OK =
35
+ typeof document !== 'undefined' && typeof document.createElement('dialog').showModal === 'function';
33
36
  const REPO_URL = 'https://github.com/ming-a1/dsh-balance-float';
34
37
  const POS_KEY = 'dsh.balance-float.position';
35
38
  // Official top-up page; the balance endpoint has no recharge API, so the
@@ -308,6 +311,8 @@ window.__ModuleLoader__.load({
308
311
  '.dbf-version.has-update{color:var(--dsw-alias-state-error-primary)}',
309
312
  '.dbf-version.has-update .dbf-version-glyph{opacity:1}',
310
313
  '.dbf-modal{position:fixed;top:0;right:0;bottom:0;left:0;height:100dvh;z-index:10;display:flex;align-items:center;justify-content:center;padding:calc(12px + env(safe-area-inset-top,0px)) 12px calc(12px + env(safe-area-inset-bottom,0px));background:rgba(0,0,0,.45);overscroll-behavior:contain;touch-action:none}',
314
+ '.dbf-dialog{position:fixed;top:0;right:0;bottom:0;left:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:calc(12px + env(safe-area-inset-top,0px)) 12px calc(12px + env(safe-area-inset-bottom,0px));border:0;background:transparent;color:inherit;display:flex;align-items:center;justify-content:center;overflow:auto;overscroll-behavior:contain}',
315
+ '.dbf-dialog::backdrop{background:rgba(0,0,0,.45)}',
311
316
  '.dbf-modal-card{width:min(308px,100%);max-height:100%;overflow:auto;touch-action:auto;overscroll-behavior:contain;padding:16px;border-radius:14px;box-shadow:0 18px 48px rgba(0,0,0,calc(.34 * var(--dbf-shadow,1)));background:var(--dsw-alias-bg-layer-1,Canvas);color:var(--dsw-alias-label-primary,CanvasText)}',
312
317
  '.dbf-modal-head{display:flex;align-items:center;gap:8px;margin-bottom:10px}',
313
318
  '.dbf-modal-icon{width:22px;height:22px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-overlay));color:var(--dsw-alias-brand-primary,#4d6bfe);font-size:12px;line-height:1}',
@@ -598,6 +603,21 @@ window.__ModuleLoader__.load({
598
603
  const [updateOpen, setUpdateOpen] = useState(shared.updateOpen);
599
604
  const updateCheckedAt = useRef(0);
600
605
  const [copied, setCopied] = useState(false);
606
+ const modalRef = useRef(null);
607
+
608
+ // A plain fixed <div> stays inside the shell's stacking context, so the
609
+ // page header kept painting above the mask. showModal() moves the element
610
+ // into the browser top layer, where the ::backdrop always covers the
611
+ // whole viewport — no z-index can beat it.
612
+ useEffect(() => {
613
+ const element = modalRef.current;
614
+ if (element === null || typeof element.showModal !== 'function' || element.open) return;
615
+ try {
616
+ element.showModal();
617
+ } catch {
618
+ // already open or detached — nothing to do
619
+ }
620
+ });
601
621
 
602
622
  /** Copy the install spec so the user can update from the plugin manager. */
603
623
  const copyInstallSpec = useCallback(async () => {
@@ -1635,12 +1655,17 @@ window.__ModuleLoader__.load({
1635
1655
  update === null || !updateOpen
1636
1656
  ? null
1637
1657
  : h(
1638
- 'div',
1658
+ DIALOG_OK ? 'dialog' : 'div',
1639
1659
  {
1640
- className: 'dbf-modal',
1660
+ ref: DIALOG_OK ? modalRef : undefined,
1661
+ className: DIALOG_OK ? 'dbf-dialog' : 'dbf-modal',
1641
1662
  role: 'dialog',
1642
1663
  'aria-modal': 'true',
1643
1664
  'aria-label': t('update.title'),
1665
+ onCancel: (event) => {
1666
+ event.preventDefault();
1667
+ setUpdateOpen(false);
1668
+ },
1644
1669
  onClick: (event) => {
1645
1670
  if (event.target === event.currentTarget) setUpdateOpen(false);
1646
1671
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lls-a1/dsh-balance-float",
3
- "version": "1.1.44",
3
+ "version": "1.1.45",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },