feat: Add a new cleaner page for managing and automatically cleaning error S2A accounts, supported by new backend services for logging, authentication, and client operations.

This commit is contained in:
2026-02-02 03:27:33 +08:00
parent d05c19a8d5
commit daf4c68e4f
10 changed files with 704 additions and 506 deletions

View File

@@ -243,6 +243,43 @@ func ClearLogs() {
logs = make([]LogEntry, 0, 1000)
}
// GetLogsByModuleAndLevel 按模块和级别筛选日志并分页(最新的在前)
func GetLogsByModuleAndLevel(module, level string, page, pageSize int) ([]LogEntry, int) {
logsMu.RLock()
defer logsMu.RUnlock()
// 倒序收集匹配的日志
var filtered []LogEntry
for i := len(logs) - 1; i >= 0; i-- {
if logs[i].Module == module {
// 如果指定了级别,则进行过滤
if level != "" && logs[i].Level != level {
continue
}
filtered = append(filtered, logs[i])
}
}
total := len(filtered)
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 5
}
start := (page - 1) * pageSize
if start >= total {
return []LogEntry{}, total
}
end := start + pageSize
if end > total {
end = total
}
return filtered[start:end], total
}
// ClearLogsByModule 按模块清除日志
func ClearLogsByModule(module string) int {
logsMu.Lock()