新增: 电子相册全屏模式+开机启动+Win10兼容

This commit is contained in:
2026-05-27 01:00:39 +08:00
parent 0cd9cd40b4
commit f3148bf72f
31 changed files with 1290 additions and 490 deletions

View File

@@ -7,11 +7,9 @@ import (
"os"
"path/filepath"
"strings"
"sync"
"time"
)
const tianapiKey = "da21ff665b09cbdcc29952a105aad97b"
const tianapiStarURL = "https://apis.tianapi.com/star/index"
var zodiacToSign = map[string]string{
@@ -20,8 +18,6 @@ var zodiacToSign = map[string]string{
"射手座": "sagittarius", "摩羯座": "capricorn", "水瓶座": "aquarius", "双鱼座": "pisces",
}
var horoscopeMu sync.Mutex
type tianapiStarResp struct {
Code int `json:"code"`
Result struct {
@@ -68,17 +64,18 @@ func loadHoroscopeCache() *horoscopeInfo {
return &info
}
func isCacheToday(info *horoscopeInfo) bool {
return info != nil
}
func fetchHoroscope(zodiac string) *horoscopeInfo {
sign := zodiacToSign[zodiac]
if sign == "" {
sign = "sagittarius"
}
url := fmt.Sprintf("%s?key=%s&astro=%s", tianapiStarURL, tianapiKey, sign)
key := loadConfig().tianapiKey()
if key == "" {
log.Println("未配置天聚数行 API Key")
return nil
}
url := fmt.Sprintf("%s?key=%s&astro=%s", tianapiStarURL, key, sign)
data, err := httpGet(url)
if err != nil {
log.Println("星座运势请求失败:", err)
@@ -138,29 +135,27 @@ func pushHoroscope(zodiac string) {
func horoscopeLoop() {
cfg := loadConfig()
if cfg.HideZodiac {
return
}
cached := loadHoroscopeCache()
if cached != nil {
if cached != nil && !cfg.HideZodiac {
pushHoroscopeInfo(cached)
}
time.Sleep(5 * time.Second)
cfg = loadConfig()
if cfg.HideZodiac {
return
}
today := time.Now().Format("2006-01-02")
if cached != nil && cached.Date == today && cached.Zodiac == cfg.Zodiac {
return
if !cfg.HideZodiac && !(cached != nil && cached.Date == today && cached.Zodiac == cfg.Zodiac) {
for i := 0; i < 3; i++ {
pushHoroscope(cfg.Zodiac)
cached := loadHoroscopeCache()
if cached != nil && cached.Date == time.Now().Format("2006-01-02") && cached.Zodiac == cfg.Zodiac {
break
}
time.Sleep(30 * time.Second)
}
}
pushHoroscope(cfg.Zodiac)
ticker := time.NewTicker(24 * time.Hour)
for range ticker.C {
cfg := loadConfig()