增加了log页面,但是没有后端
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "json/json.h"
|
||||
#include <sys/resource.h>
|
||||
#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\"}",
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <fstream>
|
||||
#include <deque>
|
||||
#include "../LowerCommManager.h"
|
||||
#include "../PowerManger.h"
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
@@ -86,13 +85,6 @@ private:
|
||||
std::deque<std::string> m_logCache; // 缓存最近的日志
|
||||
static const size_t MAX_CACHE_SIZE = 1000; // 最大缓存条数
|
||||
|
||||
// Log monitoring
|
||||
std::string m_logPath;
|
||||
std::deque<std::string> m_logCache;
|
||||
std::mutex m_logMutex;
|
||||
std::vector<struct mg_connection*> m_logSubscribers;
|
||||
std::mutex m_subscriberMutex;
|
||||
std::atomic<off_t> m_lastLogSize;
|
||||
};
|
||||
|
||||
#endif // HTTP_SERVER_H
|
||||
Reference in New Issue
Block a user