yeg
2026-08-30 d61dec87cf2dbaccc533fa369994d4f49b831ea5
修复模拟器开机控制页响应处理
1个文件已修改
15 ■■■■■ 已修改文件
ruoyi-admin/src/main/resources/static/dev/bts-simulator.html 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/static/dev/bts-simulator.html
@@ -133,10 +133,13 @@
      const response = await fetch(api + path, { ...options, headers: { 'Content-Type': 'application/json' } });
      if (!response.ok) {
        let message = `请求失败 (${response.status})`;
        try { message = (await response.json()).message || message; } catch (_) { }
        try { const error = await response.json(); message = error?.msg || error?.message || message; } catch (_) { }
        throw new Error(message);
      }
      return response.json();
      const payload = await response.json();
      if (payload && payload.data && typeof payload.data === 'object'
        && !Array.isArray(payload.devices) && payload.data.devices) return payload.data;
      return payload;
    }
    function showError(error) {
@@ -146,6 +149,14 @@
    function render(state) {
      errorBox.classList.remove('visible');
      if (!state || typeof state !== 'object') throw new Error('模拟器响应缺少状态数据');
      if (state.data && typeof state.data === 'object' && !Array.isArray(state.devices)) state = state.data;
      state = {
        ...state,
        devices: Array.isArray(state.devices) ? state.devices : [],
        collectors: Array.isArray(state.collectors) ? state.collectors : [],
        recentRequests: Array.isArray(state.recentRequests) ? state.recentRequests : [],
      };
      const runtime = document.querySelector('#runtime');
      runtime.textContent = state.running ? '运行中' : '已停止';
      runtime.classList.toggle('online', state.running);