完善后端联调链路与模拟器多通道支持
This commit is contained in:
@@ -41,6 +41,8 @@ group-01
|
||||
|
||||
然后在小程序调试面板里把“模拟通道号”也配成同一个值。
|
||||
|
||||
当前“模拟通道号”位于工作台顶部,属于全局调试参数,不再归属某个单独分组。
|
||||
|
||||
## 当前能力
|
||||
|
||||
- 直接载入 `game.json`
|
||||
@@ -83,6 +85,13 @@ ws://127.0.0.1:17865/debug-log
|
||||
|
||||
当前 UI 会通过独立日志通道把这类消息显示到“调试日志”区域。
|
||||
|
||||
日志区域当前是:
|
||||
|
||||
- 地图右下角浮层
|
||||
- 可展开 / 缩小
|
||||
- 支持按 `scope` 过滤
|
||||
- 按当前 `channelId` 隔离显示
|
||||
|
||||
第一阶段主要用于承接:
|
||||
|
||||
- `gps-logo`
|
||||
|
||||
@@ -106,6 +106,11 @@ function isDebugLogPayload(payload) {
|
||||
&& typeof payload.message === 'string'
|
||||
}
|
||||
|
||||
function normalizeChannelId(value) {
|
||||
const trimmed = String(value || '').trim()
|
||||
return trimmed || 'default'
|
||||
}
|
||||
|
||||
async function handleProxyRequest(request, response) {
|
||||
const requestUrl = new URL(request.url || '/', `http://127.0.0.1:${PORT}`)
|
||||
const targetUrl = requestUrl.searchParams.get('url')
|
||||
@@ -533,6 +538,7 @@ gpsWss.on('connection', (socket) => {
|
||||
const outgoing = JSON.stringify({
|
||||
type: 'mock_gps',
|
||||
timestamp: Number.isFinite(parsed.timestamp) ? parsed.timestamp : Date.now(),
|
||||
channelId: normalizeChannelId(parsed.channelId),
|
||||
lat: Number(parsed.lat),
|
||||
lon: Number(parsed.lon),
|
||||
accuracyMeters: Number.isFinite(parsed.accuracyMeters) ? Number(parsed.accuracyMeters) : 6,
|
||||
@@ -566,6 +572,7 @@ heartRateWss.on('connection', (socket) => {
|
||||
const outgoing = JSON.stringify({
|
||||
type: 'mock_heart_rate',
|
||||
timestamp: Number.isFinite(parsed.timestamp) ? parsed.timestamp : Date.now(),
|
||||
channelId: normalizeChannelId(parsed.channelId),
|
||||
bpm: Math.max(1, Math.round(Number(parsed.bpm))),
|
||||
})
|
||||
gatewayBridge.publish(JSON.parse(outgoing))
|
||||
@@ -595,6 +602,7 @@ debugLogWss.on('connection', (socket) => {
|
||||
const outgoing = JSON.stringify({
|
||||
type: 'debug-log',
|
||||
timestamp: Number.isFinite(parsed.timestamp) ? parsed.timestamp : Date.now(),
|
||||
channelId: normalizeChannelId(parsed.channelId),
|
||||
scope: String(parsed.scope || 'app').slice(0, 64),
|
||||
level: parsed.level === 'warn' || parsed.level === 'error' ? parsed.level : 'info',
|
||||
message: String(parsed.message || '').slice(0, 400),
|
||||
|
||||
Reference in New Issue
Block a user