@@ -114,17 +114,17 @@ exec "\${ELECTRON_BIN}" "\${extra_args[@]}" "$@"
114114 }
115115
116116 // Hide the native menu bar and fix black transparent background on Linux
117- let buildDir = path . join ( appOutDir , 'resources' , 'app' , '.vite' , 'build' ) ;
117+ const 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 {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 );});})();` ;
121+ const inject = `(()=>{const {app}=require("electron");app.on("browser-window-created",(e,w)=>{w.setMenuBarVisibility(false);w.autoHideMenuBar=true;w.webContents.on("dom-ready",( )=>{w.webContents.executeJavaScript(\`(function() {const style=document.createElement('style');document.head.appendChild(style);function updateColors(){const bg=window.getComputedStyle(document.body).backgroundColor;const rgb=bg.match(/\\\d+/g);if(rgb&&rgb.length>=3){const isDark=(rgb[0]*0.299+rgb[1]*0.587+rgb[2]*0.114)<128;const sidebarBg=isDark?'#1e1e1e':'#f5f5f7';style.textContent='* { backdrop-filter: none !important; } aside, nav, [class*="sidebar"], [class*="Sidebar"] { background-color: '+sidebarBg+' !important; }';}}updateColors();setInterval(updateColors, 1000);}) ();\`).catch(()=>{});} );});})();` ;
122122 if ( ! content . includes ( 'setMenuBarVisibility' ) ) {
123123 content = content . replace ( 'require("electron");' , `require("electron");${ inject } ` ) ;
124124 fs . writeFileSync ( bootstrapPath , content ) ;
125- } else if ( content . includes ( 'const updateBg=()=>{try{w.setBackgroundColor ' ) ) {
125+ } else if ( content . includes ( 'const updateBg=()=>{try{' ) ) {
126126 // 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 ) ;
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 \{ .* ?\} \) \( \) ; / g, inject ) ;
128128 fs . writeFileSync ( bootstrapPath , content ) ;
129129 }
130130 }
0 commit comments