- 将硬编码的API配置移到config模块,支持环境变量配置 - 添加API Key验证和配置检查 - 添加图片上传大小限制(10MB) - 移除不必要的注释,简化代码 - 改进错误处理和日志记录
28 lines
691 B
Go
28 lines
691 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
// 配置变量
|
|
var (
|
|
BaseURL = getEnv("JWTS_BASE_URL", "http://jwts.hitwh.edu.cn")
|
|
Username = getEnv("JWTS_USERNAME", "")
|
|
Password = getEnv("JWTS_PASSWORD", "")
|
|
Semester = getEnv("JWTS_SEMESTER", "2025-20262")
|
|
TWFID = getEnv("JWTS_TWFID", "")
|
|
|
|
RecognizerAPIURL = getEnv("RECOGNIZER_API_URL", "https://api.littlelan.cn/v1/chat/completions")
|
|
RecognizerAPIKey = getEnv("RECOGNIZER_API_KEY", "")
|
|
RecognizerModel = getEnv("RECOGNIZER_MODEL", "qwen3.5-plus")
|
|
)
|
|
|
|
// getEnv 从环境变量获取配置,提供默认值
|
|
func getEnv(key, defaultValue string) string {
|
|
value := os.Getenv(key)
|
|
if value == "" {
|
|
return defaultValue
|
|
}
|
|
return value
|
|
}
|