dsh-mesh-ui 0.0.5 → 0.0.6

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.
Files changed (2) hide show
  1. package/lib/client.js +48 -18
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1254,22 +1254,55 @@ function deviceLinkState(data, peer, lanMap) {
1254
1254
  var p = String(d.path || '').replace(/[\\/]+$/, '')
1255
1255
  return (d.freeGB != null ? d.freeGB : '?') + ' / ' + d.totalGB + ' GB' + (p ? ' (' + p + ')' : '')
1256
1256
  }
1257
+ // 设备类型:按平台/CPU 形态泛化推断(不依赖任何个人设备表)
1258
+ function formFactorOf(h) {
1259
+ if (!h) return '—'
1260
+ if (h.platform === 'linux' && String(h.arch || '').indexOf('arm') === 0) return '手机'
1261
+ var cpu = String(h.cpuModel || '')
1262
+ return cpu ? '主机' : '—'
1263
+ }
1264
+ function memTextOf(h) {
1265
+ return h && h.memTotalGB ? ((h.memFreeGB != null ? h.memFreeGB : '?') + ' / ' + h.memTotalGB + ' GB') : '—'
1266
+ }
1267
+ function cpuTextOf(h) {
1268
+ return h && h.cpuModel ? h.cpuModel + ' · ' + (h.cpuCores || '?') + ' 线程' : '—'
1269
+ }
1270
+ function ipKindOf(peer) {
1271
+ var t = peer.tunnel || {}
1272
+ if (t.kind === 'loopback') return '本机回环'
1273
+ if (t.kind === 'lan') return '局域网直连'
1274
+ if (t.kind === 'frp') return '公网穿透(域名)'
1275
+ if (t.kind === 'wan') return relayHosts[String(t.host || '').toLowerCase()] ? '公网(共享中转)' : '公网 IP 直连'
1276
+ return '—'
1277
+ }
1278
+ function relayKindOf(peer) {
1279
+ var t = peer.tunnel || {}
1280
+ if (t.kind === 'loopback') return '无(本机回环)'
1281
+ if (t.kind === 'lan') return '无(局域网直连)'
1282
+ if (t.kind === 'frp') return 'Sakura / 第三方 frp 穿透'
1283
+ if (t.kind === 'wan') return relayHosts[String(t.host || '').toLowerCase()] ? '自建公网中继(frps)' : '公网 IP 直连'
1284
+ return '—'
1285
+ }
1286
+ function dshVerOf(peer) {
1287
+ var v = peer.version ? 'v' + peer.version : '—'
1288
+ if (peer.plugin) v += ' · 插件 ' + peer.plugin
1289
+ return v
1290
+ }
1257
1291
 
1258
1292
  var devices = [{
1259
1293
  key: 'local',
1260
1294
  name: nodeDisplay(data.nodeName) + '(本机)',
1261
1295
  up: Boolean(endpoint.up),
1262
1296
  rows: [
1297
+ ['设备类型', formFactorOf(hw)],
1263
1298
  ['操作系统', hw.os || '—'],
1264
- ['CPU', cpuText],
1265
- ['内存', memText],
1299
+ ['内存', memTextOf(hw)],
1266
1300
  ['磁盘', diskText(hw.disk)],
1267
- ['DSH 实例', localUp + '/' + instances.length + ' 在线'],
1268
- ['会话 / 运行', sessions + ' / ' + running],
1269
- ['模型', model],
1270
- ...localTunnelRows,
1271
- ['端点', (endpoint.pid != null ? 'pid ' + endpoint.pid : '—') + ' · tools ' + (endpoint.tools != null ? endpoint.tools : '—') + ' · mesh ' + (data.meshVersion || '?')],
1272
- ['检测时间', clockText(data.at)]
1301
+ ['CPU', cpuTextOf(hw)],
1302
+ ['DSH 版本', data.meshVersion ? 'v' + data.meshVersion : '—'],
1303
+ ['IP 类型', '本机回环'],
1304
+ ['端口号', localTunnel.port != null ? String(localTunnel.port) : '—'],
1305
+ ['公网穿透类型', mainSrc === 'self-hosted' ? '自建 frps 中继(主用)' : (mainSrc === 'sakura' ? 'Sakura 穿透(备用)' : '无(仅局域网)')]
1273
1306
  ]
1274
1307
  }].concat(peers.map(function (peer) {
1275
1308
  var t = peer.tunnel || {}
@@ -1279,18 +1312,15 @@ function deviceLinkState(data, peer, lanMap) {
1279
1312
  name: nodeDisplay(peerDeviceKey(peer.name)),
1280
1313
  up: Boolean(peer.up),
1281
1314
  rows: [
1315
+ ['设备类型', formFactorOf(hwp)],
1282
1316
  ['操作系统', hwp.os || peer.os || '—'],
1283
- ['CPU', hwp.cpuModel ? hwp.cpuModel + ' · ' + (hwp.cpuCores || '?') + ' 线程' : '—'],
1284
- ['内存', hwp.memTotalGB ? ((hwp.memFreeGB != null ? hwp.memFreeGB : '?') + ' / ' + hwp.memTotalGB + ' GB') : '—'],
1317
+ ['内存', memTextOf(hwp)],
1285
1318
  ['磁盘', diskText(hwp.disk)],
1286
- ['运行时长', uptimeText(peer.uptimeSec)],
1287
- ['DSH 实例', (peer.instancesCount || 0) + ' 个(' + ((peer.instancesList || []).map(function (x) { return x.port + (x.up ? '✓' : '✗') }).join(' ') || '—') + ')'],
1288
- ['会话 / 运行', (peer.sessions || 0) + ' / ' + (peer.running || 0)],
1289
- ['任务(进行中)', peer.tasksActive == null ? '—' : String(peer.tasksActive)],
1290
- ['入口', t.host ? t.host + (t.port ? ':' + t.port : '') : '—'],
1291
- ['链路', commLabel(peer, relayHosts).text + ' · ' + (peer.up ? (peer.latencyMs == null ? '—' : peer.latencyMs + 'ms') : '离线') + ' · ' + (peer.tls ? 'TLS ✓' : 'TLS ✗') + ' · v' + (peer.version || '?')],
1292
- ['节点 pid / tools', (peer.nodePid == null ? '—' : peer.nodePid) + ' / ' + (peer.nodeTools == null ? '—' : peer.nodeTools)],
1293
- ['检测时间', clockText(peer.detectedAt || data.at)]
1319
+ ['CPU', cpuTextOf(hwp)],
1320
+ ['DSH 版本', dshVerOf(peer)],
1321
+ ['IP 类型', ipKindOf(peer)],
1322
+ ['端口号', t.port ? String(t.port) : '—'],
1323
+ ['公网穿透类型', relayKindOf(peer)]
1294
1324
  ]
1295
1325
  }
1296
1326
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mesh-ui",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "DSH settings-page panel for dsh-mesh: AI network topology, peer health, and delegation panel. Read-only; data is collected from the local mesh CLI.",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",