app.go (768行) 拆分为 6 个文件: - app.go: App struct/辅助方法/NewApp/startup/shutdown/GetVersion - app_products.go: 商品加载/账号查询 - app_seckill.go: 抢购控制/日志/时间 - app_verify.go: 积分查询/兑换记录复验 - app_export.go: 账号导出/整理 - app_activity.go: 活动切换/配置保存 scheduler.go (1141行) 拆分为 4 个文件: - scheduler.go: struct/常量/设置/RunNow主循环/executeRound/辅助函数 - attempt.go: runAttempt/runAttemptFast/激进模式缓存 - warmup.go: 预热管理/warmupAttempts - schedule_timer.go: 定时抢购/时间校准/定时器管理 其他清理: - CollectFontCandidates 从 config 包移到 image 包(职责归属) - 删除 logger 死代码: ParseLogLine/ParseLogMeta/DetectLogLevel/ IsLogLevel/LogMeta/LogDebug/cutBracket 等反解析函数及对应测试 (日志结构化后不再有生产调用方) - 删除 static/ 空目录残留
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package image
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
)
|
|
|
|
// CollectFontCandidates 收集常见中文字体路径,允许用 DOUYU_FONT 指定自定义字体。
|
|
func CollectFontCandidates() []string {
|
|
candidates := []string{}
|
|
if custom := os.Getenv("DOUYU_FONT"); custom != "" {
|
|
candidates = append(candidates, custom)
|
|
}
|
|
candidates = append(candidates,
|
|
"Microsoft Yahei.ttf",
|
|
"Microsoft YaHei.ttf",
|
|
"NotoSansCJKsc-Regular.otf",
|
|
"NotoSansCJK-Regular.ttc",
|
|
)
|
|
|
|
switch runtime.GOOS {
|
|
case "darwin":
|
|
candidates = append(candidates,
|
|
"/System/Library/Fonts/PingFang.ttc",
|
|
"/System/Library/Fonts/Supplemental/Arial Unicode.ttf",
|
|
"/System/Library/Fonts/Supplemental/Songti.ttc",
|
|
)
|
|
case "windows":
|
|
candidates = append(candidates,
|
|
`C:\Windows\Fonts\msyh.ttc`,
|
|
`C:\Windows\Fonts\simhei.ttf`,
|
|
`C:\Windows\Fonts\simsun.ttc`,
|
|
)
|
|
default:
|
|
candidates = append(candidates,
|
|
"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
|
|
"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.otf",
|
|
"/usr/share/fonts/truetype/noto/NotoSansCJK-Regular.ttc",
|
|
"/usr/share/fonts/truetype/wqy/wqy-microhei.ttc",
|
|
"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
|
|
)
|
|
}
|
|
return candidates
|
|
}
|