新增: 电子相册全屏模式+开机启动+Win10兼容
This commit is contained in:
43
ainews.go
43
ainews.go
@@ -55,7 +55,12 @@ func fetchAINews() []aiNewsItem {
|
||||
}
|
||||
aiNewsMu.Unlock()
|
||||
|
||||
url := fmt.Sprintf("%s?key=%s", tianapiAIURL, tianapiKey)
|
||||
key := loadConfig().tianapiKey()
|
||||
if key == "" {
|
||||
log.Println("未配置天聚数行 API Key")
|
||||
return nil
|
||||
}
|
||||
url := fmt.Sprintf("%s?key=%s", tianapiAIURL, key)
|
||||
data, err := httpGet(url)
|
||||
if err != nil {
|
||||
log.Println("AI资讯请求失败:", err)
|
||||
@@ -124,25 +129,33 @@ func pushAINews(items []aiNewsItem) {
|
||||
|
||||
func aiNewsLoop() {
|
||||
cfg := loadConfig()
|
||||
if cfg.HideAINews {
|
||||
return
|
||||
}
|
||||
|
||||
// 先推送缓存
|
||||
if cached := loadAINewsCache(); cached != nil {
|
||||
pushAINews(cached)
|
||||
if !cfg.HideAINews {
|
||||
// 先推送缓存
|
||||
if cached := loadAINewsCache(); cached != nil {
|
||||
pushAINews(cached)
|
||||
}
|
||||
} else if cached := loadAINewsCache(); cached != nil {
|
||||
aiNewsMu.Lock()
|
||||
aiNewsCache = cached
|
||||
aiNewsCacheAt = time.Now()
|
||||
aiNewsMu.Unlock()
|
||||
}
|
||||
|
||||
time.Sleep(8 * time.Second)
|
||||
|
||||
cfg = loadConfig()
|
||||
if cfg.HideAINews {
|
||||
return
|
||||
}
|
||||
|
||||
items := fetchAINews()
|
||||
if items != nil {
|
||||
pushAINews(items)
|
||||
if !cfg.HideAINews {
|
||||
var items []aiNewsItem
|
||||
for i := 0; i < 3; i++ {
|
||||
items = fetchAINews()
|
||||
if items != nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(30 * time.Second)
|
||||
}
|
||||
if items != nil {
|
||||
pushAINews(items)
|
||||
}
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(2 * time.Hour)
|
||||
|
||||
Reference in New Issue
Block a user