From 9e1819cd7526ee3bd3937bba6069358d868f159a Mon Sep 17 00:00:00 2001 From: zhaojingkui <1553836110@qq.com> Date: Mon, 19 May 2025 01:48:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86log=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2,=E4=BD=86=E6=98=AF=E6=B2=A1=E6=9C=89=E5=90=8E?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pPowerManger/httpserver/httpserver.cpp | 7 ++++--- src/pPowerManger/httpserver/httpserver.h | 8 -------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/pPowerManger/httpserver/httpserver.cpp b/src/pPowerManger/httpserver/httpserver.cpp index 8a78811..dd833ca 100644 --- a/src/pPowerManger/httpserver/httpserver.cpp +++ b/src/pPowerManger/httpserver/httpserver.cpp @@ -7,6 +7,7 @@ #include "json/json.h" #include #include "data.h" +#include "logpage.h" using json = Json::Value; @@ -67,6 +68,9 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_ } else if (mg_match(hm->uri, mg_str("/data"), NULL)) { // 返回数据页面HTML mg_http_reply(c, 200, "Content-Type: text/html; charset=utf-8\r\n", DATA_HTML.c_str()); + } else if (mg_match(hm->uri, mg_str("/logs"), NULL)) { + // 返回日志页面HTML + mg_http_reply(c, 200, "Content-Type: text/html; charset=utf-8\r\n", LOG_PAGE_HTML.c_str()); } else if (mg_match(hm->uri, mg_str("/control"), NULL)) { // 处理断路器控制请求 if (mg_strcmp(hm->method, mg_str("POST")) == 0) { @@ -170,10 +174,7 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_ success = m_lowerCommManager->operate_LVA_mergencyLithiumBatteryGroup1Circuit_Breaker(opt); } } - - const char *message = success ? "操作成功" : "操作失败"; - // 返回JSON响应 mg_http_reply(c, 200, "Content-Type: application/json\r\n", "{\"success\": %s, \"message\": \"%s\"}", diff --git a/src/pPowerManger/httpserver/httpserver.h b/src/pPowerManger/httpserver/httpserver.h index 821892c..0589c55 100644 --- a/src/pPowerManger/httpserver/httpserver.h +++ b/src/pPowerManger/httpserver/httpserver.h @@ -10,7 +10,6 @@ #include #include #include "../LowerCommManager.h" -#include "../PowerManger.h" #include #include #include @@ -86,13 +85,6 @@ private: std::deque m_logCache; // 缓存最近的日志 static const size_t MAX_CACHE_SIZE = 1000; // 最大缓存条数 - // Log monitoring - std::string m_logPath; - std::deque m_logCache; - std::mutex m_logMutex; - std::vector m_logSubscribers; - std::mutex m_subscriberMutex; - std::atomic m_lastLogSize; }; #endif // HTTP_SERVER_H \ No newline at end of file