新增: Bing壁纸历史导航+极光流体主题+重启菜单

This commit is contained in:
2026-05-25 22:44:21 +08:00
parent bb1574641f
commit d4bce23d19
7 changed files with 601 additions and 72 deletions

View File

@@ -26,11 +26,19 @@ var themeGradient string
//go:embed web/themes/particles.html
var themeParticles string
//go:embed web/themes/fractal.html
var themeFractal string
//go:embed web/themes/text.html
var themeText string
var themeMap = map[ThemeName]string{
ThemeAurora: themeAurora,
ThemeStar: themeStarfield,
ThemeGradient: themeGradient,
ThemeParticle: themeParticles,
ThemeFractal: themeFractal,
ThemeText: themeText,
}
func buildWallpaperHTML(cfg *Config) string {
@@ -51,11 +59,12 @@ func buildWallpaperHTML(cfg *Config) string {
}
}
case WPBing:
bingPath := filepath.Join(configDir(), "bing_wallpaper.jpg")
if _, err := os.Stat(bingPath); err == nil {
src := imageToDataURI(bingPath)
if src != "" {
bg = fmt.Sprintf(`<img src="%s" style="position:fixed;top:0;left:0;width:100%%;height:100%%;object-fit:cover;z-index:1;">`, src)
if p := getCurrentBingPath(); p != "" {
if _, err := os.Stat(p); err == nil {
src := imageToDataURI(p)
if src != "" {
bg = fmt.Sprintf(`<img src="%s" style="position:fixed;top:0;left:0;width:100%%;height:100%%;object-fit:cover;z-index:1;">`, src)
}
}
}
case WPColor:
@@ -69,7 +78,16 @@ func buildWallpaperHTML(cfg *Config) string {
if bg == "" {
bg = themeAurora
}
return strings.Replace(overlayHTML, "{{BACKGROUND}}", bg, 1)
html := strings.Replace(overlayHTML, "{{BACKGROUND}}", bg, 1)
// 注入自定义文字
if cfg.WallpaperType == WPTheme && cfg.Theme == ThemeText && cfg.WallpaperText != "" {
escaped := strings.ReplaceAll(cfg.WallpaperText, `\`, `\\`)
escaped = strings.ReplaceAll(escaped, `"`, `\"`)
html = strings.Replace(html, "</script>", `window.wallpaperText = "`+escaped+`";</script>`, 1)
}
return html
}
func imageToDataURI(path string) string {
@@ -107,6 +125,9 @@ func reloadWallpaper() {
go func() {
time.Sleep(1 * time.Second)
evalJS(fmt.Sprintf(`window.userZodiac = %q;`, cfg.Zodiac))
if cfg.Theme == ThemeText && cfg.WallpaperText != "" {
evalJS(fmt.Sprintf(`window.wallpaperText = %q; var el=document.getElementById("wallpaper-text"); if(el){el.textContent=%q;}`, cfg.WallpaperText, cfg.WallpaperText))
}
city := getCurrentCity()
go fetchAndPushWeather(city)
}()