dsh-plugin-weapp-gateway 0.8.41 → 0.8.47
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/README.md +37 -3
- package/docs/multi-gateway-app-integration.md +2 -2
- package/lib/client.js +234 -37
- package/lib/index.mjs +31 -2
- package/lib/ui-state.mjs +36 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,6 +6,40 @@
|
|
|
6
6
|
|
|
7
7
|
`dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
|
|
8
8
|
|
|
9
|
+
### v0.8.47 · 手动地址方案不再显示鲸尾公网内容
|
|
10
|
+
|
|
11
|
+
- 中继信息块(「鲸尾公网服务 · 已注册」、中继连接器状态、单独中继二维码提示)只在「自动选择」和「鲸尾公网 · 小程序」方案下显示;「公网或其他手动地址」「局域网直连」「Cloudflare 外网」「Tailscale 私有网络」方案不再出现鲸尾公网相关内容。
|
|
12
|
+
- 切换到「公网或其他手动地址」时不再继承中继地址:有已配置的公网 WSS 入口则预填该地址,否则留空等待填写。
|
|
13
|
+
- 「鲸尾公网 · 小程序」方案下配对入口地址只读(地址由注册信息决定);需要自定义地址时改选「公网或其他手动地址」。自动选择的载荷与行为不变。
|
|
14
|
+
### v0.8.46 · 一键清除离线设备
|
|
15
|
+
|
|
16
|
+
- 「可信设备」新增 **一键清除离线设备(N)**:一次性吊销当前所有离线设备(确认后执行),在线设备不受影响;清除后这些设备需要重新配对才能连接。
|
|
17
|
+
- 新增仅回环管理接口 `POST /mgw/devices/revoke-offline`,返回 `{ removed, count }`;在线连接断开后的设备会被计入离线集合。
|
|
18
|
+
- 测试:auth 集成测试覆盖「关闭连接 → 标记离线 → 一键吊销 → 设备列表无残留」全流程;渲染测试断言按钮与离线数量。全量测试通过。
|
|
19
|
+
### v0.8.45 · 恢复「鲸尾公网 · 小程序」方案
|
|
20
|
+
|
|
21
|
+
- 去掉 v0.8.44 加入的「公网入口 + 优先 P2P(建设中)」占位项。
|
|
22
|
+
- 恢复「鲸尾公网 · 小程序」独立方案(未注册时禁用):选中即切换服务端配对模式并生成中继专用二维码;帮助气泡、注册提示与文档同步恢复,保存的 relay 配对模式重新作为默认方案(与整合前一致)。
|
|
23
|
+
- 「连接方案」其余选项保持 v0.8.44 的整合结果:自动选择 / 局域网直连 / Cloudflare 外网 / Tailscale 私有网络 / 公网或其他手动地址,统一地址输入框不变。全量测试通过。
|
|
24
|
+
### v0.8.44 · 配对选项整合(对齐上游「连接方案」)
|
|
25
|
+
|
|
26
|
+
- 「配对连接方式」更名为「连接方案」,选项按上游整合:**自动选择 / 局域网直连 / 公网入口 + 优先 P2P(建设中,禁用)/ Cloudflare 外网 / Tailscale 私有网络 / 公网或其他手动地址**。
|
|
27
|
+
- 去掉独立的「鲸尾公网 · 小程序」选项:已注册的中继由「自动选择」自动带上(小程序仍优先使用中继);旧保存的 relay 配对模式在面板打开时自动迁回 direct,保证自动选择继续生成含公网/局域网/中继的多路载荷。
|
|
28
|
+
- 所有方案共用统一的「配对入口地址」输入框(与上游一致):编辑即切到「公网或其他手动地址」;Tailscale 方案下该输入框变为主机 Tailscale 地址,保留裸 IP 自动补全与校验。
|
|
29
|
+
- 帮助气泡按上游重写;Tailscale 方案下隐藏局域网状态行(上游样式)。自动选择、局域网、Cloudflare、Tailscale 的配对载荷与鉴权逻辑均未改动。
|
|
30
|
+
### v0.8.43 · 安装页移除与侧边栏开关
|
|
31
|
+
|
|
32
|
+
- 暂时移除「安装应用」分组:左侧栏保留 4 个分组(通用设置 / 连接与配对 / 可信设备 / 网络检测)。
|
|
33
|
+
- 「通用设置」新增「在左侧栏显示入口」开关:控制 Harness 侧边栏底部「鲸尾移动设备」按钮是否显示;偏好持久化到独立的 `0600` UI 状态文件,关闭后仍可从设置页打开并重新开启。
|
|
34
|
+
- 配对方式中的 **Tailscale 直连** 改为常显:检测到本机 Tailscale 地址时自动填入;没有检测到时可直接填写运行网关这台主机的 Tailscale IP(`100.x.x.x`,IPv6 用方括号),提交时自动补成 `ws://<ip>:3081/ws/mobile`;局域网入口未监听时选项禁用。
|
|
35
|
+
- 管理接口新增 `GET/POST /mgw/ui`(仅回环,`sidebarEntry` 布尔值);新增 `test/ui-state.test.mjs` 与 auth 集成断言。全量测试通过。
|
|
36
|
+
### v0.8.42 · 同步上游面板结构
|
|
37
|
+
|
|
38
|
+
- 左侧栏分组补齐为上游的 5 项:**通用设置 / 连接与配对 / 可信设备 / 网络检测 / 安装应用**;「服务端网络检测」从通用设置移到独立的「网络检测」分组。
|
|
39
|
+
- 新增「安装应用」分组:iOS(TestFlight 公测 + App Store 安装 TestFlight)与 Android(APK 下载 / Release 页)分页引导,自动读取官方 Release 最新版本(GitHub API + 本地 6 小时缓存);不内置上游的大体积截图,保留步骤、按钮与版本信息。
|
|
40
|
+
- 新增上游的**侧边栏入口**:Harness WebUI 侧边栏底部「鲸尾移动设备」按钮 + `shell.overlay` 弹窗,与设置页入口共享同一 open 状态;设置页入口保留。
|
|
41
|
+
- 配对方式中的 Tailscale 直连选项沿用 v0.8.41(检测到地址且局域网入口监听时可用)。
|
|
42
|
+
- 渲染测试同步更新(三个 slot 注册、5 个分组、安装引导内容),全量测试保持通过。
|
|
9
43
|
### v0.8.41 · Tailscale 参与配对选路
|
|
10
44
|
|
|
11
45
|
- 「配对连接方式」新增 **Tailscale 直连**:只使用本机 Tailscale 地址(`ws://100.x` / IPv6),二维码只包含 Tailscale 端点,不泄露公网或中继;检测不到地址或局域网入口未监听时该选项禁用。
|
|
@@ -312,7 +346,7 @@ dsh web
|
|
|
312
346
|
1. 在 WebUI 的「设置」中打开“鲸尾网关助手”。
|
|
313
347
|
2. 将“网关运行模式”设为“常驻开启”(短期配对也可选“临时开启”)。
|
|
314
348
|
3. 保持“设备鉴权”开启。
|
|
315
|
-
4.
|
|
349
|
+
4. 在「连接方案」选择「局域网直连」,确认配对入口地址为 `ws://<电脑局域网 IP>:3081/ws/mobile`。即使 Cloudflare Tunnel 已开启,也无需关闭它。选择框旁的问号会按当前网关环境解释各入口并给出场景建议,不会自动更改选择。
|
|
316
350
|
5. 填写设备名称并点击“生成配对二维码”。
|
|
317
351
|
6. 在 DSH App 或鲸尾小程序扫描二维码。
|
|
318
352
|
7. WebUI 的可信设备显示“在线”后即完成。
|
|
@@ -382,7 +416,7 @@ http://127.0.0.1:<本地端口>
|
|
|
382
416
|
|
|
383
417
|
二维码只能使用一次,并会在 5 分钟后过期;超时后在 WebUI 重新生成即可。
|
|
384
418
|
“自动选择”会生成带 `routes` 分类路由表的二维码,客户端按自身能力自动选路:DSH App 依次尝试上次连通地址、公网 WSS、局域网;小程序依次尝试上次连通地址、已注册的鲸尾中继(小程序的公网)、局域网——小程序不拨 Cloudflare/反代公网直连,因为这些域名不在小程序 socket 合法域名里。
|
|
385
|
-
|
|
419
|
+
原有「鲸尾公网 · 小程序」专用中继配对选项也保留:需要强制使用鲸尾中继、且二维码只给小程序使用时选择它;想用同一张码配对 App 和小程序时选择「自动选择」。
|
|
386
420
|
|
|
387
421
|
## Windows / macOS 家用电脑远程连接
|
|
388
422
|
|
|
@@ -392,7 +426,7 @@ http://127.0.0.1:<本地端口>
|
|
|
392
426
|
|
|
393
427
|
### Cloudflare Quick Tunnel(一键临时接入)
|
|
394
428
|
|
|
395
|
-
在「鲸尾网关助手 → 连接与配对」展开 Cloudflare 外网设置,选择「Quick Tunnel · 无需域名」并点击「一键开启」。面板连接后会取得随机的 `wss://<名称>.trycloudflare.com/ws/mobile`。生成“自动选择”二维码后,DSH App 会自动尝试公网 WSS
|
|
429
|
+
在「鲸尾网关助手 → 连接与配对」展开 Cloudflare 外网设置,选择「Quick Tunnel · 无需域名」并点击「一键开启」。面板连接后会取得随机的 `wss://<名称>.trycloudflare.com/ws/mobile`。生成“自动选择”二维码后,DSH App 会自动尝试公网 WSS 与局域网候选地址;小程序则走鲸尾中继或局域网。原有「鲸尾公网 · 小程序」专用中继选项仍可单独使用。关闭开关会停止隧道;DSH 再次启动时会恢复已开启的 Quick 模式并取得**新的随机地址**。
|
|
396
430
|
|
|
397
431
|
Quick Tunnel 无需 Cloudflare 账户、Token 或自己的公网域名,但地址在 DSH 重启或隧道重连后可能变化。若隧道地址变化,重新生成二维码供 DSH App 或小程序配对;**仅凭 PC 在线不能保证旧地址继续可用**。Cloudflare 将 Quick Tunnel 定位于测试和开发,当前有并发请求上限且不提供可用性保证。参见 [Cloudflare Quick Tunnel 文档](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/trycloudflare/)。
|
|
398
432
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
## App 与小程序同时连接
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
“连接方案”仅决定**新生成的配对码**使用哪种入口(直连地址 / Cloudflare / Tailscale / 手动地址),不限制当前网关接受的客户端类型,也不会关闭已建立的 WebSocket。已注册的鲸尾公网连接器在切换到直连配对后仍会保持运行;网关重启后也会根据已保存的中继注册信息恢复连接器。因此 App 可用直连地址配对,同时小程序继续使用原有中继连接。
|
|
8
8
|
|
|
9
9
|
新版管理页的“自动选择”会生成一个兼容双端的 v2 二维码:除顶层 `publicUrl` 与 `endpoints`(公网优先、局域网在后)外,还带可选的 `routes` 分类路由表(`lan` / `public` / `relay`)。客户端按自身能力自动选路:**小程序**第一候选是上次连通的地址,其后走已注册的鲸尾中继(小程序的公网)、再局域网,不拨 Cloudflare/反代公网直连(其域名不在小程序 socket 合法域名里,硬连只会失败);**DSH App** 走公网直连、再局域网,不使用中继。选择“局域网直连”则二维码只包含局域网候选地址。
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
原有「鲸尾公网 · 小程序」选项继续保留,用于强制生成仅供小程序使用的鲸尾中继二维码;它不包含 App 使用的局域网直连字段。需要一张二维码同时兼容 App 和小程序时,选择「自动选择」。
|
|
12
12
|
|
|
13
13
|
公网入口可供 App 和小程序使用,服务端仍要求设备鉴权;完整二维码包含一次性配对码,属于敏感凭据,不要公开分享二维码或 Base64URL 字符串。
|
|
14
14
|
|
package/lib/client.js
CHANGED
|
@@ -20,6 +20,22 @@ window.__ModuleLoader__.load({
|
|
|
20
20
|
}
|
|
21
21
|
const getOpen = () => open
|
|
22
22
|
|
|
23
|
+
// 侧边栏入口开关:由管理接口 /mgw/ui 持久化;apply() 时读取一次,
|
|
24
|
+
// 面板内切换后立即通知侧边栏按钮显示/隐藏。
|
|
25
|
+
let sidebarEntry = true
|
|
26
|
+
const sidebarListeners = new Set()
|
|
27
|
+
const getSidebarEntry = () => sidebarEntry
|
|
28
|
+
const setSidebarEntry = (value) => {
|
|
29
|
+
const next = value !== false
|
|
30
|
+
if (next === sidebarEntry) return
|
|
31
|
+
sidebarEntry = next
|
|
32
|
+
for (const listener of sidebarListeners) listener()
|
|
33
|
+
}
|
|
34
|
+
const subscribeSidebar = (listener) => {
|
|
35
|
+
sidebarListeners.add(listener)
|
|
36
|
+
return () => sidebarListeners.delete(listener)
|
|
37
|
+
}
|
|
38
|
+
|
|
23
39
|
// Shared Web UI / Desktop semantic tokens update with the host theme.
|
|
24
40
|
const restartNoticeStorageKey = 'mobile-gateway-dismissed-restart-notice'
|
|
25
41
|
let dismissedRestartInstance = null
|
|
@@ -342,6 +358,38 @@ window.__ModuleLoader__.load({
|
|
|
342
358
|
return tunnelUrl || statusUrl || lanUrl || inferredUrl(status.wsPath)
|
|
343
359
|
}
|
|
344
360
|
|
|
361
|
+
// 从手动输入里取主机:支持 `100.x.x.x`、`ws://100.x.x.x:3081/ws/mobile`、
|
|
362
|
+
// 以及带方括号的 IPv6。用于 Tailscale 路线的手动填写校验与补全。
|
|
363
|
+
function tailscaleHostOf(value) {
|
|
364
|
+
let raw = String(value || '').trim()
|
|
365
|
+
if (!raw) return ''
|
|
366
|
+
raw = raw.replace(/^(?:wss?|https?):\/\//i, '')
|
|
367
|
+
raw = raw.split(/[/?#]/)[0]
|
|
368
|
+
raw = raw.replace(/^\[|\]$/g, '')
|
|
369
|
+
return raw.replace(/:\d+$/, '')
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function isTailscaleInput(value) {
|
|
373
|
+
const host = tailscaleHostOf(value)
|
|
374
|
+
if (!host) return false
|
|
375
|
+
const octets = host.split('.').map(Number)
|
|
376
|
+
if (octets.length === 4 && octets.every((part) => Number.isInteger(part) && part >= 0 && part <= 255)) {
|
|
377
|
+
return octets[0] === 100 && octets[1] >= 64 && octets[1] <= 127
|
|
378
|
+
}
|
|
379
|
+
return /^fd7a:115c:a1e0:/i.test(host)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// 手动输入的裸 IP 补成 ws://<ip>:<lanPort><wsPath>;已是 URL 的原样返回。
|
|
383
|
+
function tailscaleEndpointOf(value, status) {
|
|
384
|
+
const raw = String(value || '').trim()
|
|
385
|
+
if (!raw) return ''
|
|
386
|
+
if (/^(?:wss?|https?):\/\//i.test(raw)) return raw
|
|
387
|
+
const port = status?.lan?.port || 3081
|
|
388
|
+
const wsPath = status?.wsPath || '/ws/mobile'
|
|
389
|
+
const host = raw.includes(':') ? `[${raw.replace(/^\[|\]$/g, '')}]` : raw
|
|
390
|
+
return `ws://${host}:${port}${wsPath}`
|
|
391
|
+
}
|
|
392
|
+
|
|
345
393
|
function connectionAdvice(status, publicSetup) {
|
|
346
394
|
if (!status) return { detected: '正在读取网关环境…', local: '', remote: '' }
|
|
347
395
|
const system = status.platform === 'darwin' ? 'macOS 电脑' : status.platform === 'win32' ? 'Windows 电脑' : status.platform === 'linux' ? 'Linux 服务器' : '当前设备'
|
|
@@ -490,6 +538,8 @@ window.__ModuleLoader__.load({
|
|
|
490
538
|
}
|
|
491
539
|
|
|
492
540
|
function DevicePanel() {
|
|
541
|
+
// 侧边栏入口开关:与侧边栏按钮共享同一状态(切换后立即生效)。
|
|
542
|
+
const sidebarOn = React.useSyncExternalStore(subscribeSidebar, getSidebarEntry, () => true)
|
|
493
543
|
const [activeSection, setActiveSection] = React.useState('general')
|
|
494
544
|
const [devices, setDevices] = React.useState(null)
|
|
495
545
|
const [showAllDevices, setShowAllDevices] = React.useState(false)
|
|
@@ -559,7 +609,11 @@ window.__ModuleLoader__.load({
|
|
|
559
609
|
const [deviceNotice, setDeviceNotice] = React.useState(null)
|
|
560
610
|
const [deviceNoticeError, setDeviceNoticeError] = React.useState(false)
|
|
561
611
|
const [revokingIds, setRevokingIds] = React.useState(() => new Set())
|
|
612
|
+
const [sidebarBusy, setSidebarBusy] = React.useState(false)
|
|
613
|
+
const [offlineClearing, setOfflineClearing] = React.useState(false)
|
|
614
|
+
|
|
562
615
|
const revokingIdsRef = React.useRef(new Set())
|
|
616
|
+
const manualUrlRef = React.useRef(false)
|
|
563
617
|
const automaticUrlRef = React.useRef('')
|
|
564
618
|
const pairingRouteRef = React.useRef('auto')
|
|
565
619
|
const pairingRouteSelectedRef = React.useRef(false)
|
|
@@ -601,7 +655,9 @@ window.__ModuleLoader__.load({
|
|
|
601
655
|
pairingRouteRef.current = savedRoute
|
|
602
656
|
setPairingRoute(savedRoute)
|
|
603
657
|
}
|
|
604
|
-
|
|
658
|
+
// 自定义地址与手动填写的 Tailscale 地址不能被轮询覆盖。
|
|
659
|
+
if (pairingRouteRef.current !== 'custom'
|
|
660
|
+
&& !(pairingRouteRef.current === 'tailscale' && manualUrlRef.current)) {
|
|
605
661
|
const preferredUrl = pairingUrlFor(pairingRouteRef.current, statusData)
|
|
606
662
|
if (automaticUrlRef.current && preferredUrl !== automaticUrlRef.current) setQr(null)
|
|
607
663
|
automaticUrlRef.current = preferredUrl
|
|
@@ -762,6 +818,7 @@ window.__ModuleLoader__.load({
|
|
|
762
818
|
return () => { active = false; window.clearInterval(timer) }
|
|
763
819
|
}, [refresh])
|
|
764
820
|
|
|
821
|
+
|
|
765
822
|
React.useEffect(() => {
|
|
766
823
|
if (!qr) return
|
|
767
824
|
const previousFocus = document.activeElement
|
|
@@ -792,8 +849,12 @@ window.__ModuleLoader__.load({
|
|
|
792
849
|
pairingRouteSelectedRef.current = true
|
|
793
850
|
pairingRouteRef.current = route
|
|
794
851
|
setPairingRoute(route)
|
|
852
|
+
manualUrlRef.current = false
|
|
795
853
|
if (route === 'custom') {
|
|
796
854
|
automaticUrlRef.current = ''
|
|
855
|
+
// 「公网或其他手动地址」不从其它方案(尤其鲸尾中继)继承地址:
|
|
856
|
+
// 有已配置的公网 WSS 入口时预填它,否则留空等待填写。
|
|
857
|
+
setPublicUrl((publicSetup && publicSetup.publicUrl) || '')
|
|
797
858
|
} else if (status) {
|
|
798
859
|
const nextUrl = pairingUrlFor(route, status)
|
|
799
860
|
automaticUrlRef.current = nextUrl
|
|
@@ -882,7 +943,7 @@ window.__ModuleLoader__.load({
|
|
|
882
943
|
method: 'POST',
|
|
883
944
|
headers: { 'Content-Type': 'application/json' },
|
|
884
945
|
body: JSON.stringify({
|
|
885
|
-
publicUrl: endpoint,
|
|
946
|
+
publicUrl: pairingRoute === 'tailscale' ? tailscaleEndpointOf(endpoint, status) : endpoint,
|
|
886
947
|
route: pairingRoute,
|
|
887
948
|
lanUrl: lanPairingUrl(status),
|
|
888
949
|
}),
|
|
@@ -998,6 +1059,49 @@ window.__ModuleLoader__.load({
|
|
|
998
1059
|
}
|
|
999
1060
|
}
|
|
1000
1061
|
|
|
1062
|
+
// 左侧栏入口开关:持久化到 /mgw/ui,并立即通知侧边栏按钮。
|
|
1063
|
+
const toggleSidebarEntry = async () => {
|
|
1064
|
+
if (sidebarBusy) return
|
|
1065
|
+
setSidebarBusy(true)
|
|
1066
|
+
setError(null)
|
|
1067
|
+
try {
|
|
1068
|
+
const data = await request('/mgw/ui', {
|
|
1069
|
+
method: 'POST',
|
|
1070
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1071
|
+
body: JSON.stringify({ sidebarEntry: !sidebarOn }),
|
|
1072
|
+
})
|
|
1073
|
+
setSidebarEntry(data.sidebarEntry !== false)
|
|
1074
|
+
} catch (cause) {
|
|
1075
|
+
setError(cause.message)
|
|
1076
|
+
} finally {
|
|
1077
|
+
setSidebarBusy(false)
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// 一键清除离线设备:吊销所有当前离线的已配对设备,在线设备不受影响。
|
|
1082
|
+
const clearOfflineDevices = async () => {
|
|
1083
|
+
const targets = Array.isArray(devices) ? devices.filter((device) => !device.online) : []
|
|
1084
|
+
if (targets.length === 0 || offlineClearing) return
|
|
1085
|
+
if (!window.confirm(`清除 ${targets.length} 台离线设备?清除后需要重新配对才能连接。`)) return
|
|
1086
|
+
setOfflineClearing(true)
|
|
1087
|
+
setDeviceNotice(null)
|
|
1088
|
+
setDeviceNoticeError(false)
|
|
1089
|
+
setError(null)
|
|
1090
|
+
try {
|
|
1091
|
+
const data = await request('/mgw/devices/revoke-offline', { method: 'POST' })
|
|
1092
|
+
const removedIds = new Set(Array.isArray(data.removed) ? data.removed : [])
|
|
1093
|
+
setDevices((current) => Array.isArray(current) ? current.filter((item) => !removedIds.has(item.id)) : current)
|
|
1094
|
+
setDeviceNotice(`已清除 ${data.count ?? removedIds.size} 台离线设备`)
|
|
1095
|
+
window.setTimeout(() => setDeviceNotice(null), 2200)
|
|
1096
|
+
} catch (cause) {
|
|
1097
|
+
setDeviceNoticeError(true)
|
|
1098
|
+
setDeviceNotice(`清除失败:${cause.message}`)
|
|
1099
|
+
setError(cause.message)
|
|
1100
|
+
} finally {
|
|
1101
|
+
setOfflineClearing(false)
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1001
1105
|
const revoke = async (device) => {
|
|
1002
1106
|
if (revokingIdsRef.current.has(device.id)) return
|
|
1003
1107
|
setDeviceNotice(null)
|
|
@@ -1115,7 +1219,7 @@ window.__ModuleLoader__.load({
|
|
|
1115
1219
|
React.createElement('path', { d: 'M6 6l12 12M18 6L6 18' }))))),
|
|
1116
1220
|
React.createElement('div', { className: 'mgw-body' },
|
|
1117
1221
|
React.createElement('nav', { ref: navRef, className: 'mgw-nav', 'aria-label': '鲸尾网关助手设置分组' },
|
|
1118
|
-
[['general', '通用设置'], ['pairing', '连接与配对'], ['devices', '可信设备']].map(([id, label]) =>
|
|
1222
|
+
[['general', '通用设置'], ['pairing', '连接与配对'], ['devices', '可信设备'], ['network', '网络检测']].map(([id, label]) =>
|
|
1119
1223
|
React.createElement('button', { key: id, type: 'button', 'aria-current': activeSection === id ? 'page' : undefined,
|
|
1120
1224
|
onClick: () => { setActiveSection(id); setConnectionHelpOpen(false); setToolsOpen(false) } }, label))),
|
|
1121
1225
|
React.createElement('div', { className: 'mgw-content', key: activeSection },
|
|
@@ -1177,7 +1281,26 @@ window.__ModuleLoader__.load({
|
|
|
1177
1281
|
status && !status.requireAuth
|
|
1178
1282
|
? React.createElement('p', { style: { ...styles.error, margin: '12px 0 0' } }, 'Debug 模式:本机 DSH 入口将跳过设备凭证校验;独立局域网入口仍强制鉴权。')
|
|
1179
1283
|
: null),
|
|
1180
|
-
React.createElement(
|
|
1284
|
+
React.createElement('section', { style: styles.card },
|
|
1285
|
+
React.createElement('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 14, alignItems: 'center' } },
|
|
1286
|
+
React.createElement('div', null,
|
|
1287
|
+
React.createElement('strong', null, '在左侧栏显示入口'),
|
|
1288
|
+
React.createElement('div', { style: { ...styles.muted, marginTop: 4 } }, sidebarOn
|
|
1289
|
+
? 'Harness 侧边栏底部显示「鲸尾移动设备」按钮;关闭后仅从设置页打开。'
|
|
1290
|
+
: '已隐藏侧边栏入口;可在这里重新开启。')),
|
|
1291
|
+
React.createElement('label', { style: { ...styles.switch, opacity: sidebarBusy ? .55 : 1 }, title: sidebarOn ? '隐藏左侧栏入口' : '在左侧栏显示入口' },
|
|
1292
|
+
React.createElement('input', {
|
|
1293
|
+
type: 'checkbox',
|
|
1294
|
+
role: 'switch',
|
|
1295
|
+
'aria-label': '在左侧栏显示入口',
|
|
1296
|
+
'aria-checked': sidebarOn,
|
|
1297
|
+
checked: sidebarOn,
|
|
1298
|
+
disabled: sidebarBusy,
|
|
1299
|
+
onChange: toggleSidebarEntry,
|
|
1300
|
+
style: styles.switchInput,
|
|
1301
|
+
}),
|
|
1302
|
+
React.createElement('span', { style: { ...styles.switchTrack, background: sidebarOn ? colors.success : colors.muted } }),
|
|
1303
|
+
React.createElement('span', { style: { ...styles.switchKnob, left: sidebarOn ? 21 : 3 } })))),
|
|
1181
1304
|
React.createElement('section', { style: styles.card },
|
|
1182
1305
|
React.createElement('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 14, alignItems: 'flex-start' } },
|
|
1183
1306
|
React.createElement('div', null,
|
|
@@ -1213,11 +1336,13 @@ window.__ModuleLoader__.load({
|
|
|
1213
1336
|
onClick: checkForPluginUpdate,
|
|
1214
1337
|
}, updateChecking ? '检查中…' : '重新检查')))),
|
|
1215
1338
|
),
|
|
1339
|
+
React.createElement('div', { hidden: activeSection !== 'network' },
|
|
1340
|
+
React.createElement(ServerNetworkDiagnostics, null)),
|
|
1216
1341
|
React.createElement('div', { hidden: activeSection !== 'pairing' },
|
|
1217
1342
|
React.createElement('section', { style: styles.card },
|
|
1218
1343
|
React.createElement('div', { className: 'mgw-setting-row' },
|
|
1219
1344
|
React.createElement('div', { style: { position: 'relative', display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6 }, onMouseLeave: () => setConnectionHelpOpen(false) },
|
|
1220
|
-
React.createElement('h3', { className: 'mgw-section-title', style: { marginBottom: 0 } }, '
|
|
1345
|
+
React.createElement('h3', { className: 'mgw-section-title', style: { marginBottom: 0 } }, '连接方案'),
|
|
1221
1346
|
React.createElement('button', {
|
|
1222
1347
|
type: 'button',
|
|
1223
1348
|
style: styles.helpButton,
|
|
@@ -1232,12 +1357,14 @@ window.__ModuleLoader__.load({
|
|
|
1232
1357
|
}, '?'),
|
|
1233
1358
|
connectionHelpOpen ? React.createElement('div', { id: 'mgw-route-help', role: 'tooltip', style: styles.helpBubble },
|
|
1234
1359
|
React.createElement('strong', null, '怎么选连接方式'),
|
|
1235
|
-
helpLine('
|
|
1236
|
-
helpLine('
|
|
1237
|
-
helpLine('Cloudflare
|
|
1238
|
-
helpLine('Quick Tunnel', '
|
|
1239
|
-
helpLine('
|
|
1240
|
-
helpLine('鲸尾公网 · 小程序', '
|
|
1360
|
+
helpLine('自动选择', '优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;没有公网入口时小程序自动使用已注册的鲸尾中继。适合大多数情况。'),
|
|
1361
|
+
helpLine('局域网直连', '手机与 DSH 在同一个可互访的局域网,使用 ws:// 私有地址;离开该网络就无法直连。'),
|
|
1362
|
+
helpLine('Cloudflare 外网', 'PC 主动连接 Cloudflare,外网用固定域名的 wss://;需要 Cloudflare 账户和域名。'),
|
|
1363
|
+
helpLine('Quick Channel(Quick Tunnel)', '无需账户或域名,Cloudflare 分配临时 wss:// 地址;隧道重建后地址可能变化。'),
|
|
1364
|
+
helpLine('Tailscale 私有网络', '可检测本机地址,或填写主机的 100.x 私有地址;手机与电脑需登录同一 tailnet。'),
|
|
1365
|
+
helpLine('鲸尾公网 · 小程序', '生成仅供鲸尾小程序使用的中继二维码;要同时配对 DSH App 和小程序,请选「自动选择」。'),
|
|
1366
|
+
helpLine('公网服务器连接', 'DSH 运行在有固定公网 IPv4 的 Linux 服务器上,配置公网入口后用 wss:// 公网 IP 连接。'),
|
|
1367
|
+
helpLine('公网或其他手动地址', '已配置公网 WSS 反代或只想指定一个固定地址时使用;编辑下方地址即可。'),
|
|
1241
1368
|
React.createElement('div', { style: { borderTop: `1px solid ${colors.border}`, marginTop: 10, paddingTop: 8 } },
|
|
1242
1369
|
React.createElement('strong', null, '结合当前环境'),
|
|
1243
1370
|
React.createElement('div', { style: { color: colors.muted, marginTop: 4 } }, advice.detected),
|
|
@@ -1246,7 +1373,9 @@ window.__ModuleLoader__.load({
|
|
|
1246
1373
|
React.createElement('div', { style: { color: colors.muted, marginTop: 6 } }, '面板无法判断手机当前网络;请按手机所在位置选择,提示不会替你修改选择。')))
|
|
1247
1374
|
: null),
|
|
1248
1375
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
|
|
1249
|
-
|
|
1376
|
+
// 连接方案:与上游一致的整合列表(保留「自动选择」)。Tailscale 私有网络
|
|
1377
|
+
// 与「公网或其他手动地址」共用下方统一的配对入口地址输入框。
|
|
1378
|
+
React.createElement(GatewaySelect, { style: styles.input, value: effectiveRoute, onChange: (event) => choosePairingRoute(event.target.value), disabled: !status, 'aria-label': '连接方案' },
|
|
1250
1379
|
React.createElement('option', { value: 'auto' }, '自动选择'),
|
|
1251
1380
|
React.createElement('option', { value: 'relay', disabled: !status?.relay }, status?.relay
|
|
1252
1381
|
? '鲸尾公网 · 小程序' : '鲸尾公网 · 尚未注册'),
|
|
@@ -1256,23 +1385,21 @@ window.__ModuleLoader__.load({
|
|
|
1256
1385
|
: '局域网直连 · 当前不可用')
|
|
1257
1386
|
: null,
|
|
1258
1387
|
status?.cloudflare?.supported
|
|
1259
|
-
? React.createElement('option', {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
// 仅在检测到 Tailscale 接口时提供专用路线;局域网入口未监听时禁用。
|
|
1264
|
-
status?.tailscale && Array.isArray(status.tailscale.addresses) && status.tailscale.addresses.length
|
|
1265
|
-
? React.createElement('option', { value: 'tailscale', disabled: !(Array.isArray(status.tailscale.urls) && status.tailscale.urls.length) },
|
|
1266
|
-
Array.isArray(status.tailscale.urls) && status.tailscale.urls.length
|
|
1267
|
-
? 'Tailscale 直连' : 'Tailscale 直连 · 请先开启局域网入口')
|
|
1268
|
-
: null,
|
|
1269
|
-
React.createElement('option', { value: 'custom' }, '手动输入地址')),
|
|
1388
|
+
? React.createElement('option', { value: 'cloudflare' }, 'Cloudflare 外网') : null,
|
|
1389
|
+
React.createElement('option', { value: 'tailscale', disabled: !(status && status.lan && status.lan.listening) },
|
|
1390
|
+
(status && status.lan && status.lan.listening) ? 'Tailscale 私有网络' : 'Tailscale 私有网络 · 请先开启局域网入口'),
|
|
1391
|
+
React.createElement('option', { value: 'custom' }, '公网或其他手动地址')),
|
|
1270
1392
|
status?.cloudflare?.supported && pairingRoute === 'auto'
|
|
1271
1393
|
? React.createElement('span', { style: { fontSize: 12, lineHeight: 1.5, fontWeight: 500,
|
|
1272
1394
|
color: 'var(--dsw-alias-link, #4176e6)' } }, '自动选择会优先尝试已就绪的公网入口,并同时保留局域网与 Tailscale 地址;DSH App 和小程序都可使用这些候选地址。配置 Cloudflare 请切换到“Cloudflare 外网”。')
|
|
1273
1395
|
: pairingRoute === 'tailscale'
|
|
1274
1396
|
? React.createElement('span', { style: { fontSize: 12, lineHeight: 1.5, fontWeight: 500,
|
|
1275
|
-
color: 'var(--dsw-alias-link, #4176e6)' } },
|
|
1397
|
+
color: 'var(--dsw-alias-link, #4176e6)' } }, (() => {
|
|
1398
|
+
const detected = Array.isArray(status?.tailscale?.urls) ? status.tailscale.urls : []
|
|
1399
|
+
return detected.length
|
|
1400
|
+
? `已检测到本机 Tailscale 地址:${detected.join('、')}(可直接生成二维码)。手机需登录同一 tailnet;微信小程序线上环境要求 wss 域名,可能只能供 DSH App 使用。`
|
|
1401
|
+
: '未检测到本机 Tailscale 地址:请填写运行网关这台主机的 Tailscale IP(不是手机 IP),例如 100.x.x.x 或 ws://100.x.x.x:3081/ws/mobile。手机与电脑需登录同一 tailnet。'
|
|
1402
|
+
})())
|
|
1276
1403
|
: status?.cloudflare?.supported && pairingRoute === 'cloudflare'
|
|
1277
1404
|
? React.createElement('span', { style: { fontSize: 12, lineHeight: 1.5, fontWeight: 500,
|
|
1278
1405
|
color: 'var(--dsw-alias-link, #4176e6)' } }, cloudflareReady
|
|
@@ -1280,18 +1407,21 @@ window.__ModuleLoader__.load({
|
|
|
1280
1407
|
: 'Cloudflare 尚未就绪,可在本页 Cloudflare 设置中开启并完成连通性检测。')
|
|
1281
1408
|
: null),
|
|
1282
1409
|
React.createElement('p', { style: { ...styles.muted, margin: '-6px 0 10px' } }, pairingRoute === 'relay'
|
|
1283
|
-
? '
|
|
1410
|
+
? '此方案生成仅供鲸尾小程序使用的中继二维码;DSH App 请选「自动选择」或「局域网直连」。'
|
|
1411
|
+
: pairingRoute === 'auto'
|
|
1412
|
+
? '公网 WSS 就绪时,DSH App 和小程序都会尝试公网、局域网与 Tailscale 地址;没有公网入口时,App 使用局域网或 Tailscale,小程序优先使用已注册的鲸尾中继,否则也使用局域网。生成新二维码不会断开已连接设备。'
|
|
1284
1413
|
: pairingRoute === 'tailscale'
|
|
1285
|
-
? '
|
|
1286
|
-
: '
|
|
1287
|
-
//
|
|
1288
|
-
|
|
1414
|
+
? '此方案只生成 Tailscale 私有网络二维码;手机与电脑需登录同一 tailnet。微信小程序线上环境要求 wss 域名,可能无法使用,请改用局域网/公网地址或 tailscale serve。'
|
|
1415
|
+
: '当前方案仅使用所选入口;编辑「配对入口地址」会切换到「公网或其他手动地址」。'),
|
|
1416
|
+
// 中继信息块只属于会用到中继的方案(中继 / 自动选择);
|
|
1417
|
+
// 手动地址、局域网、Cloudflare、Tailscale 方案不应出现鲸尾公网内容。
|
|
1418
|
+
(pairingRoute === 'relay' || pairingRoute === 'auto') && (relayInfo || relayConnector?.running || relayConnector?.delegatedTo || relayConnector?.lastError)
|
|
1289
1419
|
? (relayInfo
|
|
1290
1420
|
? React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0', fontWeight: 500 } },
|
|
1291
1421
|
'鲸尾公网服务 · 已注册', ' · ',
|
|
1292
1422
|
React.createElement('span', { style: { opacity: .8 } }, `设备 ID ${relayInfo.nodeId.slice(0, 8)}… · ${relayInfo.gatewayName}`),
|
|
1293
1423
|
React.createElement('div', { style: { marginTop: 6, padding: '9px 11px', borderRadius: 10, border: '1px solid color-mix(in srgb, var(--dsw-alias-state-warning-primary, #d98324) 26%, transparent)', background: 'color-mix(in srgb, var(--dsw-alias-state-warning-primary, #d98324) 9%, transparent)', fontWeight: 400 } },
|
|
1294
|
-
React.createElement('div', null, '公网 WSS 就绪时,DSH App 和小程序都会获得公网与局域网候选地址;没有公网入口时,App
|
|
1424
|
+
React.createElement('div', null, '公网 WSS 就绪时,DSH App 和小程序都会获得公网与局域网候选地址;没有公网入口时,App 使用局域网,小程序优先使用已注册的鲸尾公网中继,否则使用局域网。也可单独选择「鲸尾公网 · 小程序」强制生成专用中继二维码。'),
|
|
1295
1425
|
React.createElement('div', { style: { marginTop: 5 } }, relayConnector?.running || relayConnector?.delegatedTo
|
|
1296
1426
|
? '中继连接保持运行;切换配对方式不会断开已配对设备。'
|
|
1297
1427
|
: relayConnector?.lastError ? '中继连接器暂不可用,请检查网络或重新开启公网连接。'
|
|
@@ -1306,9 +1436,32 @@ window.__ModuleLoader__.load({
|
|
|
1306
1436
|
React.createElement('span', { style: { opacity: .8 } }, '如已自行部署连接器,请执行 systemctl restart dsh-connector。'))
|
|
1307
1437
|
: React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0' } }, '正在启动内置连接器…(中继模式需要一个本地连接器把小程序流量桥接进来,插件会自动准备)'))
|
|
1308
1438
|
: null),
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1439
|
+
// 与上游一致的统一「配对入口地址」输入框:所有方案共用;编辑即切换到
|
|
1440
|
+
// 「公网或其他手动地址」,Tailscale 方案则保留为手动主机地址。
|
|
1441
|
+
React.createElement('label', { style: styles.label, htmlFor: 'mgw-pair-address' }, pairingRoute === 'tailscale'
|
|
1442
|
+
? '主机 Tailscale 地址(运行网关的电脑,不是手机)'
|
|
1443
|
+
: '配对入口地址(手机需能访问)'),
|
|
1444
|
+
React.createElement('input', {
|
|
1445
|
+
id: 'mgw-pair-address',
|
|
1446
|
+
style: styles.input,
|
|
1447
|
+
value: publicUrl,
|
|
1448
|
+
onChange: (event) => {
|
|
1449
|
+
const value = event.target.value
|
|
1450
|
+
if (pairingRoute === 'tailscale') { manualUrlRef.current = true; setPublicUrl(value); return }
|
|
1451
|
+
if (pairingRoute !== 'custom') { choosePairingRoute('custom'); setPublicUrl(value); return }
|
|
1452
|
+
setPublicUrl(value)
|
|
1453
|
+
},
|
|
1454
|
+
placeholder: pairingRoute === 'tailscale'
|
|
1455
|
+
? '100.x.x.x 或 ws://100.x.x.x:3081/ws/mobile(IPv6 用 [fd7a:…])'
|
|
1456
|
+
: 'ws://192.168.1.10:3081/ws/mobile 或 wss://gateway.example.com/ws/mobile',
|
|
1457
|
+
readOnly: pairingRoute === 'relay',
|
|
1458
|
+
title: pairingRoute === 'relay' ? '鲸尾中继地址由注册信息决定;需要自定义地址请选「公网或其他手动地址」' : undefined,
|
|
1459
|
+
spellCheck: false,
|
|
1460
|
+
}),
|
|
1461
|
+
pairingRoute === 'tailscale' && publicUrl.trim() && !isTailscaleInput(publicUrl)
|
|
1462
|
+
? React.createElement('div', { style: { ...styles.error, margin: '-4px 0 8px' } }, '这里要填 100.64.0.0/10(或 fd7a:115c:a1e0::/48)的 Tailscale 私有地址。')
|
|
1463
|
+
: null,
|
|
1464
|
+
pairingRoute !== 'tailscale' && status && status.lan && status.lan.enabled
|
|
1312
1465
|
? React.createElement('div', { style: { ...styles.muted, margin: '-7px 0 10px', fontWeight: 500, color: status.lan.error ? colors.danger : status.lan.listening ? colors.success : 'var(--dsw-alias-link, #4176e6)' } },
|
|
1313
1466
|
status.lan.error
|
|
1314
1467
|
? `局域网监听失败:${status.lan.error}`
|
|
@@ -1325,18 +1478,19 @@ window.__ModuleLoader__.load({
|
|
|
1325
1478
|
`检测到 Tailscale 地址 ${status.tailscale.addresses.join('、')};开启局域网入口后可直接使用。`)
|
|
1326
1479
|
: null,
|
|
1327
1480
|
React.createElement('button', {
|
|
1328
|
-
style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) || (pairingRoute === 'custom' && !publicUrl.trim()) || (pairingRoute === 'cloudflare' && !cloudflareReady) || (pairingRoute === 'tailscale' && !(status?.
|
|
1481
|
+
style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) || (pairingRoute === 'custom' && !publicUrl.trim()) || (pairingRoute === 'cloudflare' && !cloudflareReady) || (pairingRoute === 'tailscale' && !(status?.lan?.listening && isTailscaleInput(publicUrl))) ? .65 : 1 },
|
|
1329
1482
|
disabled: busy || !(status && status.gatewayEnabled) ||
|
|
1330
1483
|
(pairingRoute === 'custom' && !publicUrl.trim()) ||
|
|
1331
1484
|
(pairingRoute === 'cloudflare' && !cloudflareReady) ||
|
|
1332
|
-
(pairingRoute === 'tailscale' && !(status?.
|
|
1485
|
+
(pairingRoute === 'tailscale' && !(status?.lan?.listening && isTailscaleInput(publicUrl))) ||
|
|
1333
1486
|
(pairingRoute === 'relay' && !status?.relay),
|
|
1334
1487
|
onClick: pair,
|
|
1335
1488
|
}, busy ? '正在生成…' : !(status && status.gatewayEnabled) ? '请先开启移动网关'
|
|
1336
1489
|
: pairingRoute === 'cloudflare' && !cloudflareReady
|
|
1337
1490
|
? status?.cloudflare?.enabled ? '等待 Cloudflare 外网就绪' : '先开启 Cloudflare Tunnel'
|
|
1338
|
-
: (pairingRoute === 'tailscale' && !
|
|
1339
|
-
: (pairingRoute === '
|
|
1491
|
+
: (pairingRoute === 'tailscale' && !status?.lan?.listening) ? '请先开启局域网入口'
|
|
1492
|
+
: (pairingRoute === 'tailscale' && !isTailscaleInput(publicUrl)) ? '填写主机 Tailscale 地址'
|
|
1493
|
+
: (pairingRoute === 'custom' && !publicUrl.trim()) ? '等待连接地址' : '生成配对二维码'),
|
|
1340
1494
|
React.createElement('p', { style: { ...styles.muted, margin: '10px 0 0' } }, '配对码仅可使用一次,5 分钟内有效。')),
|
|
1341
1495
|
pairingRoute === 'cloudflare' && status?.cloudflare?.supported
|
|
1342
1496
|
? React.createElement('section', { className: 'mgw-cloudflare-block', style: { ...styles.card, background: colors.card, border: 0, borderRadius: 16, padding: 18, marginTop: 16 } },
|
|
@@ -1432,6 +1586,12 @@ window.__ModuleLoader__.load({
|
|
|
1432
1586
|
deviceNotice || refreshNotice ? React.createElement('span', {
|
|
1433
1587
|
style: { ...styles.muted, color: deviceNoticeError ? colors.danger : colors.success },
|
|
1434
1588
|
}, deviceNotice || refreshNotice) : null,
|
|
1589
|
+
React.createElement('button', {
|
|
1590
|
+
style: { ...styles.button, opacity: offlineDevices.length === 0 ? .55 : 1, color: colors.danger },
|
|
1591
|
+
disabled: offlineDevices.length === 0 || offlineClearing,
|
|
1592
|
+
title: '吊销所有当前离线的已配对设备',
|
|
1593
|
+
onClick: clearOfflineDevices,
|
|
1594
|
+
}, offlineClearing ? '清除中…' : `一键清除离线设备(${offlineDevices.length})`),
|
|
1435
1595
|
React.createElement('button', {
|
|
1436
1596
|
style: { ...styles.button, opacity: refreshing ? .6 : 1 },
|
|
1437
1597
|
disabled: refreshing,
|
|
@@ -1471,6 +1631,32 @@ window.__ModuleLoader__.load({
|
|
|
1471
1631
|
return isOpen ? React.createElement(DevicePanel) : null
|
|
1472
1632
|
}
|
|
1473
1633
|
|
|
1634
|
+
// 侧边栏入口:与上游一致,在 Harness WebUI 侧边栏底部放一个「鲸尾移动设备」
|
|
1635
|
+
// 按钮,点击打开同一个管理弹窗;设置页入口保留,两个入口共享同一 open 状态。
|
|
1636
|
+
function FooterButton(props) {
|
|
1637
|
+
const isOpen = React.useSyncExternalStore(subscribe, getOpen, () => false)
|
|
1638
|
+
const visible = React.useSyncExternalStore(subscribeSidebar, getSidebarEntry, () => true)
|
|
1639
|
+
if (!visible) return null
|
|
1640
|
+
const wide = !!props.wide
|
|
1641
|
+
const iconSize = wide ? 20 : 22
|
|
1642
|
+
const icon = React.createElement('svg', { width: iconSize, height: iconSize, viewBox: '0 0 24 24', fill: 'none',
|
|
1643
|
+
stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, style: { flexShrink: 0 } },
|
|
1644
|
+
React.createElement('rect', { x: 6, y: 2, width: 12, height: 20, rx: 2.5 }),
|
|
1645
|
+
React.createElement('path', { d: 'M10 18h4' }))
|
|
1646
|
+
return React.createElement('button', {
|
|
1647
|
+
type: 'button', title: '鲸尾移动设备', 'aria-label': '鲸尾移动设备', 'aria-pressed': isOpen,
|
|
1648
|
+
onClick: () => setOpen(!isOpen),
|
|
1649
|
+
style: { cursor: 'pointer', background: 'transparent', border: 'none', color: 'inherit', font: 'inherit',
|
|
1650
|
+
display: 'flex', alignItems: 'center', justifyContent: wide ? 'flex-start' : 'center', gap: wide ? 8 : 0,
|
|
1651
|
+
boxSizing: 'border-box', width: wide ? 'calc(100% + 4px)' : 36, height: wide ? 42 : 36,
|
|
1652
|
+
margin: wide ? '4px -2px' : '3px 0', padding: wide ? '0 10px 0 8px' : 0, lineHeight: wide ? '22px' : 'normal' },
|
|
1653
|
+
}, icon, wide ? React.createElement('span', null, '鲸尾移动设备') : null)
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
function OverlayEntry() {
|
|
1657
|
+
const isOpen = React.useSyncExternalStore(subscribe, getOpen, () => false)
|
|
1658
|
+
return isOpen ? React.createElement(DevicePanel, null) : null
|
|
1659
|
+
}
|
|
1474
1660
|
const inject = ['slots']
|
|
1475
1661
|
function apply(ctx) {
|
|
1476
1662
|
// Upstream 0.10.1: the panel stylesheet is injected once through an
|
|
@@ -1490,6 +1676,17 @@ window.__ModuleLoader__.load({
|
|
|
1490
1676
|
{ name: 'settings.section', id: 'mobile-gateway', order: 35, label: () => NAV_LABEL },
|
|
1491
1677
|
() => React.createElement(SettingsEntry, null),
|
|
1492
1678
|
))
|
|
1679
|
+
// 侧边栏入口的显示开关来自管理接口;读取失败时保持默认显示。
|
|
1680
|
+
void request('/mgw/ui').then((data) => setSidebarEntry(data.sidebarEntry !== false)).catch(() => {})
|
|
1681
|
+
// 与上游一致:侧边栏底部入口 + shell overlay,共享同一个 open 状态。
|
|
1682
|
+
ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register(
|
|
1683
|
+
{ name: 'sidebar.footer.action', id: 'mobile-gateway-devices', order: 80, label: '鲸尾移动设备' },
|
|
1684
|
+
(props) => React.createElement(FooterButton, props),
|
|
1685
|
+
))
|
|
1686
|
+
ctx.slots.inject('shell.overlay', () => ctx.slots.register(
|
|
1687
|
+
{ name: 'shell.overlay', id: 'mobile-gateway-devices-panel', order: 100, label: '移动设备' },
|
|
1688
|
+
() => React.createElement(OverlayEntry, null),
|
|
1689
|
+
))
|
|
1493
1690
|
}
|
|
1494
1691
|
|
|
1495
1692
|
exports.apply = apply
|
package/lib/index.mjs
CHANGED
|
@@ -162,6 +162,7 @@ import { createFileUploadManager, FILE_UPLOAD_REQUEST_TYPES, FILE_UPLOAD_DEFAULT
|
|
|
162
162
|
import { assistantFinish, failureDetails, toolResultDetails, turnReasonDetails } from './session-event-details.mjs'
|
|
163
163
|
import { createNetworkDiagnostics } from './network-diagnostics.mjs'
|
|
164
164
|
import { isTailscaleIp, tailscaleInterfaceStatus } from './tailscale-addresses.mjs'
|
|
165
|
+
import { createUiState } from './ui-state.mjs'
|
|
165
166
|
|
|
166
167
|
const { createRegistry } = devicesModule
|
|
167
168
|
|
|
@@ -2871,6 +2872,7 @@ const plugin = {
|
|
|
2871
2872
|
relayEnsureTimer.unref?.()
|
|
2872
2873
|
}
|
|
2873
2874
|
const registry = createRegistry(deviceFile, { pairingTtlMs: options.pairingTtlMs })
|
|
2875
|
+
const uiState = createUiState(`${deviceFile}.ui.json`)
|
|
2874
2876
|
const wss = new WebSocketServer({
|
|
2875
2877
|
noServer: true,
|
|
2876
2878
|
maxPayload: options.maxPayloadBytes,
|
|
@@ -3443,6 +3445,14 @@ const plugin = {
|
|
|
3443
3445
|
if (body.mode === undefined && typeof body.enabled !== 'boolean') throw badRequest('mode or boolean enabled is required')
|
|
3444
3446
|
setGatewayMode(body.mode !== undefined ? body.mode : (body.enabled ? 'temporary' : 'disabled'), 'changed from management UI')
|
|
3445
3447
|
sendJson(res, 200, { gatewayEnabled, gatewayMode, waitExpiresAt, connectedClients: clients.size })
|
|
3448
|
+
} else if (req.method === 'GET' && p === '/mgw/ui') {
|
|
3449
|
+
sendJson(res, 200, { sidebarEntry: uiState.sidebarEntry })
|
|
3450
|
+
} else if (req.method === 'POST' && p === '/mgw/ui') {
|
|
3451
|
+
const body = await readBody(req)
|
|
3452
|
+
if (typeof body.sidebarEntry !== 'boolean') throw badRequest('sidebarEntry must be a boolean')
|
|
3453
|
+
uiState.setSidebarEntry(body.sidebarEntry)
|
|
3454
|
+
log(`sidebar entry ${body.sidebarEntry ? 'enabled' : 'disabled'} from management UI`)
|
|
3455
|
+
sendJson(res, 200, { sidebarEntry: uiState.sidebarEntry })
|
|
3446
3456
|
} else if (req.method === 'POST' && p === '/mgw/network-test') {
|
|
3447
3457
|
const abort = new AbortController()
|
|
3448
3458
|
const cancel = () => abort.abort()
|
|
@@ -3532,8 +3542,14 @@ const plugin = {
|
|
|
3532
3542
|
error.status = 409
|
|
3533
3543
|
throw error
|
|
3534
3544
|
}
|
|
3535
|
-
|
|
3536
|
-
|
|
3545
|
+
// 面板允许直接填主机 Tailscale IP;这里补成 ws://<ip>:<lanPort><wsPath>。
|
|
3546
|
+
const rawCandidate = typeof body.publicUrl === 'string' ? body.publicUrl.trim() : ''
|
|
3547
|
+
const bareTailscale = /^(?:\d{1,3}\.){3}\d{1,3}$/.test(rawCandidate)
|
|
3548
|
+
|| (/^[0-9a-f:]+$/i.test(rawCandidate) && rawCandidate.includes(':'))
|
|
3549
|
+
const candidate = rawCandidate
|
|
3550
|
+
? normalizePublicUrl(bareTailscale
|
|
3551
|
+
? `ws://${rawCandidate.includes(':') ? `[${rawCandidate}]` : rawCandidate}:${lanBoundPort}${wsPath}`
|
|
3552
|
+
: rawCandidate, req, wsPath)
|
|
3537
3553
|
: tailscaleUrls[0] || ''
|
|
3538
3554
|
if (!candidate) {
|
|
3539
3555
|
const error = new Error('no Tailscale address detected; connect this host to a tailnet and keep the LAN listener enabled')
|
|
@@ -3709,6 +3725,19 @@ const plugin = {
|
|
|
3709
3725
|
qrPayload,
|
|
3710
3726
|
svg,
|
|
3711
3727
|
})
|
|
3728
|
+
} else if (req.method === 'POST' && p === '/mgw/devices/revoke-offline') {
|
|
3729
|
+
// 一键清除离线设备:只吊销当前没有活跃连接的设备,在线设备不受影响。
|
|
3730
|
+
const offline = registry.list().filter((device) => !device.online || device.connections === 0)
|
|
3731
|
+
const removed = []
|
|
3732
|
+
for (const device of offline) {
|
|
3733
|
+
if (!registry.revoke(device.id)) continue
|
|
3734
|
+
removed.push(device.id)
|
|
3735
|
+
for (const client of clients) {
|
|
3736
|
+
if (client.deviceId === device.id) client.close(4003, 'device revoked')
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
if (removed.length > 0) log(`offline devices revoked: ${removed.length}`)
|
|
3740
|
+
sendJson(res, 200, { removed, count: removed.length })
|
|
3712
3741
|
} else if (req.method === 'POST' && p.startsWith('/mgw/devices/') && p.endsWith('/revoke')) {
|
|
3713
3742
|
const id = decodeURIComponent(p.slice('/mgw/devices/'.length, -'/revoke'.length))
|
|
3714
3743
|
const revoked = registry.revoke(id)
|
package/lib/ui-state.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// 面板 UI 偏好:与网关身份/模式分开存储。该文件损坏时回退默认值,
|
|
2
|
+
// 不让插件启动失败(身份文件损坏才会 fail closed)。
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import crypto from 'node:crypto'
|
|
6
|
+
|
|
7
|
+
const DEFAULTS = { version: 1, sidebarEntry: true }
|
|
8
|
+
|
|
9
|
+
export function createUiState(file) {
|
|
10
|
+
let state = { ...DEFAULTS }
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
13
|
+
if (parsed && parsed.version === 1 && typeof parsed.sidebarEntry === 'boolean') {
|
|
14
|
+
state = { version: 1, sidebarEntry: parsed.sidebarEntry }
|
|
15
|
+
}
|
|
16
|
+
} catch { /* 首次运行或文件损坏:使用默认值 */ }
|
|
17
|
+
const write = (value) => {
|
|
18
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 })
|
|
19
|
+
const tmp = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`
|
|
20
|
+
try {
|
|
21
|
+
fs.writeFileSync(tmp, `${JSON.stringify(value)}\n`, { mode: 0o600, flag: 'wx' })
|
|
22
|
+
fs.renameSync(tmp, file)
|
|
23
|
+
} finally {
|
|
24
|
+
fs.rmSync(tmp, { force: true })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
get sidebarEntry() { return state.sidebarEntry },
|
|
29
|
+
setSidebarEntry(value) {
|
|
30
|
+
if (typeof value !== 'boolean') throw new TypeError('sidebarEntry must be a boolean')
|
|
31
|
+
const next = { version: 1, sidebarEntry: value }
|
|
32
|
+
write(next)
|
|
33
|
+
state = next
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-weapp-gateway",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.47",
|
|
4
4
|
"description": "鲸尾网关助手:DeepSeek Harness 移动客户端连接与会话同步,支持安全配对、远程访问、上下文、编队、额度和语音输入",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"files": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"bin": "bin/setup-ip.mjs",
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "node test/wire-json.test.mjs && node --test test/history-cache.test.mjs && node test/session-target.test.mjs && node test/setup-ip.test.mjs && node test/host-adapter.test.mjs && node test/file-upload-adapter.test.mjs && node test/file-upload.test.mjs && node test/agent-team.test.mjs && node test/account-bridge.test.mjs && node test/context-bridge.test.mjs && node test/cost-meter.test.mjs && node --test test/cost-meter-dashboard.test.mjs && node test/clawbot-service.test.mjs && node test/speech-input.test.mjs && node test/speech-official.test.mjs && node test/plugin-management.test.mjs && node test/model-config.test.mjs && node test/plugin-updates.test.mjs && node test/session-preset.test.mjs && node test/session-follower.test.mjs && node test/completion-notifications.test.mjs && node --test test/workspace-changes.test.mjs && node --test test/question-replay.test.mjs && node --test test/network-diagnostics.test.mjs && node --test test/tailscale-addresses.test.mjs && node test/gateway.test.mjs && node test/auth.test.mjs && node test/lan.test.mjs && node test/cloudflared-binary.test.mjs && node test/cloudflare-tunnel.test.mjs && node --test test/public-endpoint-check.test.mjs && node test/gateway-tools.test.mjs && node test/relay-connector.test.mjs && node test/restart-reconnect.test.mjs && node test/cloudflare-linux.test.mjs && node test/multi-gateway.test.mjs"
|
|
32
|
+
"test": "node test/wire-json.test.mjs && node --test test/history-cache.test.mjs && node test/session-target.test.mjs && node test/setup-ip.test.mjs && node test/host-adapter.test.mjs && node test/file-upload-adapter.test.mjs && node test/file-upload.test.mjs && node test/agent-team.test.mjs && node test/account-bridge.test.mjs && node test/context-bridge.test.mjs && node test/cost-meter.test.mjs && node --test test/cost-meter-dashboard.test.mjs && node test/clawbot-service.test.mjs && node test/speech-input.test.mjs && node test/speech-official.test.mjs && node test/plugin-management.test.mjs && node test/model-config.test.mjs && node test/plugin-updates.test.mjs && node test/session-preset.test.mjs && node test/session-follower.test.mjs && node test/completion-notifications.test.mjs && node --test test/workspace-changes.test.mjs && node --test test/question-replay.test.mjs && node --test test/network-diagnostics.test.mjs && node --test test/tailscale-addresses.test.mjs && node --test test/ui-state.test.mjs && node test/gateway.test.mjs && node test/auth.test.mjs && node test/lan.test.mjs && node test/cloudflared-binary.test.mjs && node test/cloudflare-tunnel.test.mjs && node --test test/public-endpoint-check.test.mjs && node test/gateway-tools.test.mjs && node test/relay-connector.test.mjs && node test/restart-reconnect.test.mjs && node test/cloudflare-linux.test.mjs && node test/multi-gateway.test.mjs"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
35
35
|
".": "./lib/index.mjs",
|