同步前后端联调与文档更新

This commit is contained in:
2026-04-02 09:25:05 +08:00
parent af43beadb0
commit 6964e26ec9
113 changed files with 4317 additions and 293 deletions

View File

@@ -1,6 +1,6 @@
# Mock GPS Simulator
> 文档版本v1.0
> 最后更新2026-04-02
> 最后更新2026-04-02 08:28:05
## 启动
@@ -19,6 +19,19 @@ npm run mock-gps-sim
- 小程序调试日志地址: `ws://127.0.0.1:17865/debug-log`
- 资源代理: `http://127.0.0.1:17865/proxy?url=<remote-url>`
补充说明:
- 模拟器工作台内部现在会按当前页面地址自动推导 websocket 地址。
- 本地访问 `http://127.0.0.1:17865/` 时,会自动连接:
- `ws://127.0.0.1:17865/mock-gps`
- `ws://127.0.0.1:17865/mock-hr`
- `ws://127.0.0.1:17865/debug-log`
- 外网访问例如 `https://gs.gotomars.xyz/` 时,会自动连接同源:
- `wss://gs.gotomars.xyz/mock-gps`
- `wss://gs.gotomars.xyz/mock-hr`
- `wss://gs.gotomars.xyz/debug-log`
- 因此外网页面不能再把 `https://gs.gotomars.xyz/` 当作 websocket 地址手工填写;应直接使用对应的 `wss://...` 路径,或让工作台按同源自动连接。
## 多通道联调
模拟器现在支持一个最小的多通道隔离方案:
@@ -281,3 +294,4 @@ http://192.168.1.23:17865/
ws://192.168.1.23:17865/debug-log
```

View File

@@ -3,9 +3,16 @@
const DEFAULT_CONFIG_URL = 'https://oss-mbh5.colormaprun.com/wxmini/test/game.json'
const DEFAULT_TILE_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
const PROXY_BASE_URL = `${location.origin}/proxy?url=`
const GPS_WS_URL = `ws://${location.hostname}:17865/mock-gps`
const HEART_RATE_WS_URL = `ws://${location.hostname}:17865/mock-hr`
const DEBUG_LOG_WS_URL = `ws://${location.hostname}:17865/debug-log`
function createSameOriginWsUrl(pathname) {
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'
const normalizedPath = String(pathname || '').startsWith('/') ? pathname : `/${pathname}`
return `${wsProtocol}//${location.host}${normalizedPath}`
}
const GPS_WS_URL = createSameOriginWsUrl('/mock-gps')
const HEART_RATE_WS_URL = createSameOriginWsUrl('/mock-hr')
const DEBUG_LOG_WS_URL = createSameOriginWsUrl('/debug-log')
const DEFAULT_GATEWAY_BRIDGE_URL = 'ws://127.0.0.1:18080/ws'
const LEGACY_GATEWAY_BRIDGE_URLS = new Set([
'ws://127.0.0.1:8080/ws',