fix: 管理后台连接状态 + 修复按钮无响应

连接状态(正式):
- /api/display/state 扩展:screens_online(大屏心跳统计,opc/display/heartbeat)+ last_command(最近指令与发布结果)
- 前端大屏每 10s 上报心跳(稳定 client_id),后端 30s TTL 统计在线大屏数
- 管理台新增「连接状态」卡片:后端/MQTT/在线大屏/最近指令,3s 轮询刷新

按钮无响应根治:
- admin.js 改为 document 事件委托(data-nav/data-control/data-action/复制/预览),不再依赖逐个绑定
- /static 与 /admin 响应加 no-cache 头,杜绝旧 JS/CSS 缓存导致的按钮失效
- SSE 不再自动重载页面(避免与操作回调双重重载清掉反馈);立即播放改为 toast 不重载
This commit is contained in:
Pine
2026-08-17 21:54:23 +08:00
parent 1a95ecbacb
commit c55835fb7d
10 changed files with 297 additions and 86 deletions
+11
View File
@@ -69,6 +69,17 @@ app.add_middleware(
allow_headers=["*"],
)
@app.middleware("http")
async def no_cache_admin_static(request: Request, call_next):
"""管理后台页面与静态资源禁用缓存,避免旧 JS/CSS 残留导致按钮无响应"""
response = await call_next(request)
if request.url.path.startswith(("/static/", "/admin")):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "0"
return response
app.include_router(router)
# 媒体资源静态服务(上传/播放的文件)