feat: Implement ChatGPT account registration flow and establish core backend API infrastructure with logging utilities.

This commit is contained in:
2026-02-03 03:22:43 +08:00
parent b014226074
commit cf25845a0b
8 changed files with 36 additions and 14 deletions

View File

@@ -25,6 +25,20 @@ var (
listMu sync.RWMutex
)
// 旋转动画字符
var spinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
var spinnerIndex int
var spinnerMu sync.Mutex
// getSpinnerChar 获取下一个旋转字符
func getSpinnerChar() string {
spinnerMu.Lock()
defer spinnerMu.Unlock()
char := spinnerFrames[spinnerIndex%len(spinnerFrames)]
spinnerIndex++
return char
}
// AddListener 添加日志监听器
func AddListener(id string) chan LogEntry {
listMu.Lock()
@@ -130,6 +144,10 @@ func log(level, message, email, module string) {
case "warning":
prefix = "WARN "
color = colorYellow
case "status":
// 状态日志使用旋转动画字符
prefix = getSpinnerChar() + " WAIT "
color = colorCyan
}
// 模块名固定宽度8字符
@@ -184,6 +202,11 @@ func Warning(message, email, module string) {
log("warning", message, email, module)
}
// Status 记录状态日志(带旋转动画字符,用于等待中的操作)
func Status(message, email, module string) {
log("status", message, email, module)
}
// GetLogs 获取日志
func GetLogs(limit int) []LogEntry {
logsMu.RLock()