@@ -17,7 +17,6 @@ import { getElemAsStr } from "@/util/focusutil";
1717import * as keyutil from "@/util/keyutil" ;
1818import * as util from "@/util/util" ;
1919import clsx from "clsx" ;
20- import Color from "color" ;
2120import debug from "debug" ;
2221import { Provider , useAtomValue } from "jotai" ;
2322import "overlayscrollbars/overlayscrollbars.css" ;
@@ -130,21 +129,24 @@ function AppSettingsUpdater() {
130129 const isTransparentOrBlur =
131130 ( windowSettings ?. [ "window:transparent" ] || windowSettings ?. [ "window:blur" ] ) ?? false ;
132131 const opacity = util . boundNumber ( windowSettings ?. [ "window:opacity" ] ?? 0.8 , 0 , 1 ) ;
133- let baseBgColor = windowSettings ?. [ "window:bgcolor" ] ;
132+ const baseBgColor = windowSettings ?. [ "window:bgcolor" ] ;
134133 const mainDiv = document . getElementById ( "main" ) ;
135134 // console.log("window settings", windowSettings, isTransparentOrBlur, opacity, baseBgColor, mainDiv);
136135 if ( isTransparentOrBlur ) {
137136 mainDiv . classList . add ( "is-transparent" ) ;
138- const rootStyles = getComputedStyle ( document . documentElement ) ;
139- if ( baseBgColor == null ) {
140- baseBgColor = rootStyles . getPropertyValue ( "--main-bg-color" ) . trim ( ) ;
137+ if ( opacity != null ) {
138+ document . body . style . setProperty ( "--window-opacity" , `${ opacity } ` ) ;
139+ } else {
140+ document . body . style . removeProperty ( "--window-opacity" ) ;
141141 }
142- const color = new Color ( baseBgColor ) ;
143- const rgbaColor = color . alpha ( opacity ) . string ( ) ;
144- document . body . style . backgroundColor = rgbaColor ;
145142 } else {
146143 mainDiv . classList . remove ( "is-transparent" ) ;
147- document . body . style . backgroundColor = "var(--main-bg-color)" ;
144+ document . body . style . removeProperty ( "--window-opacity" ) ;
145+ }
146+ if ( baseBgColor != null ) {
147+ document . body . style . setProperty ( "--main-bg-color" , baseBgColor ) ;
148+ } else {
149+ document . body . style . removeProperty ( "--main-bg-color" ) ;
148150 }
149151 } , [ windowSettings ] ) ;
150152 return null ;
0 commit comments