docs: replace systemPreferences.isDarkMode() with nativeTheme.shouldUseDarkColors (#21480)

This commit is contained in:
liulun 2019-12-18 07:13:35 +08:00 committed by Shelley Vohr
parent f0d52eaf0c
commit cc8bf12351

View file

@ -21,12 +21,12 @@ If your app has its own dark mode you should toggle it on and off in sync with t
this by listening for the theme changed event on Electron's `systemPreferences` module. E.g. this by listening for the theme changed event on Electron's `systemPreferences` module. E.g.
```js ```js
const { systemPreferences } = require('electron') const { nativeTheme } = require('electron')
systemPreferences.subscribeNotification( systemPreferences.subscribeNotification(
'AppleInterfaceThemeChangedNotification', 'AppleInterfaceThemeChangedNotification',
function theThemeHasChanged () { function theThemeHasChanged () {
updateMyAppTheme(systemPreferences.isDarkMode()) updateMyAppTheme(nativeTheme.shouldUseDarkColors)
} }
) )
``` ```