@@ -935,6 +935,22 @@ const theIcon =
935935 ? join ( runPath , "assets/logo/icon.ico" )
936936 : join ( runPath , "assets/logo/1024x1024.png" ) ;
937937
938+ const baseWinConfig : ( ) => Electron . BrowserWindowConstructorOptions = ( ) => {
939+ const bg = nativeTheme . shouldUseDarkColors
940+ ? store . get ( "全局.主题.dark.bg" )
941+ : store . get ( "全局.主题.light.bg" ) ;
942+ return {
943+ icon : theIcon ,
944+ autoHideMenuBar : true ,
945+ backgroundColor : bg ,
946+ webPreferences : {
947+ nodeIntegration : true ,
948+ contextIsolation : false ,
949+ sandbox : false ,
950+ } ,
951+ } ;
952+ } ;
953+
938954mainOn ( "dialogMessage" , ( [ arg0 ] ) => {
939955 const id = dialog . showMessageBoxSync ( arg0 ) ;
940956 return id ;
@@ -1223,15 +1239,7 @@ function createRecorderWindow(
12231239 y = Math . min ( y , sy1 - h ) ;
12241240 x = Math . round ( x ) ;
12251241 y = Math . round ( y ) ;
1226- const recorder = new BrowserWindow ( {
1227- icon : theIcon ,
1228- autoHideMenuBar : true ,
1229- webPreferences : {
1230- nodeIntegration : true ,
1231- contextIsolation : false ,
1232- sandbox : false ,
1233- } ,
1234- } ) ;
1242+ const recorder = new BrowserWindow ( baseWinConfig ( ) ) ;
12351243 _recorder = recorder ;
12361244 rendererPath ( recorder , "recorder.html" ) ;
12371245 if ( dev ) recorder . webContents . openDevTools ( ) ;
@@ -1365,14 +1373,7 @@ mainOn("recordSavePath", ([ext]) => {
13651373} ) ;
13661374
13671375function createSuperRecorderWindow ( ) {
1368- const recorder = new BrowserWindow ( {
1369- icon : theIcon ,
1370- webPreferences : {
1371- nodeIntegration : true ,
1372- contextIsolation : false ,
1373- sandbox : false ,
1374- } ,
1375- } ) ;
1376+ const recorder = new BrowserWindow ( baseWinConfig ( ) ) ;
13761377 recorder . minimize ( ) ;
13771378 rendererPath ( recorder , "videoEditor.html" ) ;
13781379 if ( dev ) recorder . webContents . openDevTools ( ) ;
@@ -1731,13 +1732,7 @@ function createTranslator(op: Omit<translateWinType, "type">) {
17311732}
17321733
17331734function createPhotoEditor ( img : string ) {
1734- const win = new BrowserWindow ( {
1735- webPreferences : {
1736- nodeIntegration : true ,
1737- contextIsolation : false ,
1738- } ,
1739- autoHideMenuBar : true ,
1740- } ) ;
1735+ const win = new BrowserWindow ( baseWinConfig ( ) ) ;
17411736
17421737 rendererPath ( win , "photoEditor.html" ) ;
17431738 if ( dev ) win . webContents . openDevTools ( ) ;
@@ -1786,8 +1781,7 @@ async function createMainWindow(op: MainWinType) {
17861781 width : w ,
17871782 height : h ,
17881783 minWidth : 400 ,
1789- backgroundColor : bg ,
1790- icon : theIcon ,
1784+ ...baseWinConfig ( ) ,
17911785 titleBarStyle : "hidden" ,
17921786 titleBarOverlay : {
17931787 color : bg ,
@@ -1796,12 +1790,6 @@ async function createMainWindow(op: MainWinType) {
17961790 : store . get ( "全局.主题.light.fontColor" ) ,
17971791 height : 32 ,
17981792 } ,
1799- webPreferences : {
1800- nodeIntegration : true ,
1801- contextIsolation : false ,
1802- webSecurity : false ,
1803- } ,
1804- show : true ,
18051793 } ) ;
18061794 mainWindowL [ windowName ] = {
18071795 browser : { top : 0 , bottom : 48 } ,
@@ -1863,17 +1851,7 @@ async function createMainWindow(op: MainWinType) {
18631851async function createSettingWindow ( ) {
18641852 const settingWindow = new BrowserWindow ( {
18651853 minWidth : 600 ,
1866- backgroundColor : nativeTheme . shouldUseDarkColors
1867- ? store . get ( "全局.主题.dark.bg" )
1868- : store . get ( "全局.主题.light.bg" ) ,
1869- icon : theIcon ,
1870- webPreferences : {
1871- nodeIntegration : true ,
1872- contextIsolation : false ,
1873- webSecurity : false ,
1874- } ,
1875- show : true ,
1876- autoHideMenuBar : true ,
1854+ ...baseWinConfig ( ) ,
18771855 } ) ;
18781856
18791857 rendererPath ( settingWindow , "setting.html" ) ;
0 commit comments