feat: 管理后台UI全面优化 + TCP指令发送修复

- 指令页面:三个设备选择器合并为顶部统一选择器,在线/离线分组显示
- 仪表盘:8卡片压缩为6紧凑卡片,新增刷新按钮和更新时间戳
- 仪表盘:最近告警添加"查看全部"跳转链接
- 考勤页面:定位方式显示GPS/WiFi/LBS文字标签替代纯图标
- 告警页面:alarm_source中文化(单围栏/多围栏/基站/WiFi)
- 告警页面:确认操作改为DOM单行更新,无需刷新整个表格
- 数据日志:默认选中"位置"类型
- 全部表格:全选复选框tooltip改为"全选当前页"
- TCP修复:移除发送前硬性在线检查,改为尝试发送+失败提示
- TCP修复:检测僵死连接(writer.is_closing)并自动清理

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
This commit is contained in:
2026-03-31 05:01:04 +00:00
parent 61c300bad8
commit b970b78136
3 changed files with 162 additions and 133 deletions

View File

@@ -2445,6 +2445,13 @@ class TCPManager:
return False
_reader, writer, conn_info = conn
# Check if the writer is still alive
if writer.is_closing():
logger.warning("IMEI=%s writer is closing, removing stale connection", imei)
del self.connections[imei]
return False
serial = conn_info.next_serial()
# Build 0x80 online-command packet
@@ -2469,7 +2476,8 @@ class TCPManager:
command_content,
)
except Exception:
logger.exception("Failed to send command to IMEI=%s", imei)
logger.exception("Failed to send command to IMEI=%s, removing stale connection", imei)
self.connections.pop(imei, None)
return False
return True
@@ -2495,6 +2503,12 @@ class TCPManager:
return False
_reader, writer, conn_info = conn
if writer.is_closing():
logger.warning("IMEI=%s writer is closing, removing stale connection", imei)
del self.connections[imei]
return False
serial = conn_info.next_serial()
msg_bytes = message.encode("utf-16-be")
@@ -2517,7 +2531,8 @@ class TCPManager:
logger.info("Message sent to IMEI=%s (%d bytes)", imei, len(msg_bytes))
return True
except Exception:
logger.exception("Failed to send message to IMEI=%s", imei)
logger.exception("Failed to send message to IMEI=%s, removing stale connection", imei)
self.connections.pop(imei, None)
return False
# ------------------------------------------------------------------