dsh-plugin-weapp-gateway 0.8.48 → 0.8.50

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 CHANGED
@@ -6,6 +6,19 @@
6
6
 
7
7
  `dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
8
8
 
9
+ ### v0.8.50 · 小程序固定中继优先、局域网兜底;自动选择移到 App 层
10
+
11
+ - 小程序模块不再提供「自动选择」,固定为**鲸尾公网 · 小程序**:二维码改为小程序专用 v2 载荷(`routes` 同时包含中继与局域网端点,不生成 `miniProgramRoute`),因此小程序**先连中继、连不上再回落局域网**(旧的 v3 中继专用码不会回落局域网)。
12
+ - 服务端新增 `route: "mini"`:只带局域网兜底地址 + 中继路由表,不泄露公网入口,也不生成 `miniProgramRoute`。
13
+ - 「自动选择」移到「兼容 App(备用)」层,作为 App 直连的默认方案(公网优先、局域网兜底);上游插件的直连选项(局域网 / Cloudflare / Tailscale / 手动地址)保持完整。
14
+ - 说明:上游插件的连接方案下拉里并没有「自动选择」(其内部状态有 auto/auto-lan,但 UI 未暴露,靠场景向导推荐);我们的自动选择保留在 App 层。
15
+ - 测试:auth 覆盖 `route=mini`(中继 + 局域网路由表、无 `miniProgramRoute`);全量测试通过。
16
+ ### v0.8.49 · 配对区改为两层:鲸尾公网主用,兼容 App 折叠备用
17
+
18
+ - 第一层常显:**鲸尾公网(小程序 · 主用)** —— 自动选择 / 鲸尾公网 · 小程序、中继状态与「生成小程序二维码」。
19
+ - 第二层折叠:**兼容 App(备用)** —— 点击展开上游插件的直连方式(局域网直连 / Cloudflare 外网 / Tailscale 私有网络 / 公网或其他手动地址),独立地址输入与「生成 App 二维码」;默认收起,与鲸尾公网内容完全分开。
20
+ - App 连接排查:协议层实测正常(LAN 入口 `dsh-pair` 握手 → `paired`/`hello` v3、token 重连;LAN / 自定义 / Tailscale / Cloudflare 四种 App 路线均 201);此前失败最可能是扫了中继专用 v3 码。现在 App 走第二层生成的直连码。
21
+ - 帮助气泡、面板文案与渲染测试同步;全量测试通过。
9
22
  ### v0.8.48 · 配对界面拆分为两个模块(App 连接修复)
10
23
 
11
24
  - 「连接与配对」拆成两个独立模块,避免把小程序中继码当 App 码用:
package/lib/client.js CHANGED
@@ -545,10 +545,9 @@ window.__ModuleLoader__.load({
545
545
  const [showAllDevices, setShowAllDevices] = React.useState(false)
546
546
  const [status, setStatus] = React.useState(null)
547
547
  const [dismissedNotice, setDismissedNotice] = React.useState(() => dismissedRestartInstance)
548
- // 两个配对模块各自维护方案:小程序(主用)与 App 直连(备用)。
548
+ // 两个配对模块各自维护方案:鲸尾公网小程序(主用)与兼容 App(折叠备用)。
549
549
  const [appUrl, setAppUrl] = React.useState('')
550
- const [miniPlan, setMiniPlan] = React.useState('auto')
551
- const [appRoute, setAppRoute] = React.useState('lan')
550
+ const [appRoute, setAppRoute] = React.useState('auto')
552
551
  const [connectionHelpOpen, setConnectionHelpOpen] = React.useState(false)
553
552
  const [toolsOpen, setToolsOpen] = React.useState(false)
554
553
  const [toolBusy, setToolBusy] = React.useState(false)
@@ -613,13 +612,13 @@ window.__ModuleLoader__.load({
613
612
  const [revokingIds, setRevokingIds] = React.useState(() => new Set())
614
613
  const [sidebarBusy, setSidebarBusy] = React.useState(false)
615
614
  const [offlineClearing, setOfflineClearing] = React.useState(false)
615
+ const [appLayerOpen, setAppLayerOpen] = React.useState(false)
616
616
 
617
617
  const revokingIdsRef = React.useRef(new Set())
618
618
  const manualAppUrlRef = React.useRef(false)
619
619
  const appUrlRef = React.useRef('')
620
- const appRouteRef = React.useRef('lan')
620
+ const appRouteRef = React.useRef('auto')
621
621
  const appRouteChosenRef = React.useRef(false)
622
- const miniChosenRef = React.useRef(false)
623
622
  const cloudflareModeLoadedRef = React.useRef(false)
624
623
 
625
624
  const refresh = React.useCallback(async () => {
@@ -651,8 +650,7 @@ window.__ModuleLoader__.load({
651
650
  cloudflareModeLoadedRef.current = true
652
651
  setCloudflareMode(statusData.cloudflare.mode || 'quick')
653
652
  }
654
- // 小程序方案只在首次加载时按保存的配对模式选择,之后不覆盖运营者选择。
655
- if (!miniChosenRef.current) setMiniPlan(statusData.pairingMode === 'relay' ? 'relay' : 'auto')
653
+ // 小程序模块固定为鲸尾公网(中继优先、局域网兜底),不再需要方案状态。
656
654
  // App 模块地址跟随环境刷新;自定义地址与手动填写的 Tailscale 地址不被覆盖。
657
655
  if (appRouteRef.current !== 'custom'
658
656
  && !(appRouteRef.current === 'tailscale' && manualAppUrlRef.current)) {
@@ -825,11 +823,6 @@ window.__ModuleLoader__.load({
825
823
  }, [qr])
826
824
 
827
825
 
828
- const chooseMiniPlan = (plan) => {
829
- setQr(null)
830
- miniChosenRef.current = true
831
- setMiniPlan(plan)
832
- }
833
826
 
834
827
  // App 模块方案:自定义地址与手动 Tailscale 地址不随轮询覆盖。
835
828
  const chooseAppRoute = (route) => {
@@ -934,19 +927,8 @@ window.__ModuleLoader__.load({
934
927
  try {
935
928
  let data
936
929
  if (module === 'mini') {
937
- if (miniPlan === 'relay') {
938
- if (status?.pairingMode !== 'relay') {
939
- const modeData = await request('/mgw/mode', {
940
- method: 'POST',
941
- headers: { 'Content-Type': 'application/json' },
942
- body: JSON.stringify({ mode: 'relay' }),
943
- })
944
- setStatus((current) => ({ ...(current || {}), pairingMode: modeData.pairingMode, relay: modeData.relay }))
945
- }
946
- data = await requestPairing({})
947
- } else {
948
- data = await requestPairing({ route: 'auto' })
949
- }
930
+ // 小程序专用路线:中继优先、局域网兜底(路线由小程序端按路由表选择)。
931
+ data = await requestPairing({ route: 'mini' })
950
932
  } else {
951
933
  data = await requestPairing({
952
934
  publicUrl: appRoute === 'tailscale' ? tailscaleEndpointOf(appUrl, status) : appUrl,
@@ -1139,6 +1121,7 @@ window.__ModuleLoader__.load({
1139
1121
  const appPairingDisabled = busy || !(status && status.gatewayEnabled) ||
1140
1122
  (appRoute === 'custom' && !appUrl.trim()) ||
1141
1123
  (appRoute === 'cloudflare' && !cloudflareReady) ||
1124
+ (appRoute === 'auto' && !lanPairingUrl(status)) ||
1142
1125
  (appRoute === 'lan' && !lanPairingUrl(status)) ||
1143
1126
  (appRoute === 'tailscale' && !(status?.lan?.listening && isTailscaleInput(appUrl)))
1144
1127
 
@@ -1352,10 +1335,10 @@ window.__ModuleLoader__.load({
1352
1335
  }, '?'),
1353
1336
  connectionHelpOpen ? React.createElement('div', { id: 'mgw-route-help', role: 'tooltip', style: styles.helpBubble },
1354
1337
  React.createElement('strong', null, '怎么选连接方式'),
1355
- helpLine('小程序连接(推荐)', '鲸尾小程序在微信里通过鲸尾公网中继连接,不受 wss 域名限制;「自动选择」的二维码同时带上 App 可用的地址。'),
1356
- helpLine('自动选择', '优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;没有公网入口时小程序自动使用已注册的鲸尾中继。'),
1357
- helpLine('鲸尾公网 · 小程序', '生成仅供鲸尾小程序使用的中继二维码。'),
1358
- helpLine('App 直连(备用)', 'DSH App 使用直连入口:局域网直连、Cloudflare 外网、Tailscale 私有网络或公网/手动地址。'),
1338
+ helpLine('小程序连接(推荐)', '鲸尾小程序在微信里通过鲸尾公网中继连接,不受 wss 域名限制;手机与网关在同一局域网时自动兜底直连。'),
1339
+ helpLine('鲸尾公网 · 小程序', '小程序专用二维码:中继优先、局域网兜底;无需公网域名。'),
1340
+ helpLine('兼容 App(备用)', 'DSH App 使用直连入口:自动选择、局域网直连、Cloudflare 外网、Tailscale 私有网络或公网/手动地址。'),
1341
+ helpLine('自动选择(App)', '优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;没有公网入口时使用局域网。'),
1359
1342
  helpLine('局域网直连', '手机与 DSH 在同一个可互访的局域网,使用 ws:// 私有地址;离开该网络就无法直连。'),
1360
1343
  helpLine('Cloudflare 外网', 'PC 主动连接 Cloudflare,外网用固定域名的 wss://;需要 Cloudflare 账户和域名。'),
1361
1344
  helpLine('Tailscale 私有网络', '可检测本机地址,或填写主机的 100.x 私有地址;手机与电脑需登录同一 tailnet。'),
@@ -1367,15 +1350,11 @@ window.__ModuleLoader__.load({
1367
1350
  React.createElement('div', { style: { marginTop: 6 } }, advice.remote),
1368
1351
  React.createElement('div', { style: { color: colors.muted, marginTop: 6 } }, '面板无法判断手机当前网络;请按手机所在位置选择,提示不会替你修改选择。')))
1369
1352
  : null),
1370
- React.createElement('p', { style: styles.muted }, '鲸尾小程序通过鲸尾公网中继连接,不需要公网域名;「自动选择」生成的二维码同时兼容 App。'),
1371
- React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
1372
- React.createElement(GatewaySelect, { style: styles.input, value: miniPlan, onChange: (event) => chooseMiniPlan(event.target.value), disabled: !status, 'aria-label': '小程序连接方式' },
1373
- React.createElement('option', { value: 'auto' }, '自动选择'),
1374
- React.createElement('option', { value: 'relay', disabled: !status?.relay }, status?.relay
1375
- ? '鲸尾公网 · 小程序' : '鲸尾公网 · 尚未注册'))),
1376
- React.createElement('p', { style: { ...styles.muted, margin: '-6px 0 10px' } }, miniPlan === 'relay'
1377
- ? '此方案生成仅供鲸尾小程序使用的中继二维码;App 请使用下方「App 直连(备用)」。'
1378
- : '自动选择会优先已就绪的公网入口,同时保留局域网与 Tailscale 地址;小程序没有公网入口时自动使用已注册的鲸尾中继;App 也可使用该二维码。生成新二维码不会断开已连接设备。'),
1353
+ React.createElement('p', { style: styles.muted }, '小程序默认通过鲸尾公网中继连接,不需要公网域名;手机与网关在同一局域网时自动兜底直连。'),
1354
+ React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%', marginBottom: 2 } },
1355
+ React.createElement('strong', { style: { fontWeight: 600 } }, '鲸尾公网 · 小程序'),
1356
+ React.createElement('span', { style: styles.muted }, '中继优先,局域网兜底'),
1357
+ status?.relay ? null : React.createElement('span', { style: { ...styles.muted, color: colors.danger, fontWeight: 500 } }, '尚未注册中继')),
1379
1358
  // 中继信息块属于小程序模块(自动选择 / 鲸尾公网中继)。
1380
1359
  (relayInfo || relayConnector?.running || relayConnector?.delegatedTo || relayConnector?.lastError)
1381
1360
  ? (relayInfo
@@ -1400,83 +1379,98 @@ window.__ModuleLoader__.load({
1400
1379
  : null,
1401
1380
  React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 12, flexWrap: 'wrap', marginTop: 10 } },
1402
1381
  React.createElement('button', {
1403
- style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) || (miniPlan === 'relay' && !status?.relay) ? .65 : 1 },
1404
- disabled: busy || !(status && status.gatewayEnabled) || (miniPlan === 'relay' && !status?.relay),
1382
+ style: { ...styles.button, ...styles.primary, opacity: busy || !(status && status.gatewayEnabled) || !status?.relay || !lanPairingUrl(status) ? .65 : 1 },
1383
+ disabled: busy || !(status && status.gatewayEnabled) || !status?.relay || !lanPairingUrl(status),
1405
1384
  onClick: () => pairFor('mini'),
1406
1385
  }, busy ? '正在生成…' : !(status && status.gatewayEnabled) ? '请先开启移动网关'
1407
- : miniPlan === 'relay' ? '生成小程序中继二维码' : '生成小程序二维码'),
1386
+ : !status?.relay ? '请先注册鲸尾公网中继'
1387
+ : !lanPairingUrl(status) ? '请先开启局域网入口' : '生成小程序二维码'),
1408
1388
  React.createElement('span', { style: styles.muted }, '配对码仅可使用一次,5 分钟内有效。'))),
1409
- // ── 模块二:App 直连(备用)──────────────────────────────────────
1389
+ // ── 第二层:兼容 App(折叠备用)────────────────────────────────
1410
1390
  React.createElement('section', { style: { ...styles.card, marginTop: 16 } },
1411
- React.createElement('h3', { className: 'mgw-section-title' }, 'App 直连(备用)'),
1412
- React.createElement('p', { style: styles.muted }, 'DSH App 使用直连入口(上游移动网关的方式);小程序已在上方模块配对时,这里只用于 App。'),
1413
- React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
1414
- React.createElement(GatewaySelect, { style: styles.input, value: appRoute, onChange: (event) => chooseAppRoute(event.target.value), disabled: !status, 'aria-label': 'App 连接方式' },
1415
- React.createElement('option', { value: 'lan', disabled: !lanPairingUrl(status) }, lanPairingUrl(status)
1416
- ? '局域网直连'
1417
- : '局域网直连 · 当前不可用'),
1418
- status?.cloudflare?.supported
1419
- ? React.createElement('option', { value: 'cloudflare' }, 'Cloudflare 外网') : null,
1420
- React.createElement('option', { value: 'tailscale', disabled: !(status && status.lan && status.lan.listening) },
1421
- (status && status.lan && status.lan.listening) ? 'Tailscale 私有网络' : 'Tailscale 私有网络 · 请先开启局域网入口'),
1422
- React.createElement('option', { value: 'custom' }, '公网或其他手动地址'))),
1423
- React.createElement('label', { style: styles.label, htmlFor: 'mgw-pair-address' }, appRoute === 'tailscale'
1424
- ? '主机 Tailscale 地址(运行网关的电脑,不是手机)'
1425
- : '配对入口地址(手机需能访问)'),
1426
- React.createElement('input', {
1427
- id: 'mgw-pair-address',
1428
- style: styles.input,
1429
- value: appUrl,
1430
- onChange: (event) => {
1431
- const value = event.target.value
1432
- if (appRoute === 'tailscale') { manualAppUrlRef.current = true; setAppUrl(value); return }
1433
- if (appRoute !== 'custom') { chooseAppRoute('custom'); setAppUrl(value); return }
1434
- setAppUrl(value)
1435
- },
1436
- placeholder: appRoute === 'tailscale'
1437
- ? '100.x.x.x 或 ws://100.x.x.x:3081/ws/mobile(IPv6 用 [fd7a:…])'
1438
- : 'ws://192.168.1.10:3081/ws/mobile 或 wss://gateway.example.com/ws/mobile',
1439
- spellCheck: false,
1440
- }),
1441
- appRoute === 'tailscale' && appUrl.trim() && !isTailscaleInput(appUrl)
1442
- ? React.createElement('div', { style: { ...styles.error, margin: '-4px 0 8px' } }, '这里要填 100.64.0.0/10(或 fd7a:115c:a1e0::/48)的 Tailscale 私有地址。')
1443
- : null,
1444
- // Tailscale 手动地址指引:检测到本机地址时提示可直接使用。
1445
- appRoute === 'tailscale'
1446
- ? React.createElement('div', { style: { ...styles.muted, margin: '-4px 0 10px', fontWeight: 500 } }, (() => {
1447
- const detected = Array.isArray(status?.tailscale?.urls) ? status.tailscale.urls : []
1448
- return detected.length
1449
- ? `已检测到本机 Tailscale 地址:${detected.join('、')}(可直接生成二维码)。手机需登录同一 tailnet。`
1450
- : '未检测到本机 Tailscale 地址:请填写运行网关这台主机的 Tailscale IP(不是手机 IP),例如 100.x.x.x。手机与电脑需登录同一 tailnet。'
1451
- })())
1452
- : null,
1453
- appRoute !== 'tailscale' && status && status.lan && status.lan.enabled
1454
- ? 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)' } },
1455
- status.lan.error
1456
- ? `局域网监听失败:${status.lan.error}`
1457
- : status.lan.listening
1458
- ? `局域网入口已开启${status.lan.urls && status.lan.urls.length ? `:${status.lan.urls.join('、')}` : `,端口 ${status.lan.port}`}`
1459
- : '局域网入口启动中…')
1460
- : null,
1461
- appRoute === 'cloudflare' && !cloudflareReady
1462
- ? React.createElement('div', { style: { ...styles.muted, margin: '-4px 0 10px', fontWeight: 500 } }, status?.cloudflare?.enabled
1463
- ? 'Cloudflare 外网尚未就绪,请稍候或查看下方 Cloudflare 设置。'
1464
- : '尚未开启 Cloudflare Tunnel,可在下方设置中一键开启。')
1465
- : null,
1466
- React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 12, flexWrap: 'wrap' } },
1467
- React.createElement('button', {
1468
- style: { ...styles.button, ...styles.primary, opacity: appPairingDisabled ? .65 : 1 },
1469
- disabled: appPairingDisabled,
1470
- onClick: () => pairFor('app'),
1471
- }, busy ? '正在生成…' : !(status && status.gatewayEnabled) ? '请先开启移动网关'
1472
- : appRoute === 'cloudflare' && !cloudflareReady
1473
- ? status?.cloudflare?.enabled ? '等待 Cloudflare 外网就绪' : '先开启 Cloudflare Tunnel'
1474
- : appRoute === 'tailscale' && !status?.lan?.listening ? '请先开启局域网入口'
1475
- : appRoute === 'tailscale' && !isTailscaleInput(appUrl) ? '填写主机 Tailscale 地址'
1476
- : appRoute === 'lan' && !lanPairingUrl(status) ? '当前不可用'
1477
- : appRoute === 'custom' && !appUrl.trim() ? '等待连接地址' : '生成 App 二维码'),
1478
- React.createElement('span', { style: styles.muted }, '二维码只发给 App;小程序请用上方模块。'))),
1479
- appRoute === 'cloudflare' && status?.cloudflare?.supported
1391
+ React.createElement('button', {
1392
+ type: 'button',
1393
+ style: { ...styles.button, width: '100%', textAlign: 'left', display: 'flex', justifyContent: 'space-between', alignItems: 'center', background: 'transparent', border: 0, padding: 0 },
1394
+ 'aria-expanded': appLayerOpen,
1395
+ onClick: () => setAppLayerOpen((value) => !value),
1396
+ },
1397
+ React.createElement('span', null,
1398
+ React.createElement('strong', null, '兼容 App(备用)'),
1399
+ React.createElement('span', { style: { ...styles.muted, marginLeft: 8, fontWeight: 400 } },
1400
+ appLayerOpen ? '收起 App 兼容方式' : '需要连接 DSH App 时展开')),
1401
+ React.createElement('span', { 'aria-hidden': true, style: styles.muted }, appLayerOpen ? '▾' : '▸')),
1402
+ appLayerOpen
1403
+ ? React.createElement(React.Fragment, null,
1404
+ React.createElement('p', { style: styles.muted }, '仅用于 DSH App(上游移动网关的直连方式),与上方鲸尾公网互不影响。'),
1405
+ React.createElement('div', { style: { display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '8px 14px', maxWidth: '100%' } },
1406
+ React.createElement(GatewaySelect, { style: styles.input, value: appRoute, onChange: (event) => chooseAppRoute(event.target.value), disabled: !status, 'aria-label': 'App 连接方式' },
1407
+ React.createElement('option', { value: 'auto' }, '自动选择'),
1408
+ React.createElement('option', { value: 'lan', disabled: !lanPairingUrl(status) }, lanPairingUrl(status)
1409
+ ? '局域网直连'
1410
+ : '局域网直连 · 当前不可用'),
1411
+ status?.cloudflare?.supported
1412
+ ? React.createElement('option', { value: 'cloudflare' }, 'Cloudflare 外网') : null,
1413
+ React.createElement('option', { value: 'tailscale', disabled: !(status && status.lan && status.lan.listening) },
1414
+ (status && status.lan && status.lan.listening) ? 'Tailscale 私有网络' : 'Tailscale 私有网络 · 请先开启局域网入口'),
1415
+ React.createElement('option', { value: 'custom' }, '公网或其他手动地址'))),
1416
+ React.createElement('label', { style: styles.label, htmlFor: 'mgw-pair-address' }, appRoute === 'tailscale'
1417
+ ? '主机 Tailscale 地址(运行网关的电脑,不是手机)'
1418
+ : '配对入口地址(手机需能访问)'),
1419
+ React.createElement('input', {
1420
+ id: 'mgw-pair-address',
1421
+ style: styles.input,
1422
+ value: appUrl,
1423
+ onChange: (event) => {
1424
+ const value = event.target.value
1425
+ if (appRoute === 'tailscale') { manualAppUrlRef.current = true; setAppUrl(value); return }
1426
+ if (appRoute !== 'custom') { chooseAppRoute('custom'); setAppUrl(value); return }
1427
+ setAppUrl(value)
1428
+ },
1429
+ placeholder: appRoute === 'tailscale'
1430
+ ? '100.x.x.x 或 ws://100.x.x.x:3081/ws/mobile(IPv6 用 [fd7a:…])'
1431
+ : 'ws://192.168.1.10:3081/ws/mobile 或 wss://gateway.example.com/ws/mobile',
1432
+ spellCheck: false,
1433
+ }),
1434
+ appRoute === 'tailscale' && appUrl.trim() && !isTailscaleInput(appUrl)
1435
+ ? React.createElement('div', { style: { ...styles.error, margin: '-4px 0 8px' } }, '这里要填 100.64.0.0/10(或 fd7a:115c:a1e0::/48)的 Tailscale 私有地址。')
1436
+ : null,
1437
+ // Tailscale 手动地址指引:检测到本机地址时提示可直接使用。
1438
+ appRoute === 'tailscale'
1439
+ ? React.createElement('div', { style: { ...styles.muted, margin: '-4px 0 10px', fontWeight: 500 } }, (() => {
1440
+ const detected = Array.isArray(status?.tailscale?.urls) ? status.tailscale.urls : []
1441
+ return detected.length
1442
+ ? `已检测到本机 Tailscale 地址:${detected.join('、')}(可直接生成二维码)。手机需登录同一 tailnet。`
1443
+ : '未检测到本机 Tailscale 地址:请填写运行网关这台主机的 Tailscale IP(不是手机 IP),例如 100.x.x.x。手机与电脑需登录同一 tailnet。'
1444
+ })())
1445
+ : null,
1446
+ appRoute !== 'tailscale' && status && status.lan && status.lan.enabled
1447
+ ? 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)' } },
1448
+ status.lan.error
1449
+ ? `局域网监听失败:${status.lan.error}`
1450
+ : status.lan.listening
1451
+ ? `局域网入口已开启${status.lan.urls && status.lan.urls.length ? `:${status.lan.urls.join('、')}` : `,端口 ${status.lan.port}`}`
1452
+ : '局域网入口启动中…')
1453
+ : null,
1454
+ appRoute === 'cloudflare' && !cloudflareReady
1455
+ ? React.createElement('div', { style: { ...styles.muted, margin: '-4px 0 10px', fontWeight: 500 } }, status?.cloudflare?.enabled
1456
+ ? 'Cloudflare 外网尚未就绪,请稍候或查看下方 Cloudflare 设置。'
1457
+ : '尚未开启 Cloudflare Tunnel,可在下方设置中一键开启。')
1458
+ : null,
1459
+ React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 12, flexWrap: 'wrap' } },
1460
+ React.createElement('button', {
1461
+ style: { ...styles.button, ...styles.primary, opacity: appPairingDisabled ? .65 : 1 },
1462
+ disabled: appPairingDisabled,
1463
+ onClick: () => pairFor('app'),
1464
+ }, busy ? '正在生成…' : !(status && status.gatewayEnabled) ? '请先开启移动网关'
1465
+ : appRoute === 'cloudflare' && !cloudflareReady
1466
+ ? status?.cloudflare?.enabled ? '等待 Cloudflare 外网就绪' : '先开启 Cloudflare Tunnel'
1467
+ : appRoute === 'tailscale' && !status?.lan?.listening ? '请先开启局域网入口'
1468
+ : appRoute === 'tailscale' && !isTailscaleInput(appUrl) ? '填写主机 Tailscale 地址'
1469
+ : appRoute === 'lan' && !lanPairingUrl(status) ? '当前不可用'
1470
+ : appRoute === 'custom' && !appUrl.trim() ? '等待连接地址' : '生成 App 二维码'),
1471
+ React.createElement('span', { style: styles.muted }, '二维码只发给 App;小程序请用上方模块。')))
1472
+ : React.createElement('p', { style: { ...styles.muted, margin: '8px 0 0' } }, '局域网直连 / Cloudflare 外网 / Tailscale 私有网络 / 公网或其他手动地址;与鲸尾公网互不影响。')),
1473
+ appLayerOpen && appRoute === 'cloudflare' && status?.cloudflare?.supported
1480
1474
  ? React.createElement('section', { className: 'mgw-cloudflare-block', style: { ...styles.card, background: colors.card, border: 0, borderRadius: 16, padding: 18, marginTop: 16 } },
1481
1475
  React.createElement('h3', { className: 'mgw-section-title' }, 'Cloudflare Tunnel · 外网接入'),
1482
1476
  React.createElement('p', { style: styles.muted }, status.platform === 'linux'
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
- : normalizePublicUrl(body.publicUrl || configuredUrl, req, wsPath)
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-weapp-gateway",
3
- "version": "0.8.48",
3
+ "version": "0.8.50",
4
4
  "description": "鲸尾网关助手:DeepSeek Harness 移动客户端连接与会话同步,支持安全配对、远程访问、上下文、编队、额度和语音输入",
5
5
  "main": "lib/index.mjs",
6
6
  "files": [