feat: complete 2.0.7.12 platform overhaul

This commit is contained in:
2026-08-16 19:33:03 +08:00
parent 73555cd04c
commit c9fa6f7a88
159 changed files with 13243 additions and 2539 deletions
@@ -28,6 +28,7 @@ type Service struct {
mu sync.RWMutex
jobs map[string]CheckJob
subscribers map[chan Event]struct{}
onChange func()
}
type Event struct {
@@ -548,6 +549,7 @@ func (s *Service) CheckOne(ctx context.Context, item db.Source) error {
}
func (s *Service) CheckOneStatus(ctx context.Context, item db.Source) (string, error) {
defer s.notifyChange()
if strings.TrimSpace(item.APIURL) == "" {
return "error", errors.New("source api_url is empty")
}
@@ -657,6 +659,21 @@ func (s *Service) PublishEvent(kind string, data map[string]any) {
s.emit(kind, data)
}
func (s *Service) SetChangeCallback(callback func()) {
s.mu.Lock()
s.onChange = callback
s.mu.Unlock()
}
func (s *Service) notifyChange() {
s.mu.RLock()
callback := s.onChange
s.mu.RUnlock()
if callback != nil {
callback()
}
}
func newJobID() string {
return fmt.Sprintf("check-%d", time.Now().UnixNano())
}