File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { join, normalize } from 'path';
14
14
import { format } from 'url' ;
15
15
import { IPC } from './ipc-events.const' ;
16
16
import { getSettings } from './get-settings' ;
17
+ import { readFileSync , stat } from 'fs' ;
17
18
18
19
let mainWin : BrowserWindow ;
19
20
@@ -96,7 +97,19 @@ export const createWindow = ({
96
97
slashes : true ,
97
98
} ) ;
98
99
99
- mainWin . loadURL ( url ) ;
100
+ mainWin . loadURL ( url ) . then ( ( ) => {
101
+ // load custom stylesheet if any
102
+ const CSS_FILE_PATH = app . getPath ( 'userData' ) + '/styles.css' ;
103
+ stat ( app . getPath ( 'userData' ) + '/styles.css' , ( err ) => {
104
+ if ( err ) {
105
+ console . log ( 'No custom styles detected at ' + CSS_FILE_PATH ) ;
106
+ } else {
107
+ console . log ( 'Loading custom styles from ' + CSS_FILE_PATH ) ;
108
+ const styles = readFileSync ( CSS_FILE_PATH , { encoding : 'utf8' } ) ;
109
+ mainWin . webContents . insertCSS ( styles ) . then ( console . log ) . catch ( console . error ) ;
110
+ }
111
+ } ) ;
112
+ } ) ;
100
113
101
114
// show gracefully
102
115
mainWin . once ( 'ready-to-show' , ( ) => {
You can’t perform that action at this time.
0 commit comments