This commit is contained in:
tao.chen
2026-08-18 10:29:58 +08:00
parent 08bd0d0662
commit db586f6532
5 changed files with 400 additions and 226 deletions
+33
View File
@@ -0,0 +1,33 @@
package main
import (
"encoding/json"
"os"
"sync"
"time"
)
// Config 对应 config.json 结构
type Config struct {
SecretToken string `json:"secret_token"`
Projects map[string]map[string]string `json:"projects"`
DeviceKeys []string `json:"device_keys"`
}
var (
globalConfig Config
// pendingDebounceMap 防抖窗口内的待执行任务,key: "repoName:ref", value: *debounceEntry
pendingDebounceMap sync.Map
// 防抖冷却时间限制:5 分钟
debounceDuration = 5 * time.Minute
// bark 推送消息
pushURL = "https://bark.maimaicuizhiji.top/push"
)
func loadConfig(path string) error {
file, err := os.ReadFile(path)
if err != nil {
return err
}
return json.Unmarshal(file, &globalConfig)
}