新增: 电子相册全屏模式+开机启动+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

65
bing.go
View File

@@ -213,25 +213,14 @@ func bingToggleFavorite() string {
r := &h.Records[h.CurrentIdx]
r.Favorited = !r.Favorited
saveBingHistory(h)
state := "收藏"
if r.Favorited {
state = "取消收藏"
}
log.Printf("Bing 壁纸: %s (date=%s)", state, r.Date)
if r.Favorited {
log.Printf("Bing 壁纸: 已收藏 (date=%s)", r.Date)
return "☆ 取消收藏"
}
log.Printf("Bing 壁纸: 已取消收藏 (date=%s)", r.Date)
return "★ 收藏当前壁纸"
}
func bingCopyrightInfo() string {
r := getCurrentBingRecord()
if r != nil {
return fmt.Sprintf("%s (%s)", r.Copyright, r.Date)
}
return ""
}
func bingCurrentState() string {
h := loadBingHistory()
if h.CurrentIdx < 0 || h.CurrentIdx >= len(h.Records) {
@@ -305,30 +294,34 @@ func bingWallpaperLoop() {
}
// 定时切换壁纸 (1 小时间隔)
ticker := time.NewTicker(1 * time.Hour)
for range ticker.C {
cfg := loadConfig()
if cfg.WallpaperType != WPBing || !cfg.BingAutoRefresh {
continue
go func() {
ticker := time.NewTicker(1 * time.Hour)
for range ticker.C {
cfg := loadConfig()
if cfg.WallpaperType != WPBing || !cfg.BingAutoRefresh {
continue
}
bingMu.Lock()
h := loadBingHistory()
if len(h.Records) <= 1 {
bingMu.Unlock()
continue
}
h.CurrentIdx = (h.CurrentIdx + 1) % len(h.Records)
saveBingHistory(h)
bingMu.Unlock()
bingReloadImage()
log.Printf("Bing 自动切换: idx=%d/%d", h.CurrentIdx, len(h.Records))
}
h := loadBingHistory()
if len(h.Records) <= 1 {
continue
}
// 顺序切换到下一张
nextIdx := (h.CurrentIdx + 1) % len(h.Records)
h.CurrentIdx = nextIdx
saveBingHistory(h)
bingReloadImage()
log.Printf("Bing 自动切换: idx=%d/%d", nextIdx, len(h.Records))
}
}()
// 定时拉取新壁纸 (4 小时间隔)
fetchTicker := time.NewTicker(4 * time.Hour)
for range fetchTicker.C {
cfg := loadConfig()
if cfg.WallpaperType == WPBing {
go fetchBingHistory()
go func() {
fetchTicker := time.NewTicker(4 * time.Hour)
for range fetchTicker.C {
cfg := loadConfig()
if cfg.WallpaperType == WPBing {
go fetchBingHistory()
}
}
}
}()
}