@@ -114,16 +114,17 @@ exec "\${ELECTRON_BIN}" "\${extra_args[@]}" "$@"
114114 }
115115
116116 // Hide the native menu bar and fix black transparent background on Linux
117- const buildDir = path . join ( appOutDir , 'resources' , 'app' , '.vite' , 'build' ) ;
117+ let buildDir = path . join ( appOutDir , 'resources' , 'app' , '.vite' , 'build' ) ;
118118 const bootstrapPath = path . join ( buildDir , 'bootstrap.js' ) ;
119119 if ( fs . existsSync ( bootstrapPath ) ) {
120120 let content = fs . readFileSync ( bootstrapPath , 'utf8' ) ;
121- const inject = `(()=>{const {app,nativeTheme}=require("electron");app.on("browser-window-created",(e,w)=>{w.setMenuBarVisibility(false);w.autoHideMenuBar=true;const updateBg=()=>{try{w.setBackgroundColor( nativeTheme.shouldUseDarkColors?"#1c1c1e ":"#f5f5f7");} catch(err){}};updateBg();nativeTheme.on("updated",updateBg);});})();` ;
121+ const inject = `(()=>{const {app,nativeTheme}=require("electron");app.on("browser-window-created",(e,w)=>{w.setMenuBarVisibility(false);w.autoHideMenuBar=true;const updateBg=()=>{try{const bg= nativeTheme.shouldUseDarkColors?"#1e1e1e ":"#ffffff";w.setBackgroundColor(bg);w.webContents.insertCSS(\`* { backdrop-filter: none !important; } aside, nav, [class*="sidebar"] { background-color: \${bg} !important; }\`);} catch(err){}};w.webContents.on("dom-ready",updateBg) ;updateBg();nativeTheme.on("updated",updateBg);});})();` ;
122122 if ( ! content . includes ( 'setMenuBarVisibility' ) ) {
123123 content = content . replace ( 'require("electron");' , `require("electron");${ inject } ` ) ;
124124 fs . writeFileSync ( bootstrapPath , content ) ;
125- } else if ( content . includes ( 'w.setMenuBarVisibility(false);w.autoHideMenuBar=true;});' ) ) {
126- content = content . replace ( 'require("electron").app.on("browser-window-created",(e,w)=>{w.setMenuBarVisibility(false);w.autoHideMenuBar=true;});' , inject ) ;
125+ } else if ( content . includes ( 'const updateBg=()=>{try{w.setBackgroundColor' ) ) {
126+ // Replace the previous injection with the new one
127+ content = content . replace ( / \( \( \) = > \{ c o n s t \{ a p p , n a t i v e T h e m e \} = r e q u i r e \( " e l e c t r o n " \) ; a p p \. o n \( " b r o w s e r - w i n d o w - c r e a t e d " , \( e , w \) = > \{ w \. s e t M e n u B a r V i s i b i l i t y \( f a l s e \) ; w \. a u t o H i d e M e n u B a r = t r u e ; c o n s t u p d a t e B g = \( \) = > \{ t r y \{ w \. s e t B a c k g r o u n d C o l o r .* ?\} \) \( \) ; / g, inject ) ;
127128 fs . writeFileSync ( bootstrapPath , content ) ;
128129 }
129130 }
0 commit comments