1
- const { app, BrowserWindow, ipcMain, Tray, Menu, globalShortcut, dialog, shell, powerSaveBlocker, powerMonitor, Notification, nativeTheme } = require ( 'electron' )
1
+ const { app, BrowserWindow, ipcMain, Tray, Menu, globalShortcut, dialog, shell, powerSaveBlocker, powerMonitor, systemPreferences , Notification, nativeTheme } = require ( 'electron' )
2
2
const Store = require ( 'electron-store' ) ;
3
3
const store = new Store ( ) ;
4
4
const path = require ( "path" ) ;
@@ -9,7 +9,7 @@ var Registry = require('winreg')
9
9
let win , settingsWin = null , aboutWin = null , tourWin = null ;
10
10
let tray = null , contextMenu = null ;
11
11
let resetAlarm = null , powerSaveBlockerId = null ;
12
- let isTimerWin = null , isWorkMode = null ;
12
+ let isTimerWin = null , isWorkMode = null , isShadowless = null ;
13
13
let timeLeftTip = null ;
14
14
let predefinedTasks = null ;
15
15
let pushNotificationLink = null
@@ -175,8 +175,8 @@ app.on('ready', () => {
175
175
} )
176
176
177
177
globalShortcut . register ( 'CommandOrControl+Shift+L' , ( ) => {
178
- let focusWin = BrowserWindow . getFocusedWindow ( )
179
- focusWin && focusWin . toggleDevTools ( )
178
+ let focusWin = BrowserWindow . getFocusedWindow ( ) ;
179
+ focusWin && focusWin . toggleDevTools ( ) ;
180
180
} ) //toggle devtools
181
181
182
182
if ( store . get ( 'islocked' ) ) { //locked mode
@@ -282,6 +282,40 @@ app.on('ready', () => {
282
282
powerSaveBlockerId = powerSaveBlocker . start ( 'prevent-app-suspension' ) ;
283
283
if ( win != null ) win . webContents . send ( 'alter-start-stop' , 'start' )
284
284
} )
285
+
286
+ if ( process . platform == "win32" ) {
287
+ var regKey = new Registry ( {
288
+ hive : Registry . HKCU ,
289
+ key : '\\Control Panel\\Desktop\\'
290
+ } )
291
+ regKey . values ( function ( err , items ) {
292
+ if ( err )
293
+ return 'unset' ;
294
+ else {
295
+ for ( var i = 0 ; i < items . length ; i ++ ) {
296
+ if ( items [ i ] . name == 'UserPreferencesMask' ) {
297
+ if ( parseInt ( items [ i ] . value , 16 ) . toString ( 2 ) . charAt ( 21 ) == 1 && systemPreferences . isAeroGlassEnabled ( ) ) {
298
+ isShadowless = false ;
299
+ try {
300
+ store . set ( "is-shadowless" , false ) ;
301
+ }
302
+ catch ( e ) {
303
+ console . log ( e ) ;
304
+ }
305
+ } else {
306
+ isShadowless = true ;
307
+ try {
308
+ store . set ( "is-shadowless" , true ) ;
309
+ }
310
+ catch ( e ) {
311
+ console . log ( e ) ;
312
+ }
313
+ }
314
+ }
315
+ }
316
+ }
317
+ } )
318
+ } //backport when shadow disabled
285
319
} )
286
320
287
321
function notificationSolution ( title , body , func ) {
@@ -354,7 +388,7 @@ function traySolution(isFullScreen) {
354
388
} , {
355
389
label : i18n . __ ( 'website' ) ,
356
390
click : function ( ) {
357
- shell . openExternal ( 'https://wnr.scris.top /' ) ;
391
+ shell . openExternal ( 'https://getwnr.com /' ) ;
358
392
}
359
393
} , {
360
394
label : i18n . __ ( 'github' ) ,
@@ -455,7 +489,7 @@ function macOSFullscreenSolution(isFullScreen) {
455
489
} , {
456
490
label : i18n . __ ( 'website' ) ,
457
491
click : function ( ) {
458
- shell . openExternal ( 'https://wnr.scris.top /' ) ;
492
+ shell . openExternal ( 'https://getwnr.com /' ) ;
459
493
}
460
494
} , {
461
495
label : i18n . __ ( 'github' ) ,
@@ -726,17 +760,19 @@ ipcMain.on('delete-all-data', function () {
726
760
} )
727
761
728
762
function windowCloseChk ( ) {
729
- dialog . showMessageBox ( win , {
730
- title : i18n . __ ( 'window-close-dialog-box-title' ) ,
731
- type : "warning" ,
732
- message : i18n . __ ( 'window-close-dialog-box-content' ) ,
733
- checkboxLabel : i18n . __ ( 'window-close-dialog-box-chk' ) ,
734
- checkboxChecked : false
735
- } ) . then ( function ( msger ) {
736
- if ( msger . checkboxChecked ) {
737
- app . quit ( )
738
- }
739
- } )
763
+ if ( app . isPackaged )
764
+ dialog . showMessageBox ( win , {
765
+ title : i18n . __ ( 'window-close-dialog-box-title' ) ,
766
+ type : "warning" ,
767
+ message : i18n . __ ( 'window-close-dialog-box-content' ) ,
768
+ checkboxLabel : i18n . __ ( 'window-close-dialog-box-chk' ) ,
769
+ checkboxChecked : false
770
+ } ) . then ( function ( msger ) {
771
+ if ( msger . checkboxChecked ) {
772
+ app . quit ( )
773
+ }
774
+ } )
775
+ else app . quit ( )
740
776
}
741
777
ipcMain . on ( 'window-close-chk' , windowCloseChk ) ;
742
778
0 commit comments