dsh-plugin-weapp-gateway 0.8.49 → 0.8.51
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 +14 -0
- package/lib/client.js +90 -48
- package/lib/index.mjs +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,20 @@
|
|
|
6
6
|
|
|
7
7
|
`dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
|
|
8
8
|
|
|
9
|
+
### v0.8.51 · 配对面板细节打磨
|
|
10
|
+
|
|
11
|
+
- 小程序模块去掉「鲸尾公网 · 小程序 / 中继优先,局域网兜底」说明行(上方描述文案已含同样信息)。
|
|
12
|
+
- 「鲸尾公网服务 · 已注册」下的提示大卡片移除,精简为一行连接器状态(运行中 / 异常 / 恢复中,带颜色标识)。
|
|
13
|
+
- 「兼容 App(备用)」层新增上游样式的**连接方案摘要**:按所选入口显示「配对入口」与提示——局域网 / Cloudflare / Tailscale / 手动地址各自判定(公网必须 wss、内网可 ws,含回环地址与子网路由提示),与上游 `pairingConnectionPlan` 同一判定思路。
|
|
14
|
+
- 「兼容 App」右侧箭头改为与下拉一致的 SVG chevron(展开时旋转 180°,带过渡动画),替换原来的文字箭头。
|
|
15
|
+
- 全量测试通过。
|
|
16
|
+
### v0.8.50 · 小程序固定中继优先、局域网兜底;自动选择移到 App 层
|
|
17
|
+
|
|
18
|
+
- 小程序模块不再提供「自动选择」,固定为**鲸尾公网 · 小程序**:二维码改为小程序专用 v2 载荷(`routes` 同时包含中继与局域网端点,不生成 `miniProgramRoute`),因此小程序**先连中继、连不上再回落局域网**(旧的 v3 中继专用码不会回落局域网)。
|
|
19
|
+
- 服务端新增 `route: "mini"`:只带局域网兜底地址 + 中继路由表,不泄露公网入口,也不生成 `miniProgramRoute`。
|
|
20
|
+
- 「自动选择」移到「兼容 App(备用)」层,作为 App 直连的默认方案(公网优先、局域网兜底);上游插件的直连选项(局域网 / Cloudflare / Tailscale / 手动地址)保持完整。
|
|
21
|
+
- 说明:上游插件的连接方案下拉里并没有「自动选择」(其内部状态有 auto/auto-lan,但 UI 未暴露,靠场景向导推荐);我们的自动选择保留在 App 层。
|
|
22
|
+
- 测试:auth 覆盖 `route=mini`(中继 + 局域网路由表、无 `miniProgramRoute`);全量测试通过。
|
|
9
23
|
### v0.8.49 · 配对区改为两层:鲸尾公网主用,兼容 App 折叠备用
|
|
10
24
|
|
|
11
25
|
- 第一层常显:**鲸尾公网(小程序 · 主用)** —— 自动选择 / 鲸尾公网 · 小程序、中继状态与「生成小程序二维码」。
|
package/lib/client.js
CHANGED
|
@@ -379,6 +379,65 @@ window.__ModuleLoader__.load({
|
|
|
379
379
|
return /^fd7a:115c:a1e0:/i.test(host)
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
+
// 与上游一致的连接方案摘要:按所选入口给出「配对入口 + 提示」。
|
|
383
|
+
function appConnectionPlan(route, status, rawUrl) {
|
|
384
|
+
const lanUrl = lanPairingUrl(status)
|
|
385
|
+
if (route === 'auto') {
|
|
386
|
+
return {
|
|
387
|
+
valid: !!lanUrl,
|
|
388
|
+
entry: '自动选择(公网优先,局域网兜底)',
|
|
389
|
+
note: lanUrl ? '手机会按实际连通情况在公网与局域网之间自动切换。' : '局域网入口不可用;自动选择需要一个手机可访问的局域网或公网入口。',
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (route === 'lan') {
|
|
393
|
+
return {
|
|
394
|
+
valid: !!lanUrl,
|
|
395
|
+
entry: '局域网直连',
|
|
396
|
+
note: lanUrl ? '同一局域网可直接访问;离开该网络就无法直连。' : '局域网入口不可用,请先开启基本设置中的局域网入口。',
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (route === 'cloudflare') {
|
|
400
|
+
const ready = !!(status?.cloudflare?.enabled && status.cloudflare.publicReady === true && status.cloudflare.publicUrl)
|
|
401
|
+
return {
|
|
402
|
+
valid: ready,
|
|
403
|
+
entry: 'Cloudflare Tunnel',
|
|
404
|
+
note: ready ? '公网入口已验证可达;手机在任何网络都可尝试。' : '公网入口尚未验证通过,请先完成下方配置和检测。',
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (route === 'tailscale') {
|
|
408
|
+
const valid = !!(status?.lan?.listening && isTailscaleInput(rawUrl))
|
|
409
|
+
return {
|
|
410
|
+
valid,
|
|
411
|
+
entry: 'Tailscale 私有网络',
|
|
412
|
+
note: valid ? '手机与主机需登录同一 tailnet,并允许访问网关端口。' : '请填写运行网关这台主机的 Tailscale IP(不是手机 IP),例如 100.x.x.x。',
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
// custom:按地址特征给提示(与上游 pairingConnectionPlan 同一判定思路)。
|
|
416
|
+
const raw = String(rawUrl || '').trim()
|
|
417
|
+
let endpoint
|
|
418
|
+
try { endpoint = new URL(raw) } catch {
|
|
419
|
+
return { valid: false, entry: '等待填写有效的配对地址', note: '请输入手机能够访问的 ws:// 或 wss:// 地址。' }
|
|
420
|
+
}
|
|
421
|
+
const scheme = endpoint.protocol === 'http:' ? 'ws:' : endpoint.protocol === 'https:' ? 'wss:' : endpoint.protocol
|
|
422
|
+
const host = endpoint.hostname.replace(/^\[|\]$/g, '').toLowerCase()
|
|
423
|
+
const parts = host.split('.').map(Number)
|
|
424
|
+
const ipv4 = parts.length === 4 && parts.every((n) => Number.isInteger(n) && n >= 0 && n <= 255)
|
|
425
|
+
const loopback = host === 'localhost' || host === '::1' || (ipv4 && parts[0] === 127)
|
|
426
|
+
const privateHost = loopback || host.endsWith('.local') ||
|
|
427
|
+
(ipv4 && (parts[0] === 10 || (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) ||
|
|
428
|
+
(parts[0] === 192 && parts[1] === 168) || (parts[0] === 169 && parts[1] === 254))) ||
|
|
429
|
+
(host.includes(':') && /^(fc|fd|fe80:)/.test(host))
|
|
430
|
+
if (!['ws:', 'wss:'].includes(scheme) || endpoint.username || endpoint.password || endpoint.search || endpoint.hash ||
|
|
431
|
+
raw.length > 2048 || ['0.0.0.0', '::'].includes(host) || (scheme === 'ws:' && !privateHost)) {
|
|
432
|
+
return { valid: false, entry: '配对地址需要修改', note: '公网地址必须使用 wss://;地址不能包含账号、查询参数或片段。' }
|
|
433
|
+
}
|
|
434
|
+
const entry = loopback ? '本机回环地址' : privateHost ? '局域网或子网路由' : '加密 WebSocket 入口'
|
|
435
|
+
let note = '配对地址已填写,手机是否可达仍需实际连接确认。'
|
|
436
|
+
if (loopback) note = '回环地址仅适用于本机模拟器;真机请填写电脑的局域网、Tailscale 或公网地址。'
|
|
437
|
+
else if (privateHost) note = '同一局域网可直接访问;异地访问此地址需要手机已有可用的子网路由。'
|
|
438
|
+
return { valid: true, entry, note }
|
|
439
|
+
}
|
|
440
|
+
|
|
382
441
|
// 手动输入的裸 IP 补成 ws://<ip>:<lanPort><wsPath>;已是 URL 的原样返回。
|
|
383
442
|
function tailscaleEndpointOf(value, status) {
|
|
384
443
|
const raw = String(value || '').trim()
|
|
@@ -547,8 +606,7 @@ window.__ModuleLoader__.load({
|
|
|
547
606
|
const [dismissedNotice, setDismissedNotice] = React.useState(() => dismissedRestartInstance)
|
|
548
607
|
// 两个配对模块各自维护方案:鲸尾公网小程序(主用)与兼容 App(折叠备用)。
|
|
549
608
|
const [appUrl, setAppUrl] = React.useState('')
|
|
550
|
-
const [
|
|
551
|
-
const [appRoute, setAppRoute] = React.useState('lan')
|
|
609
|
+
const [appRoute, setAppRoute] = React.useState('auto')
|
|
552
610
|
const [connectionHelpOpen, setConnectionHelpOpen] = React.useState(false)
|
|
553
611
|
const [toolsOpen, setToolsOpen] = React.useState(false)
|
|
554
612
|
const [toolBusy, setToolBusy] = React.useState(false)
|
|
@@ -618,9 +676,8 @@ window.__ModuleLoader__.load({
|
|
|
618
676
|
const revokingIdsRef = React.useRef(new Set())
|
|
619
677
|
const manualAppUrlRef = React.useRef(false)
|
|
620
678
|
const appUrlRef = React.useRef('')
|
|
621
|
-
const appRouteRef = React.useRef('
|
|
679
|
+
const appRouteRef = React.useRef('auto')
|
|
622
680
|
const appRouteChosenRef = React.useRef(false)
|
|
623
|
-
const miniChosenRef = React.useRef(false)
|
|
624
681
|
const cloudflareModeLoadedRef = React.useRef(false)
|
|
625
682
|
|
|
626
683
|
const refresh = React.useCallback(async () => {
|
|
@@ -652,8 +709,7 @@ window.__ModuleLoader__.load({
|
|
|
652
709
|
cloudflareModeLoadedRef.current = true
|
|
653
710
|
setCloudflareMode(statusData.cloudflare.mode || 'quick')
|
|
654
711
|
}
|
|
655
|
-
//
|
|
656
|
-
if (!miniChosenRef.current) setMiniPlan(statusData.pairingMode === 'relay' ? 'relay' : 'auto')
|
|
712
|
+
// 小程序模块固定为鲸尾公网(中继优先、局域网兜底),不再需要方案状态。
|
|
657
713
|
// App 模块地址跟随环境刷新;自定义地址与手动填写的 Tailscale 地址不被覆盖。
|
|
658
714
|
if (appRouteRef.current !== 'custom'
|
|
659
715
|
&& !(appRouteRef.current === 'tailscale' && manualAppUrlRef.current)) {
|
|
@@ -826,11 +882,6 @@ window.__ModuleLoader__.load({
|
|
|
826
882
|
}, [qr])
|
|
827
883
|
|
|
828
884
|
|
|
829
|
-
const chooseMiniPlan = (plan) => {
|
|
830
|
-
setQr(null)
|
|
831
|
-
miniChosenRef.current = true
|
|
832
|
-
setMiniPlan(plan)
|
|
833
|
-
}
|
|
834
885
|
|
|
835
886
|
// App 模块方案:自定义地址与手动 Tailscale 地址不随轮询覆盖。
|
|
836
887
|
const chooseAppRoute = (route) => {
|
|
@@ -935,19 +986,8 @@ window.__ModuleLoader__.load({
|
|
|
935
986
|
try {
|
|
936
987
|
let data
|
|
937
988
|
if (module === 'mini') {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const modeData = await request('/mgw/mode', {
|
|
941
|
-
method: 'POST',
|
|
942
|
-
headers: { 'Content-Type': 'application/json' },
|
|
943
|
-
body: JSON.stringify({ mode: 'relay' }),
|
|
944
|
-
})
|
|
945
|
-
setStatus((current) => ({ ...(current || {}), pairingMode: modeData.pairingMode, relay: modeData.relay }))
|
|
946
|
-
}
|
|
947
|
-
data = await requestPairing({})
|
|
948
|
-
} else {
|
|
949
|
-
data = await requestPairing({ route: 'auto' })
|
|
950
|
-
}
|
|
989
|
+
// 小程序专用路线:中继优先、局域网兜底(路线由小程序端按路由表选择)。
|
|
990
|
+
data = await requestPairing({ route: 'mini' })
|
|
951
991
|
} else {
|
|
952
992
|
data = await requestPairing({
|
|
953
993
|
publicUrl: appRoute === 'tailscale' ? tailscaleEndpointOf(appUrl, status) : appUrl,
|
|
@@ -1140,8 +1180,10 @@ window.__ModuleLoader__.load({
|
|
|
1140
1180
|
const appPairingDisabled = busy || !(status && status.gatewayEnabled) ||
|
|
1141
1181
|
(appRoute === 'custom' && !appUrl.trim()) ||
|
|
1142
1182
|
(appRoute === 'cloudflare' && !cloudflareReady) ||
|
|
1183
|
+
(appRoute === 'auto' && !lanPairingUrl(status)) ||
|
|
1143
1184
|
(appRoute === 'lan' && !lanPairingUrl(status)) ||
|
|
1144
1185
|
(appRoute === 'tailscale' && !(status?.lan?.listening && isTailscaleInput(appUrl)))
|
|
1186
|
+
const appPlan = appConnectionPlan(appRoute, status, appUrl)
|
|
1145
1187
|
|
|
1146
1188
|
const advice = connectionAdvice(status, publicSetup)
|
|
1147
1189
|
const helpLine = (name, description) => React.createElement('div', { style: { marginTop: 7 } },
|
|
@@ -1353,10 +1395,10 @@ window.__ModuleLoader__.load({
|
|
|
1353
1395
|
}, '?'),
|
|
1354
1396
|
connectionHelpOpen ? React.createElement('div', { id: 'mgw-route-help', role: 'tooltip', style: styles.helpBubble },
|
|
1355
1397
|
React.createElement('strong', null, '怎么选连接方式'),
|
|
1356
|
-
helpLine('小程序连接(推荐)', '鲸尾小程序在微信里通过鲸尾公网中继连接,不受 wss
|
|
1357
|
-
helpLine('
|
|
1358
|
-
helpLine('
|
|
1359
|
-
helpLine('
|
|
1398
|
+
helpLine('小程序连接(推荐)', '鲸尾小程序在微信里通过鲸尾公网中继连接,不受 wss 域名限制;手机与网关在同一局域网时自动兜底直连。'),
|
|
1399
|
+
helpLine('鲸尾公网 · 小程序', '小程序专用二维码:中继优先、局域网兜底;无需公网域名。'),
|
|
1400
|
+
helpLine('兼容 App(备用)', 'DSH App 使用直连入口:自动选择、局域网直连、Cloudflare 外网、Tailscale 私有网络或公网/手动地址。'),
|
|
1401
|
+
helpLine('自动选择(App)', '优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;没有公网入口时使用局域网。'),
|
|
1360
1402
|
helpLine('局域网直连', '手机与 DSH 在同一个可互访的局域网,使用 ws:// 私有地址;离开该网络就无法直连。'),
|
|
1361
1403
|
helpLine('Cloudflare 外网', 'PC 主动连接 Cloudflare,外网用固定域名的 wss://;需要 Cloudflare 账户和域名。'),
|
|
1362
1404
|
helpLine('Tailscale 私有网络', '可检测本机地址,或填写主机的 100.x 私有地址;手机与电脑需登录同一 tailnet。'),
|
|
@@ -1368,28 +1410,19 @@ window.__ModuleLoader__.load({
|
|
|
1368
1410
|
React.createElement('div', { style: { marginTop: 6 } }, advice.remote),
|
|
1369
1411
|
React.createElement('div', { style: { color: colors.muted, marginTop: 6 } }, '面板无法判断手机当前网络;请按手机所在位置选择,提示不会替你修改选择。')))
|
|
1370
1412
|
: null),
|
|
1371
|
-
React.createElement('p', { style: styles.muted }, '
|
|
1372
|
-
|
|
1373
|
-
React.createElement(GatewaySelect, { style: styles.input, value: miniPlan, onChange: (event) => chooseMiniPlan(event.target.value), disabled: !status, 'aria-label': '小程序连接方式' },
|
|
1374
|
-
React.createElement('option', { value: 'auto' }, '自动选择'),
|
|
1375
|
-
React.createElement('option', { value: 'relay', disabled: !status?.relay }, status?.relay
|
|
1376
|
-
? '鲸尾公网 · 小程序' : '鲸尾公网 · 尚未注册'))),
|
|
1377
|
-
React.createElement('p', { style: { ...styles.muted, margin: '-6px 0 10px' } }, miniPlan === 'relay'
|
|
1378
|
-
? '此方案生成仅供鲸尾小程序使用的中继二维码;App 请展开下方「兼容 App(备用)」。'
|
|
1379
|
-
: '自动选择会优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;小程序没有公网入口时自动使用已注册的鲸尾中继;App 也可使用该二维码。生成新二维码不会断开已连接设备。'),
|
|
1413
|
+
React.createElement('p', { style: styles.muted }, '小程序默认通过鲸尾公网中继连接,不需要公网域名;手机与网关在同一局域网时自动兜底直连。'),
|
|
1414
|
+
|
|
1380
1415
|
// 中继信息块属于小程序模块(自动选择 / 鲸尾公网中继)。
|
|
1381
1416
|
(relayInfo || relayConnector?.running || relayConnector?.delegatedTo || relayConnector?.lastError)
|
|
1382
1417
|
? (relayInfo
|
|
1383
1418
|
? React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0', fontWeight: 500 } },
|
|
1384
1419
|
'鲸尾公网服务 · 已注册', ' · ',
|
|
1385
1420
|
React.createElement('span', { style: { opacity: .8 } }, `设备 ID ${relayInfo.nodeId.slice(0, 8)}… · ${relayInfo.gatewayName}`),
|
|
1386
|
-
React.createElement('div', { style: { marginTop:
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
?
|
|
1390
|
-
|
|
1391
|
-
: '中继身份已保存,连接器正在恢复…'),
|
|
1392
|
-
React.createElement('div', { style: { marginTop: 5 } }, '设备配对与公网有效期独立;公网到期不影响局域网。已注册不代表手机端完整链路已通过验证。')))
|
|
1421
|
+
React.createElement('div', { style: { marginTop: 4, color: relayConnector?.lastError ? colors.danger : relayConnector?.running || relayConnector?.delegatedTo ? colors.success : 'var(--dsw-alias-link, #4176e6)' } },
|
|
1422
|
+
relayConnector?.running || relayConnector?.delegatedTo
|
|
1423
|
+
? '中继连接保持运行'
|
|
1424
|
+
: relayConnector?.lastError ? `中继连接器异常:${relayConnector.lastError}`
|
|
1425
|
+
: '中继连接器正在恢复…'))
|
|
1393
1426
|
: relayConnector && relayConnector.running
|
|
1394
1427
|
? React.createElement('div', { style: { ...styles.muted, margin: '2px 0 0', fontWeight: 500,
|
|
1395
1428
|
color: 'var(--dsw-alias-link, #4176e6)' } }, '内置连接器已自动启动,正在连接中继并上报身份…')
|
|
@@ -1401,11 +1434,12 @@ window.__ModuleLoader__.load({
|
|
|
1401
1434
|
: null,
|
|
1402
1435
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 12, flexWrap: 'wrap', marginTop: 10 } },
|
|
1403
1436
|
React.createElement('button', {
|
|
1404
|
-
style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) ||
|
|
1405
|
-
disabled: busy || !(status && status.gatewayEnabled) ||
|
|
1437
|
+
style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) || !status?.relay || !lanPairingUrl(status) ? .65 : 1 },
|
|
1438
|
+
disabled: busy || !(status && status.gatewayEnabled) || !status?.relay || !lanPairingUrl(status),
|
|
1406
1439
|
onClick: () => pairFor('mini'),
|
|
1407
1440
|
}, busy ? '正在生成…' : !(status && status.gatewayEnabled) ? '请先开启移动网关'
|
|
1408
|
-
:
|
|
1441
|
+
: !status?.relay ? '请先注册鲸尾公网中继'
|
|
1442
|
+
: !lanPairingUrl(status) ? '请先开启局域网入口' : '生成小程序二维码'),
|
|
1409
1443
|
React.createElement('span', { style: styles.muted }, '配对码仅可使用一次,5 分钟内有效。'))),
|
|
1410
1444
|
// ── 第二层:兼容 App(折叠备用)────────────────────────────────
|
|
1411
1445
|
React.createElement('section', { style: { ...styles.card, marginTop: 16 } },
|
|
@@ -1419,12 +1453,16 @@ window.__ModuleLoader__.load({
|
|
|
1419
1453
|
React.createElement('strong', null, '兼容 App(备用)'),
|
|
1420
1454
|
React.createElement('span', { style: { ...styles.muted, marginLeft: 8, fontWeight: 400 } },
|
|
1421
1455
|
appLayerOpen ? '收起 App 兼容方式' : '需要连接 DSH App 时展开')),
|
|
1422
|
-
React.createElement('
|
|
1456
|
+
React.createElement('svg', { width: 16, height: 16, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor',
|
|
1457
|
+
strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true,
|
|
1458
|
+
style: { flexShrink: 0, color: colors.muted, transform: appLayerOpen ? 'rotate(180deg)' : 'none', transition: 'transform .18s ease' } },
|
|
1459
|
+
React.createElement('path', { d: 'M6 9l6 6 6-6' }))),
|
|
1423
1460
|
appLayerOpen
|
|
1424
1461
|
? React.createElement(React.Fragment, null,
|
|
1425
1462
|
React.createElement('p', { style: styles.muted }, '仅用于 DSH App(上游移动网关的直连方式),与上方鲸尾公网互不影响。'),
|
|
1426
1463
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
|
|
1427
1464
|
React.createElement(GatewaySelect, { style: styles.input, value: appRoute, onChange: (event) => chooseAppRoute(event.target.value), disabled: !status, 'aria-label': 'App 连接方式' },
|
|
1465
|
+
React.createElement('option', { value: 'auto' }, '自动选择'),
|
|
1428
1466
|
React.createElement('option', { value: 'lan', disabled: !lanPairingUrl(status) }, lanPairingUrl(status)
|
|
1429
1467
|
? '局域网直连'
|
|
1430
1468
|
: '局域网直连 · 当前不可用'),
|
|
@@ -1433,6 +1471,10 @@ window.__ModuleLoader__.load({
|
|
|
1433
1471
|
React.createElement('option', { value: 'tailscale', disabled: !(status && status.lan && status.lan.listening) },
|
|
1434
1472
|
(status && status.lan && status.lan.listening) ? 'Tailscale 私有网络' : 'Tailscale 私有网络 · 请先开启局域网入口'),
|
|
1435
1473
|
React.createElement('option', { value: 'custom' }, '公网或其他手动地址'))),
|
|
1474
|
+
// 与上游一致的连接方案摘要:配对入口 + 提示。
|
|
1475
|
+
React.createElement('div', { 'aria-label': '当前连接方案', style: { margin: '2px 0 10px', padding: '9px 11px', borderRadius: 10, border: `1px solid ${colors.border}`, background: colors.card, fontSize: 12, lineHeight: 1.7 } },
|
|
1476
|
+
React.createElement('div', null, React.createElement('strong', null, '配对入口'), ':', appPlan.entry),
|
|
1477
|
+
React.createElement('div', { style: { color: appPlan.valid ? colors.muted : colors.danger } }, appPlan.note)),
|
|
1436
1478
|
React.createElement('label', { style: styles.label, htmlFor: 'mgw-pair-address' }, appRoute === 'tailscale'
|
|
1437
1479
|
? '主机 Tailscale 地址(运行网关的电脑,不是手机)'
|
|
1438
1480
|
: '配对入口地址(手机需能访问)'),
|
package/lib/index.mjs
CHANGED
|
@@ -3523,7 +3523,7 @@ const plugin = {
|
|
|
3523
3523
|
throw error
|
|
3524
3524
|
}
|
|
3525
3525
|
const body = await readBody(req)
|
|
3526
|
-
const clientRoute = ['auto', 'lan', 'cloudflare', 'custom', 'tailscale'].includes(body.route) ? body.route : null
|
|
3526
|
+
const clientRoute = ['auto', 'mini', 'lan', 'cloudflare', 'custom', 'tailscale'].includes(body.route) ? body.route : null
|
|
3527
3527
|
const cloudflareStatus = tunnel?.snapshot() || null
|
|
3528
3528
|
const configuredUrl = configuredPublicUrl()
|
|
3529
3529
|
const autoUrl = cloudflareStatus?.enabled && cloudflareStatus.publicReady === true
|
|
@@ -3565,11 +3565,15 @@ const plugin = {
|
|
|
3565
3565
|
return parsed.toString()
|
|
3566
3566
|
})()
|
|
3567
3567
|
: ''
|
|
3568
|
+
// route=mini 是小程序专用路线:不带公网入口,载荷只含局域网兜底 +
|
|
3569
|
+
// 中继路由表(客户端中继优先、局域网兜底),也不生成 miniProgramRoute。
|
|
3568
3570
|
const publicUrl = clientRoute === 'tailscale'
|
|
3569
3571
|
? requestedTailscaleUrl
|
|
3570
3572
|
: clientRoute === 'auto'
|
|
3571
3573
|
? (autoUrl ? normalizePublicUrl(autoUrl, req, wsPath) : '')
|
|
3572
|
-
:
|
|
3574
|
+
: clientRoute === 'mini'
|
|
3575
|
+
? ''
|
|
3576
|
+
: normalizePublicUrl(body.publicUrl || configuredUrl, req, wsPath)
|
|
3573
3577
|
if (clientRoute) {
|
|
3574
3578
|
const discoveredLan = lanListening
|
|
3575
3579
|
? lanWebSocketUrls(options, wsPath, lanBoundPort).find(isRoutablePrivateEndpoint)
|