新增: 音频可视化壁纸主题(WASAPI+FFT+Canvas)
This commit is contained in:
23
wallpaper.go
23
wallpaper.go
@@ -33,6 +33,9 @@ var themeFractal string
|
||||
//go:embed web/themes/text.html
|
||||
var themeText string
|
||||
|
||||
//go:embed web/themes/audio-viz.html
|
||||
var themeAudioViz string
|
||||
|
||||
var themeMap = map[ThemeName]string{
|
||||
ThemeAurora: themeAurora,
|
||||
ThemeStar: themeStarfield,
|
||||
@@ -40,6 +43,7 @@ var themeMap = map[ThemeName]string{
|
||||
ThemeParticle: themeParticles,
|
||||
ThemeFractal: themeFractal,
|
||||
ThemeText: themeText,
|
||||
ThemeAudioViz: themeAudioViz,
|
||||
}
|
||||
|
||||
func buildWallpaperHTML(cfg *Config) string {
|
||||
@@ -88,6 +92,14 @@ func buildWallpaperHTML(cfg *Config) string {
|
||||
inject += fmt.Sprintf(`<script>window.wallpaperText=%s;</script>`, string(escaped))
|
||||
}
|
||||
|
||||
// 注入音频可视化配置
|
||||
if cfg.WallpaperType == WPTheme && cfg.Theme == ThemeAudioViz {
|
||||
inject += fmt.Sprintf(
|
||||
`<script>window.__audioVizStyle=%q;window.__audioVizSensitivity=%f;window.__audioVizColors=%q;</script>`,
|
||||
cfg.AudioVizStyle, cfg.AudioSensitivity, cfg.AudioColorScheme,
|
||||
)
|
||||
}
|
||||
|
||||
return strings.Replace(overlayHTML, "</head>", inject+"</head>", 1)
|
||||
}
|
||||
|
||||
@@ -118,6 +130,17 @@ func reloadWallpaper() {
|
||||
}
|
||||
cfg := loadConfig()
|
||||
|
||||
// 音频捕获生命周期
|
||||
if cfg.WallpaperType == WPTheme && cfg.Theme == ThemeAudioViz {
|
||||
if !audioActiveState() {
|
||||
startAudioCapture()
|
||||
}
|
||||
} else {
|
||||
if audioActiveState() {
|
||||
stopAudioCapture()
|
||||
}
|
||||
}
|
||||
|
||||
// 非主题壁纸切换:仅替换 #bg-layer,不销毁卡片状态
|
||||
if cfg.WallpaperType != WPTheme {
|
||||
updateBackground(cfg)
|
||||
|
||||
Reference in New Issue
Block a user