Files
MyGoNavi/internal/nativewindow/window_visual.go
Syngnat 67981575a9 🐛 fix(nativewindow): 同步独立窗口主题与透明背景
- 同步主窗口解析后的自定义主题上下文,覆盖独立窗口主题变量和 Ant Design 令牌\n- 使用主题背景绘制 detached WebView,避免透明区域回退为白色\n- 按 macOS、Windows 和 Linux 配置原生窗口透明参数\n- 补充主题通信、覆盖层主题和原生窗口视觉选项回归测试
2026-08-03 15:27:30 +08:00

52 lines
1.5 KiB
Go

package nativewindow
import (
"strings"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
type detachedWindowVisualOptions struct {
backgroundColour *options.RGBA
windows *windows.Options
mac *mac.Options
linux *linux.Options
}
// Detached windows render their actual surface in the WebView. Keeping the
// native surface transparent prevents a stale white Wails background from
// showing through while a custom theme is being applied or around transparent
// WebView pixels.
func resolveDetachedWindowVisualOptions(goos string) detachedWindowVisualOptions {
if strings.EqualFold(strings.TrimSpace(goos), "windows") {
return detachedWindowVisualOptions{
backgroundColour: &options.RGBA{A: 0},
windows: &windows.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: true,
},
}
}
if strings.EqualFold(strings.TrimSpace(goos), "darwin") {
return detachedWindowVisualOptions{
backgroundColour: &options.RGBA{A: 0},
mac: &mac.Options{
WebviewIsTransparent: true,
WindowIsTranslucent: true,
},
}
}
if strings.EqualFold(strings.TrimSpace(goos), "linux") {
return detachedWindowVisualOptions{
backgroundColour: &options.RGBA{A: 0},
linux: &linux.Options{WindowIsTranslucent: true},
}
}
return detachedWindowVisualOptions{
backgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
}
}