@andy.ian/dsh-homing 2.1.14 → 2.1.15

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/index.js CHANGED
@@ -33,6 +33,7 @@ import { createRestartPolicy } from './restart/face.mjs';
33
33
  import * as compress from './lib/compress.mjs';
34
34
  import * as office from './lib/office.mjs';
35
35
  import * as markdown from './lib/markdown.mjs';
36
+ import { NAV_CSS, topNav } from './lib/nav.mjs';
36
37
  import * as windowRemote from './lib/window-remote.mjs';
37
38
  import { setOrientation, ensureLandscape } from './lib/orientation.mjs';
38
39
  import { protectSecret, unprotectSecret } from './lib/secret.mjs';
@@ -846,11 +847,12 @@ function renderRestartPage({ status, sessions, message, confirmForce, portState
846
847
 
847
848
  const policy = restartPolicy.status()
848
849
  const cfg = policy?.config ?? {}
849
- const nav = '<div class="nav"><a href="/">← 返回 DSH</a><a href="/files">文件</a><a href="/git">Git</a><a href="/term">终端</a><a href="/debug">调试</a></div>'
850
+ const nav = topNav()
850
851
 
851
852
  return '<!doctype html><html lang="zh-CN"><head><meta charset="utf-8">'
852
853
  + '<meta name="viewport" content="width=device-width,initial-scale=1">'
853
854
  + '<title>重启 DSH</title><style>'
855
+ + NAV_CSS
854
856
  + 'body{background:#12161d;color:#dbe2ea;font:14px/1.45 system-ui,-apple-system,"Noto Sans SC",sans-serif;margin:0 auto;padding:10px 12px 20px;max-width:620px}'
855
857
  + 'h1{font-size:17px;margin:0}.sub{color:#8b93a1;font-size:12px;margin:2px 0 8px}'
856
858
  + '.nav{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px}'
@@ -916,7 +918,7 @@ const DEBUG_HTML = `<!doctype html>
916
918
  <html lang="zh-CN"><head><meta charset="utf-8">
917
919
  <meta name="viewport" content="width=device-width, initial-scale=1">
918
920
  <title>调试 · DSH 手机入口</title>
919
- <style>
921
+ <style>${NAV_CSS}
920
922
  :root { color-scheme: dark; }
921
923
  body { margin:0; font-family: system-ui, -apple-system, "Noto Sans SC", sans-serif; background:#0f1115; color:#e8eaed; }
922
924
  .wrap { max-width: 620px; margin: 0 auto; padding: 20px 16px 60px; }
@@ -942,7 +944,7 @@ const DEBUG_HTML = `<!doctype html>
942
944
  .shots img { width:88px; height:88px; object-fit:cover; border-radius:8px; border:1px solid #262b36; }
943
945
  code { background:#1d2229; padding:1px 5px; border-radius:4px; font-size:12px; }
944
946
  </style></head>
945
- <body><div class="wrap">
947
+ <body><div class="wrap">${topNav({ current: '/debug' })}
946
948
  <h1>调试页</h1>
947
949
  <p class="sub">这一页不依赖移动端样式,界面被改坏时也能打开。</p>
948
950
  <p class="sub"><a href="/">← 返回 DSH</a> · <a href="/term">终端</a> · <a href="/files">文件</a> · <a href="/git">Git</a></p>
@@ -1043,7 +1045,7 @@ const ACCOUNT_HTML = `<!doctype html>
1043
1045
  <html lang="zh-CN"><head><meta charset="utf-8">
1044
1046
  <meta name="viewport" content="width=device-width, initial-scale=1">
1045
1047
  <title>账户 · DSH 手机入口</title>
1046
- <style>
1048
+ <style>${NAV_CSS}
1047
1049
  :root { color-scheme: dark; }
1048
1050
  body { margin:0; font-family: system-ui, -apple-system, "Noto Sans SC", sans-serif; background:#0f1115; color:#e8eaed; }
1049
1051
  .wrap { max-width: 640px; margin: 0 auto; padding: 24px 18px 48px; }
@@ -1060,7 +1062,7 @@ const ACCOUNT_HTML = `<!doctype html>
1060
1062
  ul { padding-left:18px; margin:8px 0 0; font-size:13px; color:#9aa4b2; }
1061
1063
  a { color:#7aa7ff; }
1062
1064
  </style></head>
1063
- <body><div class="wrap">
1065
+ <body><div class="wrap">${topNav({ current: '/dsh_homing/account' })}
1064
1066
  <h1>账户设置</h1>
1065
1067
  <p class="sub"><a href="/dsh_homing/devices">设备管理(吊销/删除已配对设备)→</a></p>
1066
1068
  <p class="sub"><a href="/">← 返回 DSH</a> · <a href="/term">终端</a> · <a href="/files">文件</a> · <a href="/git">Git</a></p>
@@ -1318,7 +1320,7 @@ const LOGIN_HTML = `<!doctype html>
1318
1320
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
1319
1321
  <meta name="robots" content="noindex, nofollow">
1320
1322
  <title>登录 · DSH</title>
1321
- <style>
1323
+ <style>${NAV_CSS}
1322
1324
  :root { color-scheme: dark; }
1323
1325
  * { box-sizing: border-box; }
1324
1326
  body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
@@ -1338,7 +1340,7 @@ const LOGIN_HTML = `<!doctype html>
1338
1340
  border: 1px solid rgba(255,80,80,.35); color: #ff9b9b; font-size: 13px; }
1339
1341
  .hint { margin-top: 18px; color: #6b7383; font-size: 12px; text-align: center; }
1340
1342
  </style></head>
1341
- <body><div class="card">
1343
+ <body><div class="card">${topNav()}
1342
1344
  <h1>DeepSeek Harness</h1>
1343
1345
  <p class="sub">请输入本机设置的账号密码</p>
1344
1346
  <form method="post" action="/login">
@@ -1357,7 +1359,7 @@ const RESET_HTML = `<!doctype html>
1357
1359
  <html lang="zh-CN"><head><meta charset="utf-8">
1358
1360
  <meta name="viewport" content="width=device-width, initial-scale=1">
1359
1361
  <title>重置密码 · DSH 手机入口</title>
1360
- <style>
1362
+ <style>${NAV_CSS}
1361
1363
  :root { color-scheme: dark; }
1362
1364
  body { margin:0; font-family: system-ui, -apple-system, "Noto Sans SC", sans-serif; background:#0f1115; color:#e8eaed; }
1363
1365
  .wrap { max-width: 460px; margin: 0 auto; padding: 32px 18px; }
@@ -1370,7 +1372,7 @@ const RESET_HTML = `<!doctype html>
1370
1372
  .msg { background:#2a2618; border:1px solid #514a2a; color:#e8d99a; padding:10px 12px; border-radius:9px; margin:12px 0 0; font-size:14px; }
1371
1373
  a { color:#7aa7ff; }
1372
1374
  </style></head>
1373
- <body><div class="wrap">
1375
+ <body><div class="wrap">${topNav()}
1374
1376
  <h1>重置密码</h1>
1375
1377
  <p>重置需要在<strong>运行 DSH 的那台电脑</strong>上取一个重置码——这确保只有能碰到这台机器的人才能重置。</p>
1376
1378
  {{message}}
@@ -3062,6 +3064,7 @@ function createBridge({ getUpstreamPort, mintCookie, auth, config, dir, secureCo
3062
3064
  res.end(`<!doctype html><meta charset="utf-8"><title>预览失败</title><body style="background:#161a20;color:#e6e8ee;font-family:system-ui;padding:24px">
3063
3065
  <h1 style="font-size:18px">预览失败</h1>
3064
3066
  <p style="color:#9aa3b2">${escapeHtml(String(result.error ?? '未知原因'))}</p>
3067
+ <p><a style="color:#8ab4f8" href="/">← 返回 DSH</a> · <a style="color:#8ab4f8" href="/files?path=${encodeURIComponent(path.dirname(target))}">← 返回文件列表</a></p>
3065
3068
  <p><a style="color:#8ab4f8" href="/files/download?path=${encodeURIComponent(target)}">下载后用 WPS / Office 打开</a></p>
3066
3069
  </body>`);
3067
3070
  return;
@@ -3373,7 +3376,7 @@ button.danger{background:#3a2226;border-color:#54303a;color:#f0b6bf}
3373
3376
  a{color:#8ab4f8}
3374
3377
  </style>
3375
3378
  <h1>设备管理</h1>
3376
- <p class="sub"><a href="/dsh_homing/account">← 返回账户设置</a></p>
3379
+ <p class="sub"><a href="/">← 返回 DSH</a> · <a href="/dsh_homing/account">← 返回账户设置</a></p>
3377
3380
  <p class="sub">每台配对过的手机/浏览器各占一条。吊销后它的下一次请求立即失效,不用改密码、不用重启。</p>
3378
3381
  ${message ? `<div class="msg">${escapeHtml(message)}</div>` : ''}
3379
3382
  <table><thead><tr><th>设备</th><th>最后活跃</th><th>配对日期</th><th></th></tr></thead>
@@ -3,6 +3,8 @@
3
3
  * 全部服务端渲染 + 原生表单:微信/鸿蒙浏览器里最稳,不依赖任何 JS 框架。
4
4
  */
5
5
 
6
+ import { NAV_CSS, topNav } from './nav.mjs'
7
+
6
8
  const escapeHtml = (value) => String(value ?? '')
7
9
  .replaceAll('&', '&amp;')
8
10
  .replaceAll('<', '&lt;')
@@ -63,12 +65,12 @@ const STYLE = `
63
65
  .md-body a.md-img { border-bottom:0; }
64
66
  `
65
67
 
66
- export function layout({ title, body }) {
68
+ export function layout({ title, body, current = '/files' }) {
67
69
  return `<!doctype html>
68
70
  <html lang="zh-CN"><head><meta charset="utf-8">
69
71
  <meta name="viewport" content="width=device-width, initial-scale=1">
70
72
  <title>${escapeHtml(title)} · DSH 文件</title>
71
- <style>${STYLE}.flist { display: flex; flex-direction: column; }
73
+ <style>${STYLE}${NAV_CSS}.flist { display: flex; flex-direction: column; }
72
74
  .sortbar { display: flex; align-items: center; gap: 6px; padding: 6px 2px 8px; color: #8b93a1; font-size: 12px; }
73
75
  .sortlabel { margin-right: 2px; }
74
76
  .sortbtn { padding: 4px 9px; border-radius: 6px; background: #222833; border: 1px solid #333c48; color: #b9c3d1; font-size: 12px; }
@@ -83,7 +85,7 @@ export function layout({ title, body }) {
83
85
  .fempty { padding: 18px 4px; color: #8b93a1; }
84
86
  .flist .mm { grid-area: menu; }
85
87
  </style></head>
86
- <body><div class="wrap">${body}</div></body></html>`
88
+ <body><div class="wrap">${topNav({ current })}${body}</div></body></html>`
87
89
  }
88
90
 
89
91
  const messageHtml = (message, isError) => (message
@@ -316,11 +318,6 @@ ${entry.dir ? `<a class="mi" role="menuitem" data-act="paste" data-path="${escap
316
318
  <div style="display:flex;align-items:center;gap:8px;flex-wrap:nowrap;min-width:0">
317
319
  <h1 style="margin:0;flex:0 0 auto;font-size:18px">文件</h1>
318
320
  <div style="flex:1 1 auto;display:flex;align-items:center;justify-content:flex-end;gap:4px;flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none">
319
- <a class="btn ghost" href="/" style="${navStyle}">DSH</a>
320
- <a class="btn ghost" href="/term" style="${navStyle}">终端</a>
321
- <a class="btn ghost" href="/remote" style="${navStyle}">窗口</a>
322
- <a class="btn ghost" href="/vnc" style="${navStyle}">桌面</a>
323
- <a class="btn ghost" href="/git?path=${encodeURIComponent(info.path)}" style="${navStyle}">Git</a>
324
321
  <a class="btn ghost" href="/files?path=${encodeURIComponent(home)}" style="${navStyle}">HOME</a>
325
322
  <a class="btn ghost" href="/files?path=${encodeURIComponent(dataDir)}" style="${navStyle}">配置</a>
326
323
  ${parent}
@@ -511,10 +508,6 @@ export function renderGitPage({ repoPath, summary = null, args = '', result = nu
511
508
  style="flex:1;text-align:center;padding:10px;border-radius:8px;background:#2a2f3a;color:#c7cdd8;text-decoration:none;font-size:14px">刷新</a>
512
509
  <a class="btn ghost" href="/files?path=${encodeURIComponent(repoPath)}"
513
510
  style="flex:1;text-align:center;padding:10px;border-radius:8px;background:#2a2f3a;color:#c7cdd8;text-decoration:none;font-size:14px">看文件</a>
514
- <a class="btn ghost" href="/term"
515
- style="flex:1;text-align:center;padding:10px;border-radius:8px;background:#2a2f3a;color:#c7cdd8;text-decoration:none;font-size:14px">终端</a>
516
- <a class="btn ghost" href="/"
517
- style="flex:1;text-align:center;padding:10px;border-radius:8px;background:#2a2f3a;color:#c7cdd8;text-decoration:none;font-size:14px">DSH</a>
518
511
  </div>
519
512
  </div>
520
513
  ${message ? `<div class="msg">${escapeHtml(message)}</div>` : ''}
@@ -561,7 +554,7 @@ export function renderGitPage({ repoPath, summary = null, args = '', result = nu
561
554
  <pre>${escapeHtml(result.output ?? '')}</pre>
562
555
  `}
563
556
  <p class="crumbs">命令只执行 git 本身,不经过 shell;push/pull 用你本机已配置的凭据。</p>`
564
- return layout({ title: 'Git', body })
557
+ return layout({ title: 'Git', body, current: '/git' })
565
558
  }
566
559
 
567
560
  /** 编辑页:textarea + 保存 */
package/lib/nav.mjs ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * 插件内所有页面共用的顶部导航。
3
+ *
4
+ * 目标:无论从哪个页面(文件 / Git / 终端 / 窗口 / 桌面 / 调试 / 账户 / 登录…)
5
+ * 都能一眼看到并一键回到 DSH 主页。
6
+ */
7
+
8
+ export const NAV_CSS = `
9
+ .dsh-topnav { display:flex; gap:6px; overflow-x:auto; white-space:nowrap; align-items:center;
10
+ padding:8px 10px; margin:0 0 10px; background:#141920; border-bottom:1px solid #262b35;
11
+ position:sticky; top:0; z-index:30; -webkit-overflow-scrolling:touch; }
12
+ .dsh-topnav::-webkit-scrollbar { display:none; }
13
+ .dsh-topnav a { flex:0 0 auto; padding:7px 11px; border-radius:8px; background:#222833;
14
+ border:1px solid #333c48; color:#c7cdd8; text-decoration:none; font-size:13px; line-height:1.2; }
15
+ .dsh-topnav a:hover { background:#2c3442; }
16
+ .dsh-topnav a.home { background:#2f4b8f; border-color:#3f63b8; color:#fff; font-weight:600; }
17
+ .dsh-topnav .spacer { flex:1 1 auto; }
18
+ `
19
+
20
+ const LINKS = [
21
+ ['/', '← 返回 DSH', 'home'],
22
+ ['/files', '文件', ''],
23
+ ['/git', 'Git', ''],
24
+ ['/term', '终端', ''],
25
+ ['/remote', '窗口', ''],
26
+ ['/vnc', '桌面', ''],
27
+ ['/debug', '调试', ''],
28
+ ['/dsh_homing/account', '账户', ''],
29
+ ]
30
+
31
+ /**
32
+ * 顶部导航 HTML。
33
+ * @param {{ current?: string }} [options] current 可选:/files 等,用于高亮
34
+ */
35
+ export function topNav({ current = '' } = {}) {
36
+ const items = LINKS.map(([href, label, cls]) => {
37
+ const active = current !== '' && href === current
38
+ const classes = [cls, active ? 'active' : ''].filter(Boolean).join(' ')
39
+ const style = active ? ' style="background:#3a4658;color:#fff"' : ''
40
+ return '<a class="' + classes + '" href="' + href + '"' + style + '>' + label + '</a>'
41
+ }).join('')
42
+ return '<nav class="dsh-topnav">' + items + '</nav>'
43
+ }
package/lib/term-page.mjs CHANGED
@@ -8,6 +8,8 @@
8
8
  * 为了满足 CSP(不引外网脚本),xterm.js / xterm.css 都从本地 /term/vendor/ 提供,
9
9
  * 页面自身的脚本也从 /term/app.js 单独加载(不在 HTML 里内联)。
10
10
  */
11
+ import { NAV_CSS, topNav } from './nav.mjs'
12
+
11
13
  const escapeHtml = (value) => String(value ?? '')
12
14
  .replaceAll('&', '&amp;')
13
15
  .replaceAll('<', '&lt;')
@@ -83,15 +85,11 @@ export function renderTermPage({ cwd = '', host = '', user = '', connected = tru
83
85
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
84
86
  <title>终端 · DSH</title>
85
87
  <link rel="stylesheet" href="/term/vendor/xterm.css">
86
- <style>${STYLE}</style>
88
+ <style>${STYLE}${NAV_CSS}</style>
87
89
  </head>
88
90
  <body>
91
+ ${topNav({ current: '/term' })}
89
92
  <div class="bar">
90
- <a href="/">DSH</a>
91
- <a href="/files?path=${encodeURIComponent(cwd)}">文件</a>
92
- <a href="/git?path=${encodeURIComponent(cwd)}">Git</a>
93
- <a href="/remote">窗口</a>
94
- <a href="/vnc">桌面</a>
95
93
  ${shells.length > 0 ? `<form method="post" action="/term/shell" class="shellpick" style="display:flex;gap:4px;align-items:center;margin:0">
96
94
  <select name="shell" aria-label="终端类型" style="max-width:130px;padding:2px 4px;border-radius:5px;border:1px solid #333;background:#232323;color:#cfcfcf;font:inherit;font-size:11px">
97
95
  ${shellOptions}
package/lib/vnc-page.mjs CHANGED
@@ -4,6 +4,8 @@
4
4
  * 页面本身很薄,真正的协议在 /vnc/static/core/rfb.js 里;
5
5
  * 连接地址固定为同源的 /vnc/ws(由插件代理到本机 VNC 服务端)。
6
6
  */
7
+ import { NAV_CSS, topNav } from './nav.mjs'
8
+
7
9
  const escapeHtml = (value) => String(value ?? '')
8
10
  .replaceAll('&', '&amp;')
9
11
  .replaceAll('<', '&lt;')
@@ -53,14 +55,11 @@ export function renderVncPage({ host = '', user = '', target = '127.0.0.1:5900',
53
55
  <meta charset="utf-8">
54
56
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
55
57
  <title>桌面 · DSH</title>
56
- <style>${STYLE}</style>
58
+ <style>${STYLE}${NAV_CSS}</style>
57
59
  </head>
58
60
  <body>
61
+ ${topNav({ current: '/vnc' })}
59
62
  <div class="bar">
60
- <a href="/">DSH</a>
61
- <a href="/files">文件</a>
62
- <a href="/term">终端</a>
63
- <a href="/remote">窗口</a>
64
63
  <span class="spacer"></span>
65
64
  <span>${escapeHtml(user)}@${escapeHtml(host)}</span>
66
65
  <span id="status">${ready ? '未连接' : 'noVNC 资源缺失'}</span>
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * 页面只负责渲染;抓图与输入由 /remote/frame、/remote/input 完成。
5
5
  */
6
+ import { NAV_CSS, topNav } from './nav.mjs'
7
+
6
8
  const escapeHtml = (value) => String(value ?? '')
7
9
  .replaceAll('&', '&amp;')
8
10
  .replaceAll('<', '&lt;')
@@ -71,14 +73,11 @@ export function renderWindowPage({ host = '', user = '', supported = true, agent
71
73
  <meta charset="utf-8">
72
74
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
73
75
  <title>窗口共享 · DSH</title>
74
- <style>${STYLE}</style>
76
+ <style>${STYLE}${NAV_CSS}</style>
75
77
  </head>
76
78
  <body>
79
+ ${topNav({ current: '/remote' })}
77
80
  <div class="bar">
78
- <a href="/">DSH</a>
79
- <a href="/files">文件</a>
80
- <a href="/term">终端</a>
81
- <a href="/vnc">桌面</a>
82
81
  <span class="spacer"></span>
83
82
  <span>${escapeHtml(user)}@${escapeHtml(host)}</span>
84
83
  <span id="status">${supported ? (agent ? '代理已启动' : '代理未启动') : '仅支持 Windows'}</span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andy.ian/dsh-homing",
3
- "version": "2.1.14",
3
+ "version": "2.1.15",
4
4
  "type": "module",
5
5
  "description": "把本机 DSH 通过 SSH 反向隧道安全开放到手机浏览器:TLS 端到端(服务器只透传)、账号 + TOTP、局域网与公网双入口,随 DSH 启动。",
6
6
  "keywords": [