dsh-remote-panel 0.3.9 → 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 +32 -7
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1178,15 +1178,17 @@ window.__ModuleLoader__.load({
1178
1178
  由 installStatsTray() 读它的文本、精简后放到顶部右上角 */
1179
1179
  .uV2eYG_dock { display: none !important; }
1180
1180
 
1181
+ /* 顶部状态条:左边分支、右边统计,两端对齐(像手机状态栏的左右两组) */
1181
1182
  .dsh-stats-tray {
1182
1183
  position: fixed;
1183
1184
  top: max(2px, calc(var(--dsh-safe-top, 0px) - 24px));
1185
+ left: 14px;
1184
1186
  right: 14px;
1185
1187
  z-index: 57;
1186
- max-width: 62vw;
1187
- overflow: hidden;
1188
- text-overflow: ellipsis;
1189
- white-space: nowrap;
1188
+ display: flex;
1189
+ align-items: center;
1190
+ justify-content: space-between;
1191
+ gap: 16px;
1190
1192
  font-size: 10px;
1191
1193
  line-height: 16px;
1192
1194
  font-variant-numeric: tabular-nums;
@@ -1194,6 +1196,13 @@ window.__ModuleLoader__.load({
1194
1196
  pointer-events: none;
1195
1197
  letter-spacing: .01em;
1196
1198
  }
1199
+ .dsh-stats-tray > span {
1200
+ overflow: hidden;
1201
+ text-overflow: ellipsis;
1202
+ white-space: nowrap;
1203
+ min-width: 0;
1204
+ }
1205
+ .dsh-stats-tray > span:last-child { text-align: right; flex: 0 0 auto; }
1197
1206
 
1198
1207
  /* 输入条座位顶部有一段渐隐(DSH 原本渐到 #151517),在纯黑底上会显出一条灰带,
1199
1208
  这里把终点色换成纯黑,观感才对得上;底部那行状态(轮次/token/缓存)同理 */
@@ -1692,8 +1701,13 @@ window.__ModuleLoader__.load({
1692
1701
  const tray = document.createElement('div')
1693
1702
  tray.className = 'dsh-stats-tray'
1694
1703
  tray.setAttribute('aria-hidden', 'true')
1704
+ const left = document.createElement('span')
1705
+ const right = document.createElement('span')
1706
+ tray.append(left, right)
1695
1707
  document.body.appendChild(tray)
1696
1708
 
1709
+ // 只在手机宽度下出现:桌面端这套样式本来就没注入,元素留着会变成一个裸 div 掉到页面底部
1710
+ const narrow = window.matchMedia?.('(max-width: 1023px)')
1697
1711
  let frame = 0
1698
1712
  let shown = ''
1699
1713
  const format = (text) => {
@@ -1708,13 +1722,21 @@ window.__ModuleLoader__.load({
1708
1722
  }
1709
1723
  const sync = () => {
1710
1724
  frame = 0
1725
+ if (narrow !== undefined && !narrow.matches) {
1726
+ tray.style.display = 'none'
1727
+ shown = ''
1728
+ return
1729
+ }
1711
1730
  const dock = document.querySelector('.uV2eYG_dock')
1712
1731
  const raw = dock?.textContent ?? ''
1713
- const next = raw.trim() === '' ? '' : format(raw)
1732
+ const branch = dock?.querySelector('[data-composer-stat="git-branch"]')?.textContent?.trim() ?? ''
1733
+ const stats = raw.trim() === '' ? '' : format(raw)
1734
+ const next = `${branch}|${stats}`
1714
1735
  if (next === shown) return
1715
1736
  shown = next
1716
- tray.textContent = next
1717
- tray.style.display = next === '' ? 'none' : 'block'
1737
+ left.textContent = branch
1738
+ right.textContent = stats
1739
+ tray.style.display = branch === '' && stats === '' ? 'none' : 'flex'
1718
1740
  }
1719
1741
  const schedule = () => {
1720
1742
  if (frame !== 0) return
@@ -1722,9 +1744,12 @@ window.__ModuleLoader__.load({
1722
1744
  }
1723
1745
  const observer = new MutationObserver(schedule)
1724
1746
  observer.observe(document.body, { subtree: true, childList: true, characterData: true })
1747
+ const onViewport = () => schedule()
1748
+ narrow?.addEventListener?.('change', onViewport)
1725
1749
  sync()
1726
1750
  return () => {
1727
1751
  observer.disconnect()
1752
+ narrow?.removeEventListener?.('change', onViewport)
1728
1753
  if (frame !== 0) cancelAnimationFrame(frame)
1729
1754
  tray.remove()
1730
1755
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote-panel",
3
- "version": "0.3.9",
3
+ "version": "0.4.1",
4
4
  "description": "DSH 远程访问控制面:部署向导、状态面板与一键配对(EasyTier + Caddy),数据面保持进程外。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",