dsh-remote-panel 0.4.0 → 0.4.1

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 (2) hide show
  1. package/lib/client.js +10 -0
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1706,6 +1706,8 @@ window.__ModuleLoader__.load({
1706
1706
  tray.append(left, right)
1707
1707
  document.body.appendChild(tray)
1708
1708
 
1709
+ // 只在手机宽度下出现:桌面端这套样式本来就没注入,元素留着会变成一个裸 div 掉到页面底部
1710
+ const narrow = window.matchMedia?.('(max-width: 1023px)')
1709
1711
  let frame = 0
1710
1712
  let shown = ''
1711
1713
  const format = (text) => {
@@ -1720,6 +1722,11 @@ window.__ModuleLoader__.load({
1720
1722
  }
1721
1723
  const sync = () => {
1722
1724
  frame = 0
1725
+ if (narrow !== undefined && !narrow.matches) {
1726
+ tray.style.display = 'none'
1727
+ shown = ''
1728
+ return
1729
+ }
1723
1730
  const dock = document.querySelector('.uV2eYG_dock')
1724
1731
  const raw = dock?.textContent ?? ''
1725
1732
  const branch = dock?.querySelector('[data-composer-stat="git-branch"]')?.textContent?.trim() ?? ''
@@ -1737,9 +1744,12 @@ window.__ModuleLoader__.load({
1737
1744
  }
1738
1745
  const observer = new MutationObserver(schedule)
1739
1746
  observer.observe(document.body, { subtree: true, childList: true, characterData: true })
1747
+ const onViewport = () => schedule()
1748
+ narrow?.addEventListener?.('change', onViewport)
1740
1749
  sync()
1741
1750
  return () => {
1742
1751
  observer.disconnect()
1752
+ narrow?.removeEventListener?.('change', onViewport)
1743
1753
  if (frame !== 0) cancelAnimationFrame(frame)
1744
1754
  tray.remove()
1745
1755
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote-panel",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "DSH 远程访问控制面:部署向导、状态面板与一键配对(EasyTier + Caddy),数据面保持进程外。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",