/**
 * 假数据
 */
const pools = [
    {
      pool: 1,
      url: "http://34343424224:433",
      user: "AABBBB",
      status: "Normal",
      diff: "524k",
      getWorks: 652,
      accepted: 2965,
      rejected: 0,
    },
    {
      pool: 1,
      url: "http://34343424224:433",
      user: "AABBBB",
      status: "Normal",
      diff: "666k",
      getWorks: 1000,
      accepted: 2000,
      rejected: 0,
    },
    {
      pool: 1,
      url: "http://34343424224:433",
      user: "AABBBB",
      status: "Error",
      diff: "-",
      getWorks: "-",
      accepted: "-",
      rejected: 0,
    },
  ];
  
  const logs = [
    "Apr 24 17:15:58 miner local0.err cgminer: error_event:=init miner board 1 fail!",
    "Apr 24 17:15:58 miner local0.err cgminer: error_event:=init miner board 1 fail!",
    "Apr 24 17:15:58 miner local0.err cgminer: error_event:=init miner board 1 fail!",
    "Apr 24 17:15:58 miner local0.err cgminer: error_event:=init miner board 1 fail!",
  ];
  
  /**
   * 渲染矿池表格
   */
  const renderPools = () => {
    const tbody = document.getElementById('pools-tbody');
    if (!tbody) return;
    tbody.innerHTML = pools.map(pool => `
      <tr>
        <td>${pool.pool}</td>
        <td>${pool.url}</td>
        <td>${pool.user}</td>
        <td>
          <span class="badge ${pool.status === 'Normal' ? 'badge-normal' : 'badge-error'}">
            ${pool.status}
          </span>
        </td>
        <td>${pool.diff}</td>
        <td>${pool.getWorks}</td>
        <td>${pool.accepted}</td>
        <td>${pool.rejected}</td>
      </tr>
    `).join('');
  };
  
  /**
   * 渲染诊断日志
   */
  const renderLogs = () => {
    const logDiv = document.getElementById('diagnostic-log');
    if (!logDiv) return;
    logDiv.innerHTML = logs.map(log => `<div>${log}</div>`).join('');
  };
  
  /**
   * 重启按钮事件
   */
  const handleRestart = () => {
    alert('重启功能未实现');
  };
  
  // 初始化
  window.addEventListener('DOMContentLoaded', () => {
    renderPools();
    renderLogs();
    window.handleRestart = handleRestart;
  });