feat: Add batch processing and upload functionality, including new backend APIs, logging system, SQLite database, and dedicated frontend pages.
This commit is contained in:
@@ -102,7 +102,8 @@ func startServer(cfg *config.Config) {
|
||||
// 日志 API
|
||||
mux.HandleFunc("/api/logs", api.CORS(handleGetLogs))
|
||||
mux.HandleFunc("/api/logs/clear", api.CORS(handleClearLogs))
|
||||
mux.HandleFunc("/api/logs/stream", handleLogStream) // SSE 实时日志
|
||||
mux.HandleFunc("/api/logs/query", api.CORS(handleQueryLogs)) // 按模块查询日志
|
||||
mux.HandleFunc("/api/logs/stream", handleLogStream) // SSE 实时日志
|
||||
|
||||
// S2A 代理 API
|
||||
mux.HandleFunc("/api/s2a/test", api.CORS(handleS2ATest))
|
||||
@@ -137,6 +138,10 @@ func startServer(cfg *config.Config) {
|
||||
mux.HandleFunc("/api/team/status", api.CORS(api.HandleTeamProcessStatus))
|
||||
mux.HandleFunc("/api/team/stop", api.CORS(api.HandleTeamProcessStop))
|
||||
|
||||
// 批次历史 API(分页 + 详情)
|
||||
mux.HandleFunc("/api/batch/history", api.CORS(api.HandleBatchHistory))
|
||||
mux.HandleFunc("/api/batch/detail", api.CORS(api.HandleBatchDetail))
|
||||
|
||||
// 批次记录 API
|
||||
mux.HandleFunc("/api/batch/runs", api.CORS(handleBatchRuns))
|
||||
mux.HandleFunc("/api/batch/stats", api.CORS(handleBatchStats))
|
||||
@@ -282,6 +287,39 @@ func handleClearLogs(w http.ResponseWriter, r *http.Request) {
|
||||
api.Success(w, map[string]string{"message": "日志已清空"})
|
||||
}
|
||||
|
||||
// handleQueryLogs GET /api/logs/query?module=cleaner&page=1&page_size=5
|
||||
func handleQueryLogs(w http.ResponseWriter, r *http.Request) {
|
||||
module := r.URL.Query().Get("module")
|
||||
if module == "" {
|
||||
api.Error(w, http.StatusBadRequest, "缺少 module 参数")
|
||||
return
|
||||
}
|
||||
|
||||
page := 1
|
||||
pageSize := 5
|
||||
if v := r.URL.Query().Get("page"); v != "" {
|
||||
if p, err := strconv.Atoi(v); err == nil && p > 0 {
|
||||
page = p
|
||||
}
|
||||
}
|
||||
if v := r.URL.Query().Get("page_size"); v != "" {
|
||||
if ps, err := strconv.Atoi(v); err == nil && ps > 0 && ps <= 100 {
|
||||
pageSize = ps
|
||||
}
|
||||
}
|
||||
|
||||
entries, total := logger.GetLogsByModule(module, page, pageSize)
|
||||
totalPages := (total + pageSize - 1) / pageSize
|
||||
|
||||
api.Success(w, map[string]interface{}{
|
||||
"logs": entries,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"page_size": pageSize,
|
||||
"total_pages": totalPages,
|
||||
})
|
||||
}
|
||||
|
||||
// handleBatchRuns 获取批次运行记录
|
||||
func handleBatchRuns(w http.ResponseWriter, r *http.Request) {
|
||||
if database.Instance == nil {
|
||||
|
||||
Reference in New Issue
Block a user