dsh-plugin-weapp-gateway 0.8.38 → 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/PROTOCOL.md +40 -10
- package/README.md +61 -12
- package/docs/multi-gateway-app-integration.md +2 -2
- package/lib/client.js +323 -32
- package/lib/index.mjs +227 -46
- package/lib/network-diagnostics.mjs +126 -0
- package/lib/session-event-details.mjs +59 -0
- package/lib/tailscale-addresses.mjs +37 -0
- package/lib/ui-state.mjs +36 -0
- package/package.json +2 -2
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
|
|
@@ -336,11 +352,44 @@ window.__ModuleLoader__.load({
|
|
|
336
352
|
if (route === 'lan') return lanUrl
|
|
337
353
|
if (route === 'relay') return status.relay?.relay || ''
|
|
338
354
|
if (route === 'cloudflare') return tunnelUrl
|
|
355
|
+
if (route === 'tailscale') return status.tailscale?.urls?.[0] || ''
|
|
339
356
|
const statusUrl = status.cloudflare?.enabled && status.cloudflare.publicReady !== true &&
|
|
340
357
|
status.publicUrl === status.cloudflare.publicUrl ? '' : status.publicUrl
|
|
341
358
|
return tunnelUrl || statusUrl || lanUrl || inferredUrl(status.wsPath)
|
|
342
359
|
}
|
|
343
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
|
+
|
|
344
393
|
function connectionAdvice(status, publicSetup) {
|
|
345
394
|
if (!status) return { detected: '正在读取网关环境…', local: '', remote: '' }
|
|
346
395
|
const system = status.platform === 'darwin' ? 'macOS 电脑' : status.platform === 'win32' ? 'Windows 电脑' : status.platform === 'linux' ? 'Linux 服务器' : '当前设备'
|
|
@@ -351,7 +400,7 @@ window.__ModuleLoader__.load({
|
|
|
351
400
|
status.publicUrl === tunnel.publicUrl)
|
|
352
401
|
const serverReady = status.platform === 'linux' && !!(
|
|
353
402
|
(publicSetup?.configured && publicSetup.publicUrl) || (!statusUrlIsUnreadyTunnel && /^wss:\/\//.test(status.publicUrl || '')))
|
|
354
|
-
const detected = `当前检测:${system};局域网入口${lanReady ? '已就绪' : '未就绪'};${serverReady ? '公网服务器入口已配置' : tunnelReady ? `${tunnel.mode === 'quick' ? 'Quick' : '命名'} Tunnel 已连接` : tunnel?.enabled ? (tunnel.state === 'online' ? '隧道已连接,公网入口未验证或检测失败' : 'Cloudflare Tunnel 连接中') : '外网入口未连接'}。`
|
|
403
|
+
const detected = `当前检测:${system};局域网入口${lanReady ? '已就绪' : '未就绪'};Tailscale 地址${status.tailscale?.urls?.length ? '可用' : '未检测到'};${serverReady ? '公网服务器入口已配置' : tunnelReady ? `${tunnel.mode === 'quick' ? 'Quick' : '命名'} Tunnel 已连接` : tunnel?.enabled ? (tunnel.state === 'online' ? '隧道已连接,公网入口未验证或检测失败' : 'Cloudflare Tunnel 连接中') : '外网入口未连接'}。`
|
|
355
404
|
const local = lanReady
|
|
356
405
|
? 'DSH App 和小程序都可以通过局域网或 VPN 连接;手机与 DSH 同网时可使用局域网地址。'
|
|
357
406
|
: '两种客户端都可使用局域网连接;先确认局域网入口已开启并监听成功。'
|
|
@@ -378,6 +427,76 @@ window.__ModuleLoader__.load({
|
|
|
378
427
|
return device.routes.map((route) => ROUTE_BADGES[route]).filter(Boolean)
|
|
379
428
|
}
|
|
380
429
|
|
|
430
|
+
// 服务端网络检测:向每条已鉴权移动连接发一次 WebSocket ping,展示协议 RTT。
|
|
431
|
+
// 数据来自管理接口 POST /mgw/network-test(loopback);页面可见时每两秒刷新,
|
|
432
|
+
// 进入后台或关闭面板即停止。RTT 只反映网关到手机的协议往返,不是业务处理耗时。
|
|
433
|
+
function ServerNetworkDiagnostics() {
|
|
434
|
+
const [snapshot, setSnapshot] = React.useState(null)
|
|
435
|
+
const [failure, setFailure] = React.useState('')
|
|
436
|
+
const [running, setRunning] = React.useState(typeof document === 'undefined' ? false : !document.hidden)
|
|
437
|
+
React.useEffect(() => {
|
|
438
|
+
if (typeof document === 'undefined') return undefined
|
|
439
|
+
let mounted = true, timer, controller, generation = 0
|
|
440
|
+
const stop = () => { generation++; window.clearTimeout(timer); controller?.abort() }
|
|
441
|
+
const sample = async (lease) => {
|
|
442
|
+
if (!mounted || document.hidden || generation !== lease) return
|
|
443
|
+
controller = new AbortController()
|
|
444
|
+
try {
|
|
445
|
+
const data = await request('/mgw/network-test', { method: 'POST', signal: controller.signal })
|
|
446
|
+
if (mounted && generation === lease) { setSnapshot(data); setFailure('') }
|
|
447
|
+
} catch (cause) {
|
|
448
|
+
if (mounted && generation === lease && cause.name !== 'AbortError') setFailure(cause.message)
|
|
449
|
+
} finally {
|
|
450
|
+
if (mounted && generation === lease && !document.hidden) timer = window.setTimeout(() => sample(lease), 2000)
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const visibility = () => {
|
|
454
|
+
stop()
|
|
455
|
+
setRunning(!document.hidden)
|
|
456
|
+
if (!document.hidden) { setSnapshot(null); void sample(generation) }
|
|
457
|
+
}
|
|
458
|
+
document.addEventListener('visibilitychange', visibility)
|
|
459
|
+
if (!document.hidden) void sample(generation)
|
|
460
|
+
return () => { mounted = false; stop(); document.removeEventListener('visibilitychange', visibility) }
|
|
461
|
+
}, [])
|
|
462
|
+
const number = (value) => Number.isFinite(value) ? `${value.toFixed(1)} ms` : '—'
|
|
463
|
+
const statusLabel = (value) => ({ ok: '正常', timeout: '探测超时', disconnected: '已断开', error: '检测失败', unavailable: '暂无有效样本', cancelled: '已停止' })[value] || '暂无有效样本'
|
|
464
|
+
const channelLabel = (value) => ({ control: '控制通道', conversation: '会话通道', legacy: '兼容通道' })[value] || '兼容通道'
|
|
465
|
+
const chart = (channel) => {
|
|
466
|
+
const points = channel.samples || []
|
|
467
|
+
const end = snapshot.at
|
|
468
|
+
const maximum = Math.max(1, ...points.map((point) => point.rttMs || 0)) * 1.15
|
|
469
|
+
const paths = []; let segment = []
|
|
470
|
+
const flush = () => { if (segment.length) paths.push(segment.join(' ')); segment = [] }
|
|
471
|
+
for (const point of points) {
|
|
472
|
+
if (!Number.isFinite(point.rttMs)) { flush(); continue }
|
|
473
|
+
segment.push(`${Math.max(0, (point.at - end + 60000) / 60000 * 300)},${70 - point.rttMs / maximum * 65}`)
|
|
474
|
+
}
|
|
475
|
+
flush()
|
|
476
|
+
return React.createElement('svg', { viewBox: '0 0 300 78', preserveAspectRatio: 'none', role: 'img', 'aria-label': '服务端最近一分钟 RTT', style: { width: '100%', height: 86, display: 'block' } },
|
|
477
|
+
[5, 38, 70].map((y) => React.createElement('line', { key: y, x1: 0, x2: 300, y1: y, y2: y, stroke: colors.border, strokeWidth: .6 })),
|
|
478
|
+
paths.map((points, index) => React.createElement('polyline', { key: index, points, fill: 'none', stroke: 'var(--dsw-alias-link, #4176e6)', strokeWidth: 1.5 })),
|
|
479
|
+
(points.filter((point) => Number.isFinite(point.rttMs)).slice(-1)).map((point) => React.createElement('circle', { key: point.at,
|
|
480
|
+
cx: Math.max(0, (point.at - end + 60000) / 60000 * 300), cy: 70 - point.rttMs / maximum * 65, r: 2, fill: 'var(--dsw-alias-link, #4176e6)' })))
|
|
481
|
+
}
|
|
482
|
+
return React.createElement('section', { style: styles.card, 'aria-label': '服务端网络检测' },
|
|
483
|
+
React.createElement('h3', { className: 'mgw-section-title' }, '服务端网络检测'),
|
|
484
|
+
React.createElement('p', { style: styles.muted }, running ? '自动检测已连接设备,每两秒刷新;离开此页或进入后台后停止。' : '后台已暂停检测'),
|
|
485
|
+
React.createElement('p', { style: styles.muted }, '使用 WebSocket 协议 Ping/Pong 测量往返时延;经过 Tunnel 或代理时,RTT 可能只反映代理链路。'),
|
|
486
|
+
failure ? React.createElement('p', { role: 'alert', style: styles.error }, failure) : null,
|
|
487
|
+
!snapshot ? React.createElement('p', { style: styles.muted }, '正在检测…') : snapshot.devices.length === 0
|
|
488
|
+
? React.createElement('p', { style: styles.muted }, '当前没有已连接设备。')
|
|
489
|
+
: snapshot.devices.map((device) => React.createElement('section', { key: device.deviceId, style: { marginTop: 18, paddingTop: 14, borderTop: `1px solid ${colors.border}` } },
|
|
490
|
+
React.createElement('strong', null, device.name || '未命名设备'),
|
|
491
|
+
device.channels.map((channel) => React.createElement('div', { key: channel.connectionId, style: { marginTop: 12 } },
|
|
492
|
+
React.createElement('div', { style: { display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', gap: 8 } },
|
|
493
|
+
React.createElement('span', null, channelLabel(channel.channel), ' · WebSocket'),
|
|
494
|
+
React.createElement('strong', null, 'RTT ', number(channel.rttMs))),
|
|
495
|
+
React.createElement('p', { style: { ...styles.muted, margin: '6px 0' } }, statusLabel(channel.status), ' · 协议 Ping/Pong · 最近一分钟平均 ', number(channel.averageRttMs), ' · P95 ', number(channel.p95RttMs)),
|
|
496
|
+
chart(channel))))),
|
|
497
|
+
snapshot ? React.createElement('p', { style: styles.muted }, '服务端读取时间 ', new Date(snapshot.at).toLocaleTimeString(), ' · 曲线范围:最近一分钟') : null,
|
|
498
|
+
snapshot?.truncated ? React.createElement('p', { style: styles.muted }, '连接数量过多,仅检测前 256 条连接。') : null)
|
|
499
|
+
}
|
|
381
500
|
function DeviceRow({ device, onRevoke, revoking }) {
|
|
382
501
|
const triggerRevoke = (event) => {
|
|
383
502
|
event.preventDefault()
|
|
@@ -419,6 +538,8 @@ window.__ModuleLoader__.load({
|
|
|
419
538
|
}
|
|
420
539
|
|
|
421
540
|
function DevicePanel() {
|
|
541
|
+
// 侧边栏入口开关:与侧边栏按钮共享同一状态(切换后立即生效)。
|
|
542
|
+
const sidebarOn = React.useSyncExternalStore(subscribeSidebar, getSidebarEntry, () => true)
|
|
422
543
|
const [activeSection, setActiveSection] = React.useState('general')
|
|
423
544
|
const [devices, setDevices] = React.useState(null)
|
|
424
545
|
const [showAllDevices, setShowAllDevices] = React.useState(false)
|
|
@@ -488,7 +609,11 @@ window.__ModuleLoader__.load({
|
|
|
488
609
|
const [deviceNotice, setDeviceNotice] = React.useState(null)
|
|
489
610
|
const [deviceNoticeError, setDeviceNoticeError] = React.useState(false)
|
|
490
611
|
const [revokingIds, setRevokingIds] = React.useState(() => new Set())
|
|
612
|
+
const [sidebarBusy, setSidebarBusy] = React.useState(false)
|
|
613
|
+
const [offlineClearing, setOfflineClearing] = React.useState(false)
|
|
614
|
+
|
|
491
615
|
const revokingIdsRef = React.useRef(new Set())
|
|
616
|
+
const manualUrlRef = React.useRef(false)
|
|
492
617
|
const automaticUrlRef = React.useRef('')
|
|
493
618
|
const pairingRouteRef = React.useRef('auto')
|
|
494
619
|
const pairingRouteSelectedRef = React.useRef(false)
|
|
@@ -530,7 +655,9 @@ window.__ModuleLoader__.load({
|
|
|
530
655
|
pairingRouteRef.current = savedRoute
|
|
531
656
|
setPairingRoute(savedRoute)
|
|
532
657
|
}
|
|
533
|
-
|
|
658
|
+
// 自定义地址与手动填写的 Tailscale 地址不能被轮询覆盖。
|
|
659
|
+
if (pairingRouteRef.current !== 'custom'
|
|
660
|
+
&& !(pairingRouteRef.current === 'tailscale' && manualUrlRef.current)) {
|
|
534
661
|
const preferredUrl = pairingUrlFor(pairingRouteRef.current, statusData)
|
|
535
662
|
if (automaticUrlRef.current && preferredUrl !== automaticUrlRef.current) setQr(null)
|
|
536
663
|
automaticUrlRef.current = preferredUrl
|
|
@@ -691,6 +818,7 @@ window.__ModuleLoader__.load({
|
|
|
691
818
|
return () => { active = false; window.clearInterval(timer) }
|
|
692
819
|
}, [refresh])
|
|
693
820
|
|
|
821
|
+
|
|
694
822
|
React.useEffect(() => {
|
|
695
823
|
if (!qr) return
|
|
696
824
|
const previousFocus = document.activeElement
|
|
@@ -721,8 +849,12 @@ window.__ModuleLoader__.load({
|
|
|
721
849
|
pairingRouteSelectedRef.current = true
|
|
722
850
|
pairingRouteRef.current = route
|
|
723
851
|
setPairingRoute(route)
|
|
852
|
+
manualUrlRef.current = false
|
|
724
853
|
if (route === 'custom') {
|
|
725
854
|
automaticUrlRef.current = ''
|
|
855
|
+
// 「公网或其他手动地址」不从其它方案(尤其鲸尾中继)继承地址:
|
|
856
|
+
// 有已配置的公网 WSS 入口时预填它,否则留空等待填写。
|
|
857
|
+
setPublicUrl((publicSetup && publicSetup.publicUrl) || '')
|
|
726
858
|
} else if (status) {
|
|
727
859
|
const nextUrl = pairingUrlFor(route, status)
|
|
728
860
|
automaticUrlRef.current = nextUrl
|
|
@@ -811,7 +943,7 @@ window.__ModuleLoader__.load({
|
|
|
811
943
|
method: 'POST',
|
|
812
944
|
headers: { 'Content-Type': 'application/json' },
|
|
813
945
|
body: JSON.stringify({
|
|
814
|
-
publicUrl: endpoint,
|
|
946
|
+
publicUrl: pairingRoute === 'tailscale' ? tailscaleEndpointOf(endpoint, status) : endpoint,
|
|
815
947
|
route: pairingRoute,
|
|
816
948
|
lanUrl: lanPairingUrl(status),
|
|
817
949
|
}),
|
|
@@ -927,6 +1059,49 @@ window.__ModuleLoader__.load({
|
|
|
927
1059
|
}
|
|
928
1060
|
}
|
|
929
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
|
+
|
|
930
1105
|
const revoke = async (device) => {
|
|
931
1106
|
if (revokingIdsRef.current.has(device.id)) return
|
|
932
1107
|
setDeviceNotice(null)
|
|
@@ -1044,7 +1219,7 @@ window.__ModuleLoader__.load({
|
|
|
1044
1219
|
React.createElement('path', { d: 'M6 6l12 12M18 6L6 18' }))))),
|
|
1045
1220
|
React.createElement('div', { className: 'mgw-body' },
|
|
1046
1221
|
React.createElement('nav', { ref: navRef, className: 'mgw-nav', 'aria-label': '鲸尾网关助手设置分组' },
|
|
1047
|
-
[['general', '通用设置'], ['pairing', '连接与配对'], ['devices', '可信设备']].map(([id, label]) =>
|
|
1222
|
+
[['general', '通用设置'], ['pairing', '连接与配对'], ['devices', '可信设备'], ['network', '网络检测']].map(([id, label]) =>
|
|
1048
1223
|
React.createElement('button', { key: id, type: 'button', 'aria-current': activeSection === id ? 'page' : undefined,
|
|
1049
1224
|
onClick: () => { setActiveSection(id); setConnectionHelpOpen(false); setToolsOpen(false) } }, label))),
|
|
1050
1225
|
React.createElement('div', { className: 'mgw-content', key: activeSection },
|
|
@@ -1106,6 +1281,26 @@ window.__ModuleLoader__.load({
|
|
|
1106
1281
|
status && !status.requireAuth
|
|
1107
1282
|
? React.createElement('p', { style: { ...styles.error, margin: '12px 0 0' } }, 'Debug 模式:本机 DSH 入口将跳过设备凭证校验;独立局域网入口仍强制鉴权。')
|
|
1108
1283
|
: null),
|
|
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 } })))),
|
|
1109
1304
|
React.createElement('section', { style: styles.card },
|
|
1110
1305
|
React.createElement('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 14, alignItems: 'flex-start' } },
|
|
1111
1306
|
React.createElement('div', null,
|
|
@@ -1141,11 +1336,13 @@ window.__ModuleLoader__.load({
|
|
|
1141
1336
|
onClick: checkForPluginUpdate,
|
|
1142
1337
|
}, updateChecking ? '检查中…' : '重新检查')))),
|
|
1143
1338
|
),
|
|
1339
|
+
React.createElement('div', { hidden: activeSection !== 'network' },
|
|
1340
|
+
React.createElement(ServerNetworkDiagnostics, null)),
|
|
1144
1341
|
React.createElement('div', { hidden: activeSection !== 'pairing' },
|
|
1145
1342
|
React.createElement('section', { style: styles.card },
|
|
1146
1343
|
React.createElement('div', { className: 'mgw-setting-row' },
|
|
1147
1344
|
React.createElement('div', { style: { position: 'relative', display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6 }, onMouseLeave: () => setConnectionHelpOpen(false) },
|
|
1148
|
-
React.createElement('h3', { className: 'mgw-section-title', style: { marginBottom: 0 } }, '
|
|
1345
|
+
React.createElement('h3', { className: 'mgw-section-title', style: { marginBottom: 0 } }, '连接方案'),
|
|
1149
1346
|
React.createElement('button', {
|
|
1150
1347
|
type: 'button',
|
|
1151
1348
|
style: styles.helpButton,
|
|
@@ -1160,11 +1357,14 @@ window.__ModuleLoader__.load({
|
|
|
1160
1357
|
}, '?'),
|
|
1161
1358
|
connectionHelpOpen ? React.createElement('div', { id: 'mgw-route-help', role: 'tooltip', style: styles.helpBubble },
|
|
1162
1359
|
React.createElement('strong', null, '怎么选连接方式'),
|
|
1163
|
-
helpLine('
|
|
1164
|
-
helpLine('
|
|
1165
|
-
helpLine('
|
|
1166
|
-
helpLine('
|
|
1167
|
-
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 反代或只想指定一个固定地址时使用;编辑下方地址即可。'),
|
|
1168
1368
|
React.createElement('div', { style: { borderTop: `1px solid ${colors.border}`, marginTop: 10, paddingTop: 8 } },
|
|
1169
1369
|
React.createElement('strong', null, '结合当前环境'),
|
|
1170
1370
|
React.createElement('div', { style: { color: colors.muted, marginTop: 4 } }, advice.detected),
|
|
@@ -1173,7 +1373,9 @@ window.__ModuleLoader__.load({
|
|
|
1173
1373
|
React.createElement('div', { style: { color: colors.muted, marginTop: 6 } }, '面板无法判断手机当前网络;请按手机所在位置选择,提示不会替你修改选择。')))
|
|
1174
1374
|
: null),
|
|
1175
1375
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
|
|
1176
|
-
|
|
1376
|
+
// 连接方案:与上游一致的整合列表(保留「自动选择」)。Tailscale 私有网络
|
|
1377
|
+
// 与「公网或其他手动地址」共用下方统一的配对入口地址输入框。
|
|
1378
|
+
React.createElement(GatewaySelect, { style: styles.input, value: effectiveRoute, onChange: (event) => choosePairingRoute(event.target.value), disabled: !status, 'aria-label': '连接方案' },
|
|
1177
1379
|
React.createElement('option', { value: 'auto' }, '自动选择'),
|
|
1178
1380
|
React.createElement('option', { value: 'relay', disabled: !status?.relay }, status?.relay
|
|
1179
1381
|
? '鲸尾公网 · 小程序' : '鲸尾公网 · 尚未注册'),
|
|
@@ -1183,31 +1385,43 @@ window.__ModuleLoader__.load({
|
|
|
1183
1385
|
: '局域网直连 · 当前不可用')
|
|
1184
1386
|
: null,
|
|
1185
1387
|
status?.cloudflare?.supported
|
|
1186
|
-
? React.createElement('option', {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
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' }, '公网或其他手动地址')),
|
|
1191
1392
|
status?.cloudflare?.supported && pairingRoute === 'auto'
|
|
1192
1393
|
? React.createElement('span', { style: { fontSize: 12, lineHeight: 1.5, fontWeight: 500,
|
|
1193
|
-
color: 'var(--dsw-alias-link, #4176e6)' } }, '
|
|
1194
|
-
:
|
|
1394
|
+
color: 'var(--dsw-alias-link, #4176e6)' } }, '自动选择会优先尝试已就绪的公网入口,并同时保留局域网与 Tailscale 地址;DSH App 和小程序都可使用这些候选地址。配置 Cloudflare 请切换到“Cloudflare 外网”。')
|
|
1395
|
+
: pairingRoute === 'tailscale'
|
|
1195
1396
|
? React.createElement('span', { style: { fontSize: 12, lineHeight: 1.5, fontWeight: 500,
|
|
1196
|
-
color: 'var(--dsw-alias-link, #4176e6)' } },
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
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
|
+
})())
|
|
1403
|
+
: status?.cloudflare?.supported && pairingRoute === 'cloudflare'
|
|
1404
|
+
? React.createElement('span', { style: { fontSize: 12, lineHeight: 1.5, fontWeight: 500,
|
|
1405
|
+
color: 'var(--dsw-alias-link, #4176e6)' } }, cloudflareReady
|
|
1406
|
+
? 'Cloudflare 外网已就绪;DSH App 和小程序都可使用公网入口,也会保留局域网候选地址。'
|
|
1407
|
+
: 'Cloudflare 尚未就绪,可在本页 Cloudflare 设置中开启并完成连通性检测。')
|
|
1408
|
+
: null),
|
|
1200
1409
|
React.createElement('p', { style: { ...styles.muted, margin: '-6px 0 10px' } }, pairingRoute === 'relay'
|
|
1201
|
-
? '
|
|
1202
|
-
:
|
|
1203
|
-
|
|
1204
|
-
|
|
1410
|
+
? '此方案生成仅供鲸尾小程序使用的中继二维码;DSH App 请选「自动选择」或「局域网直连」。'
|
|
1411
|
+
: pairingRoute === 'auto'
|
|
1412
|
+
? '公网 WSS 就绪时,DSH App 和小程序都会尝试公网、局域网与 Tailscale 地址;没有公网入口时,App 使用局域网或 Tailscale,小程序优先使用已注册的鲸尾中继,否则也使用局域网。生成新二维码不会断开已连接设备。'
|
|
1413
|
+
: pairingRoute === 'tailscale'
|
|
1414
|
+
? '此方案只生成 Tailscale 私有网络二维码;手机与电脑需登录同一 tailnet。微信小程序线上环境要求 wss 域名,可能无法使用,请改用局域网/公网地址或 tailscale serve。'
|
|
1415
|
+
: '当前方案仅使用所选入口;编辑「配对入口地址」会切换到「公网或其他手动地址」。'),
|
|
1416
|
+
// 中继信息块只属于会用到中继的方案(中继 / 自动选择);
|
|
1417
|
+
// 手动地址、局域网、Cloudflare、Tailscale 方案不应出现鲸尾公网内容。
|
|
1418
|
+
(pairingRoute === 'relay' || pairingRoute === 'auto') && (relayInfo || relayConnector?.running || relayConnector?.delegatedTo || relayConnector?.lastError)
|
|
1205
1419
|
? (relayInfo
|
|
1206
1420
|
? React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0', fontWeight: 500 } },
|
|
1207
1421
|
'鲸尾公网服务 · 已注册', ' · ',
|
|
1208
1422
|
React.createElement('span', { style: { opacity: .8 } }, `设备 ID ${relayInfo.nodeId.slice(0, 8)}… · ${relayInfo.gatewayName}`),
|
|
1209
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 } },
|
|
1210
|
-
React.createElement('div', null, '公网 WSS 就绪时,DSH App 和小程序都会获得公网与局域网候选地址;没有公网入口时,App
|
|
1424
|
+
React.createElement('div', null, '公网 WSS 就绪时,DSH App 和小程序都会获得公网与局域网候选地址;没有公网入口时,App 使用局域网,小程序优先使用已注册的鲸尾公网中继,否则使用局域网。也可单独选择「鲸尾公网 · 小程序」强制生成专用中继二维码。'),
|
|
1211
1425
|
React.createElement('div', { style: { marginTop: 5 } }, relayConnector?.running || relayConnector?.delegatedTo
|
|
1212
1426
|
? '中继连接保持运行;切换配对方式不会断开已配对设备。'
|
|
1213
1427
|
: relayConnector?.lastError ? '中继连接器暂不可用,请检查网络或重新开启公网连接。'
|
|
@@ -1222,9 +1436,32 @@ window.__ModuleLoader__.load({
|
|
|
1222
1436
|
React.createElement('span', { style: { opacity: .8 } }, '如已自行部署连接器,请执行 systemctl restart dsh-connector。'))
|
|
1223
1437
|
: React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0' } }, '正在启动内置连接器…(中继模式需要一个本地连接器把小程序流量桥接进来,插件会自动准备)'))
|
|
1224
1438
|
: null),
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
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
|
|
1228
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)' } },
|
|
1229
1466
|
status.lan.error
|
|
1230
1467
|
? `局域网监听失败:${status.lan.error}`
|
|
@@ -1232,17 +1469,28 @@ window.__ModuleLoader__.load({
|
|
|
1232
1469
|
? `局域网入口已开启${status.lan.urls && status.lan.urls.length ? `:${status.lan.urls.join('、')}` : `,端口 ${status.lan.port}`}`
|
|
1233
1470
|
: '局域网入口启动中…')
|
|
1234
1471
|
: null,
|
|
1472
|
+
// Tailscale 直连:同一 tailnet 的手机可直接连 ws://100.x 地址,无需 tailscale serve。
|
|
1473
|
+
status && status.tailscale && Array.isArray(status.tailscale.urls) && status.tailscale.urls.length
|
|
1474
|
+
? React.createElement('div', { style: { ...styles.muted, margin: '-7px 0 10px', fontWeight: 500, color: colors.success } },
|
|
1475
|
+
`Tailscale 直连可用:${status.tailscale.urls.join('、')}`)
|
|
1476
|
+
: status && status.tailscale && Array.isArray(status.tailscale.addresses) && status.tailscale.addresses.length
|
|
1477
|
+
? React.createElement('div', { style: { ...styles.muted, margin: '-7px 0 10px', fontWeight: 500, color: 'var(--dsw-alias-link, #4176e6)' } },
|
|
1478
|
+
`检测到 Tailscale 地址 ${status.tailscale.addresses.join('、')};开启局域网入口后可直接使用。`)
|
|
1479
|
+
: null,
|
|
1235
1480
|
React.createElement('button', {
|
|
1236
|
-
style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) || (pairingRoute === 'custom' && !publicUrl.trim()) || (pairingRoute === 'cloudflare' && !cloudflareReady) ? .65 : 1 },
|
|
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 },
|
|
1237
1482
|
disabled: busy || !(status && status.gatewayEnabled) ||
|
|
1238
1483
|
(pairingRoute === 'custom' && !publicUrl.trim()) ||
|
|
1239
1484
|
(pairingRoute === 'cloudflare' && !cloudflareReady) ||
|
|
1485
|
+
(pairingRoute === 'tailscale' && !(status?.lan?.listening && isTailscaleInput(publicUrl))) ||
|
|
1240
1486
|
(pairingRoute === 'relay' && !status?.relay),
|
|
1241
1487
|
onClick: pair,
|
|
1242
1488
|
}, busy ? '正在生成…' : !(status && status.gatewayEnabled) ? '请先开启移动网关'
|
|
1243
1489
|
: pairingRoute === 'cloudflare' && !cloudflareReady
|
|
1244
1490
|
? status?.cloudflare?.enabled ? '等待 Cloudflare 外网就绪' : '先开启 Cloudflare Tunnel'
|
|
1245
|
-
: (pairingRoute === '
|
|
1491
|
+
: (pairingRoute === 'tailscale' && !status?.lan?.listening) ? '请先开启局域网入口'
|
|
1492
|
+
: (pairingRoute === 'tailscale' && !isTailscaleInput(publicUrl)) ? '填写主机 Tailscale 地址'
|
|
1493
|
+
: (pairingRoute === 'custom' && !publicUrl.trim()) ? '等待连接地址' : '生成配对二维码'),
|
|
1246
1494
|
React.createElement('p', { style: { ...styles.muted, margin: '10px 0 0' } }, '配对码仅可使用一次,5 分钟内有效。')),
|
|
1247
1495
|
pairingRoute === 'cloudflare' && status?.cloudflare?.supported
|
|
1248
1496
|
? React.createElement('section', { className: 'mgw-cloudflare-block', style: { ...styles.card, background: colors.card, border: 0, borderRadius: 16, padding: 18, marginTop: 16 } },
|
|
@@ -1338,6 +1586,12 @@ window.__ModuleLoader__.load({
|
|
|
1338
1586
|
deviceNotice || refreshNotice ? React.createElement('span', {
|
|
1339
1587
|
style: { ...styles.muted, color: deviceNoticeError ? colors.danger : colors.success },
|
|
1340
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})`),
|
|
1341
1595
|
React.createElement('button', {
|
|
1342
1596
|
style: { ...styles.button, opacity: refreshing ? .6 : 1 },
|
|
1343
1597
|
disabled: refreshing,
|
|
@@ -1377,6 +1631,32 @@ window.__ModuleLoader__.load({
|
|
|
1377
1631
|
return isOpen ? React.createElement(DevicePanel) : null
|
|
1378
1632
|
}
|
|
1379
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
|
+
}
|
|
1380
1660
|
const inject = ['slots']
|
|
1381
1661
|
function apply(ctx) {
|
|
1382
1662
|
// Upstream 0.10.1: the panel stylesheet is injected once through an
|
|
@@ -1396,6 +1676,17 @@ window.__ModuleLoader__.load({
|
|
|
1396
1676
|
{ name: 'settings.section', id: 'mobile-gateway', order: 35, label: () => NAV_LABEL },
|
|
1397
1677
|
() => React.createElement(SettingsEntry, null),
|
|
1398
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
|
+
))
|
|
1399
1690
|
}
|
|
1400
1691
|
|
|
1401
1692
|
exports.apply = apply
|