index.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <!doctype html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Mock GPS Simulator</title>
  7. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
  8. <link rel="stylesheet" href="./style.css">
  9. </head>
  10. <body>
  11. <div class="layout">
  12. <aside class="panel">
  13. <div class="panel__header">
  14. <div class="panel__eyebrow">MOCK GPS SIM</div>
  15. <h1>外部模拟器</h1>
  16. <div id="socketStatus" class="badge badge--muted">未连接</div>
  17. </div>
  18. <section class="group">
  19. <div class="group__title">资源加载</div>
  20. <label class="field">
  21. <span>游戏配置 URL</span>
  22. <input id="configUrlInput" type="text" value="https://oss-mbh5.colormaprun.com/wxmini/test/game.json">
  23. </label>
  24. <div class="row">
  25. <button id="loadConfigBtn" class="btn btn--primary">载入配置</button>
  26. <button id="fitCourseBtn" class="btn">适配视野</button>
  27. </div>
  28. <label class="field">
  29. <span>瓦片模板</span>
  30. <input id="tileUrlInput" type="text" placeholder="https://host/tiles/{z}/{x}/{y}.webp">
  31. </label>
  32. <div class="row">
  33. <button id="applyTilesBtn" class="btn">应用瓦片</button>
  34. <button id="resetTilesBtn" class="btn">恢复 OSM</button>
  35. </div>
  36. <label class="field">
  37. <span>KML URL</span>
  38. <input id="courseUrlInput" type="text" placeholder="https://host/course/c01.kml">
  39. </label>
  40. <div class="row">
  41. <button id="loadCourseBtn" class="btn">载入控制点</button>
  42. <button id="clearCourseBtn" class="btn">清空控制点</button>
  43. </div>
  44. <div id="resourceStatus" class="hint">支持直接载入 game.json,也支持单独填瓦片模板和 KML 地址。</div>
  45. <div id="resourceDetail" class="group__status">尚未载入资源</div>
  46. <div id="courseJumpList" class="jump-list"></div>
  47. </section>
  48. <section class="group">
  49. <div class="group__title">实时发送</div>
  50. <div id="realtimeStatus" class="group__status">桥接未连接</div>
  51. <div id="lastSendStatus" class="group__status">最近发送: --</div>
  52. <div class="row">
  53. <button id="connectBtn" class="btn btn--primary">连接桥接</button>
  54. <button id="sendOnceBtn" class="btn">发送一次</button>
  55. </div>
  56. <div class="row">
  57. <button id="streamBtn" class="btn btn--accent">开始连续发送</button>
  58. <button id="stopStreamBtn" class="btn">停止发送</button>
  59. </div>
  60. <label class="field">
  61. <span>发送频率</span>
  62. <select id="hzSelect">
  63. <option value="2">2 Hz</option>
  64. <option value="5" selected>5 Hz</option>
  65. <option value="10">10 Hz</option>
  66. </select>
  67. </label>
  68. <label class="field">
  69. <span>精度 (m)</span>
  70. <input id="accuracyInput" type="number" min="1" max="100" value="6">
  71. </label>
  72. </section>
  73. <section class="group">
  74. <div class="group__title">新网关桥接</div>
  75. <div id="gatewayBridgeStatus" class="group__status">未启用</div>
  76. <div id="gatewayBridgeTarget" class="group__status">目标设备: --</div>
  77. <div id="gatewayBridgeLast" class="group__status">最近状态: --</div>
  78. <label class="field">
  79. <span>桥接预设</span>
  80. <select id="gatewayBridgePresetSelect">
  81. <option value="">选择预设</option>
  82. </select>
  83. </label>
  84. <label class="field">
  85. <span>预设名称</span>
  86. <input id="gatewayBridgePresetNameInput" type="text" placeholder="例如:家长端-A / 场控-B">
  87. </label>
  88. <div class="row">
  89. <button id="applyGatewayBridgePresetBtn" class="btn">套用预设</button>
  90. <button id="saveGatewayBridgePresetBtn" class="btn">保存预设</button>
  91. </div>
  92. <div class="row">
  93. <button id="deleteGatewayBridgePresetBtn" class="btn">删除预设</button>
  94. </div>
  95. <label class="field field--check">
  96. <input id="gatewayBridgeEnabledInput" type="checkbox">
  97. <span>启用新网关桥接</span>
  98. </label>
  99. <label class="field">
  100. <span>网关地址</span>
  101. <input id="gatewayBridgeUrlInput" type="text" placeholder="ws://127.0.0.1:18080/ws">
  102. </label>
  103. <label class="field">
  104. <span>Producer Token / Channel Token</span>
  105. <input id="gatewayBridgeTokenInput" type="text" placeholder="producerToken 或 dev-producer-token">
  106. </label>
  107. <label class="field">
  108. <span>Channel ID</span>
  109. <input id="gatewayBridgeChannelIdInput" type="text" placeholder="ch-xxxx">
  110. </label>
  111. <label class="field">
  112. <span>目标 Device ID</span>
  113. <input id="gatewayBridgeDeviceIdInput" type="text" placeholder="child-001">
  114. </label>
  115. <label class="field">
  116. <span>目标 Group ID</span>
  117. <input id="gatewayBridgeGroupIdInput" type="text" placeholder="class-a">
  118. </label>
  119. <label class="field">
  120. <span>Source ID</span>
  121. <input id="gatewayBridgeSourceIdInput" type="text" placeholder="mock-gps-sim">
  122. </label>
  123. <label class="field">
  124. <span>Source Mode</span>
  125. <input id="gatewayBridgeSourceModeInput" type="text" placeholder="mock">
  126. </label>
  127. <div class="row">
  128. <button id="applyGatewayBridgeConfigBtn" class="btn btn--primary">应用桥接配置</button>
  129. <button id="reloadGatewayBridgeConfigBtn" class="btn">重新读取</button>
  130. </div>
  131. </section>
  132. <section class="group">
  133. <div class="group__title">心率模拟</div>
  134. <div id="heartRateStatus" class="group__status">心率模拟待命</div>
  135. <div id="lastHeartRateStatus" class="group__status">最近发送: --</div>
  136. <div class="row">
  137. <button id="sendHeartRateOnceBtn" class="btn">发送一次</button>
  138. <button id="startHeartRateStreamBtn" class="btn btn--accent">开始连续发送</button>
  139. </div>
  140. <div class="row">
  141. <button id="stopHeartRateStreamBtn" class="btn">停止发送</button>
  142. <button id="applyHeartRatePresetBtn" class="btn">应用分区样本</button>
  143. </div>
  144. <div class="row">
  145. <button id="toggleHeartRateSampleBtn" class="btn">模拟真实样本</button>
  146. </div>
  147. <label class="field">
  148. <span>心率值 (bpm)</span>
  149. <input id="heartRateInput" type="number" min="40" max="220" value="120">
  150. </label>
  151. <label class="field">
  152. <span>发送频率</span>
  153. <select id="heartRateHzSelect">
  154. <option value="1" selected>1 Hz</option>
  155. <option value="2">2 Hz</option>
  156. <option value="4">4 Hz</option>
  157. </select>
  158. </label>
  159. <label class="field">
  160. <span>样本模板</span>
  161. <select id="heartRateSampleTemplateSelect">
  162. <option value="jog" selected>慢跑样本</option>
  163. <option value="tempo">节奏跑样本</option>
  164. <option value="interval">间歇跑样本</option>
  165. <option value="recovery">恢复走样本</option>
  166. </select>
  167. </label>
  168. </section>
  169. <section class="group">
  170. <div class="group__title">路径回放</div>
  171. <div id="playbackStatus" class="group__status">路径待命</div>
  172. <input id="trackFileInput" class="file-input-hidden" type="file" accept=".gpx,.kml,.geojson,.json,application/json,application/gpx+xml,application/vnd.google-earth.kml+xml">
  173. <div class="row">
  174. <button id="importTrackBtn" class="btn">导入轨迹文件</button>
  175. <button id="togglePathModeBtn" class="btn">开启路径编辑</button>
  176. </div>
  177. <div class="row">
  178. <button id="clearPathBtn" class="btn">清空路径</button>
  179. <button id="fitPathBtn" class="btn">适配路径</button>
  180. </div>
  181. <div class="row">
  182. <button id="playPathBtn" class="btn btn--accent">开始回放</button>
  183. <button id="pausePathBtn" class="btn">暂停回放</button>
  184. </div>
  185. <label class="field">
  186. <span>移动速度 (km/h)</span>
  187. <input id="speedInput" type="number" min="1" max="25" step="0.1" value="6">
  188. </label>
  189. <label class="field field--check">
  190. <input id="loopPathInput" type="checkbox" checked>
  191. <span>循环回放</span>
  192. </label>
  193. <div id="pathHint" class="hint">点击“开启路径编辑”后,在地图上逐点添加路径。</div>
  194. </section>
  195. <section class="group">
  196. <div class="group__title">当前位置</div>
  197. <div class="stat"><span>纬度</span><strong id="latText">--</strong></div>
  198. <div class="stat"><span>经度</span><strong id="lonText">--</strong></div>
  199. <div class="stat"><span>航向</span><strong id="headingText">--</strong></div>
  200. <div class="stat"><span>路径点</span><strong id="pathCountText">0</strong></div>
  201. </section>
  202. <section class="group">
  203. <div class="group__title">日志</div>
  204. <div id="log" class="log"></div>
  205. </section>
  206. </aside>
  207. <main class="map-shell">
  208. <div id="map"></div>
  209. </main>
  210. </div>
  211. <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
  212. <script src="./simulator.js"></script>
  213. </body>
  214. </html>