Skip to main content

systemPreferences

Get system preferences.获取系统首选项。

Process:进程:Main

const { systemPreferences } = require('electron')
console.log(systemPreferences.isDarkMode())

Events事件

The systemPreferences object emits the following events:systemPreferences对象会发出以下事件:

Event: 'accent-color-changed' Windows

Returns:返回:

  • event Event
  • newColor string - The new RGBA color the user assigned to be their system accent color.用户指定为其系统强调色的新RGBA颜色。

Event: 'color-changed' Windows

Returns:返回:

  • event Event

Event: 'inverted-color-scheme-changed' Windows Deprecated

Returns:返回:

  • event Event
  • invertedColorScheme boolean - true if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is being used, false otherwise.如果使用倒置的配色方案(具有浅色文本和深色背景的高对比度配色方案),则为true,否则为false

Deprecated: Should use the new updated event on the nativeTheme module.应该在nativeTheme模块上使用新updated的事件。

Event: 'high-contrast-color-scheme-changed' Windows Deprecated

Returns:返回:

  • event Event
  • highContrastColorScheme boolean - true if a high contrast theme is being used, false otherwise.如果使用高对比度主题,则为true,否则为false

Deprecated: Should use the new updated event on the nativeTheme module.应该在nativeTheme模块上使用新updated的事件。

Methods方法

systemPreferences.isDarkMode() macOS Windows Deprecated

Returns返回boolean - Whether the system is in Dark Mode.系统是否处于黑暗模式。

Deprecated: Should use the new nativeTheme.shouldUseDarkColors API.应该使用新的nativeTheme.shouldUseDarkColors API。

systemPreferences.isSwipeTrackingFromScrollEventsEnabled() macOS

Returns返回boolean - Whether the Swipe between pages setting is on.是否启用“在页面之间滑动”设置。

systemPreferences.postNotification(event, userInfo[, deliverImmediately]) macOS

  • event string
  • userInfo Record<string, any>
  • deliverImmediately boolean (optional) - true to post notifications immediately even when the subscribing app is inactive.true,即使在订阅应用程序处于非活动状态时也能立即发布通知。

Posts event as native notifications of macOS. event作为macOS的本地通知发布。The userInfo is an Object that contains the user information dictionary sent along with the notification.userInfo是一个Object,它包含与通知一起发送的用户信息字典。

systemPreferences.postLocalNotification(event, userInfo) macOS

  • event string
  • userInfo Record<string, any>

Posts event as native notifications of macOS. event作为macOS的本地通知发布。The userInfo is an Object that contains the user information dictionary sent along with the notification.userInfo是一个Object,它包含与通知一起发送的用户信息字典。

systemPreferences.postWorkspaceNotification(event, userInfo) macOS

  • event string
  • userInfo Record<string, any>

Posts event as native notifications of macOS. event作为macOS的本地通知发布。The userInfo is an Object that contains the user information dictionary sent along with the notification.userInfo是一个Object,它包含与通知一起发送的用户信息字典。

systemPreferences.subscribeNotification(event, callback) macOS

  • event string | null
  • callback Function
    • event string
    • userInfo Record<string, unknown>
    • object string

Returns返回number - The ID of this subscription此订阅的ID

Subscribes to native notifications of macOS, callback will be called with callback(event, userInfo) when the corresponding event happens. 订阅macOS的本地通知,当相应的事件发生时,将以callback(event, userInfo)的形式调用callbackThe userInfo is an Object that contains the user information dictionary sent along with the notification. userInfo是一个Object,它包含与通知一起发送的用户信息字典。The object is the sender of the notification, and only supports NSString values for now.object是通知的发送方,目前仅支持NSString值。

The id of the subscriber is returned, which can be used to unsubscribe the event.返回订阅者的id,该id可用于取消订阅event

Under the hood this API subscribes to NSDistributedNotificationCenter, example values of event are:在后台,此API订阅了NSDistributedNotificationCenterevent的示例值为:

  • AppleInterfaceThemeChangedNotification
  • AppleAquaColorVariantChanged
  • AppleColorPreferencesChangedNotification
  • AppleShowScrollBarsSettingChanged

If event is null, the NSDistributedNotificationCenter doesn’t use it as criteria for delivery to the observer. 如果eventnull,则NSDistributedNotificationCenter不会将其用作传递给观察者的标准。See docs for more information.有关详细信息,请参阅文档

systemPreferences.subscribeLocalNotification(event, callback) macOS

  • event string | null
  • callback Function
    • event string
    • userInfo Record<string, unknown>
    • object string

Returns返回number - The ID of this subscription此订阅的ID

Same as subscribeNotification, but uses NSNotificationCenter for local defaults. subscribeNotification相同,但使用NSNotificationCenter进行本地默认设置。This is necessary for events such as NSUserDefaultsDidChangeNotification.这对于NSUserDefaultsDidChangeNotification等事件是必要的。

If event is null, the NSNotificationCenter doesn’t use it as criteria for delivery to the observer. 如果eventnull,则NSNotificationCenter不会将其用作传递给观察者的标准。See docs for more information.有关详细信息,请参阅文档

systemPreferences.subscribeWorkspaceNotification(event, callback) macOS

  • event string | null
  • callback Function
    • event string
    • userInfo Record<string, unknown>
    • object string

Returns返回number - The ID of this subscription此订阅的ID

Same as subscribeNotification, but uses NSWorkspace.sharedWorkspace.notificationCenter. subscribeNotification相同,但使用NSWorkspace.sharedWorkspace.notificationCenterThis is necessary for events such as NSWorkspaceDidActivateApplicationNotification.这对于NSWorkspaceDidActivateApplicationNotification等事件是必要的。

If event is null, the NSWorkspaceNotificationCenter doesn’t use it as criteria for delivery to the observer. 如果eventnull,则NSWorkspaceNotificationCenter不会将其用作传递给观察者的标准。See docs for more information.有关详细信息,请参阅文档

systemPreferences.unsubscribeNotification(id) macOS

  • id Integer

Removes the subscriber with id.使用id删除订阅者。

systemPreferences.unsubscribeLocalNotification(id) macOS

  • id Integer

Same as unsubscribeNotification, but removes the subscriber from NSNotificationCenter.unsubscribeNotification相同,但从NSNotificationCenter中删除订阅服务器。

systemPreferences.unsubscribeWorkspaceNotification(id) macOS

  • id Integer

Same as unsubscribeNotification, but removes the subscriber from NSWorkspace.sharedWorkspace.notificationCenter.unsubscribeNotification相同,但从NSWorkspace.sharedWorkspace.notificationCenter中删除订阅服务器。

systemPreferences.registerDefaults(defaults) macOS

  • defaults Record<string, string | boolean | number> - a dictionary of (key: value) user defaultskey:value形式的用户默认值的字典

Add the specified defaults to your application's NSUserDefaults.将指定的默认值添加到应用程序的NSUserDefaults中。

systemPreferences.getUserDefault<Type extends keyof UserDefaultTypes>(key, type) macOS

  • key string
  • type Type - Can be string, boolean, integer, float, double, url, array or dictionary.可以是stringbooleanintegerfloatdoubleurlarraydictionary

Returns UserDefaultTypes[Type] - The value of key in NSUserDefaults.NSUserDefaultskey的值。

Some popular key and types are:一些流行的keytype有:

  • AppleInterfaceStyle: string
  • AppleAquaColorVariant: integer
  • AppleHighlightColor: string
  • AppleShowScrollBars: string
  • NSNavRecentPlaces: array
  • NSPreferredWebServices: dictionary
  • NSUserDictionaryReplacementItems: array

systemPreferences.setUserDefault<Type extends keyof UserDefaultTypes>(key, type, value) macOS

  • key string
  • type Type - Can be string, boolean, integer, float, double, url, array or dictionary.可以是stringbooleanintegerfloatdoubleurlarraydictionary
  • value UserDefaultTypes[Type]

Set the value of key in NSUserDefaults.NSUserDefaults中设置key的值。

Note that type should match actual type of value. 请注意,type应该与value的实际类型相匹配。An exception is thrown if they don't.如果没有,则抛出异常。

Some popular key and types are:

  • ApplePressAndHoldEnabled: boolean

systemPreferences.removeUserDefault(key) macOS

  • key string

Removes the key in NSUserDefaults. 删除NSUserDefaults中的keyThis can be used to restore the default or global value of a key previously set with setUserDefault.这可用于恢复以前使用setUserDefault设置的key的默认值或全局值。

systemPreferences.isAeroGlassEnabled() Windows

Returns返回boolean - true if DWM composition (Aero Glass) is enabled, and false otherwise.如果启用了DWM合成(Aero Glass),则为true,否则为false

An example of using it to determine if you should create a transparent window or not (transparent windows won't work correctly when DWM composition is disabled):使用它来确定是否应该创建透明窗口的示例(禁用DWM合成时,透明窗口将无法正常工作):

const { BrowserWindow, systemPreferences } = require('electron')
const browserOptions = { width: 1000, height: 800 }

// Make the window transparent only if the platform supports it.
if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
browserOptions.transparent = true
browserOptions.frame = false
}

// Create the window.
const win = new BrowserWindow(browserOptions)

// Navigate.
if (browserOptions.transparent) {
win.loadURL(`file://${__dirname}/index.html`)
} else {
// No transparency, so we load a fallback that uses basic styles.
win.loadURL(`file://${__dirname}/fallback.html`)
}

systemPreferences.getAccentColor() Windows macOS

Returns返回string - The users current system wide accent color preference in RGBA hexadecimal form.用户当前系统范围内RGBA十六进制形式的重音颜色首选项。

const color = systemPreferences.getAccentColor() // `"aabbccdd"`
const red = color.substr(0, 2) // "aa"
const green = color.substr(2, 2) // "bb"
const blue = color.substr(4, 2) // "cc"
const alpha = color.substr(6, 2) // "dd"

This API is only available on macOS 10.14 Mojave or newer.此API仅在macOS 10.14 Mojave或更新版本上可用。

systemPreferences.getColor(color) Windows macOS

  • color string - One of the following values:以下值之一:
    • On Windows:
      • 3d-dark-shadow - Dark shadow for three-dimensional display elements.三维显示元素的阴影。
      • 3d-face - Face color for three-dimensional display elements and for dialog box backgrounds.三维显示元素和对话框背景的面颜色。
      • 3d-highlight - Highlight color for three-dimensional display elements.三维显示元素的高亮显示颜色。
      • 3d-light - Light color for three-dimensional display elements.三维显示元素的浅色。
      • 3d-shadow - Shadow color for three-dimensional display elements.三维显示元素的阴影颜色。
      • active-border - Active window border.活动窗口边框。
      • active-caption - Active window title bar. 活动窗口标题栏。Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled.如果启用渐变效果,则指定活动窗口标题栏的颜色渐变中的左侧颜色。
      • active-caption-gradient - Right side color in the color gradient of an active window's title bar.活动窗口标题栏的颜色渐变中的右侧颜色。
      • app-workspace - Background color of multiple document interface (MDI) applications.多文档界面(MDI)应用程序的背景色。
      • button-text - Text on push buttons.按钮上的文字。
      • caption-text - Text in caption, size box, and scroll bar arrow box.标题、大小框和滚动条箭头框中的文本。
      • desktop - Desktop background color.桌面背景颜色。
      • disabled-text - Grayed (disabled) text.灰色(禁用)文本。
      • highlight - Item(s) selected in a control.在控件中选择的项。
      • highlight-text - Text of item(s) selected in a control.控件中所选项目的文本。
      • hotlight - Color for a hyperlink or hot-tracked item.超链接或热跟踪项目的颜色。
      • inactive-border - Inactive window border.非活动窗口边框。
      • inactive-caption - Inactive window caption. 非活动窗口标题。Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled.如果启用渐变效果,则指定非活动窗口标题栏的颜色渐变中的左侧颜色。
      • inactive-caption-gradient - Right side color in the color gradient of an inactive window's title bar.非活动窗口标题栏的颜色渐变中的右侧颜色。
      • inactive-caption-text - Color of text in an inactive caption.非活动标题中文本的颜色。
      • info-background - Background color for tooltip controls.工具提示控件的背景色。
      • info-text - Text color for tooltip controls.工具提示控件的文本颜色。
      • menu - Menu background.菜单背景。
      • menu-highlight - The color used to highlight menu items when the menu appears as a flat menu.当菜单显示为平面菜单时,用于高亮显示菜单项的颜色。
      • menubar - The background color for the menu bar when menus appear as flat menus.当菜单显示为平面菜单时,菜单栏的背景色。
      • menu-text - Text in menus.菜单中的文本。
      • scrollbar - Scroll bar gray area.滚动条灰色区域。
      • window - Window background.窗口背景。
      • window-frame - Window frame.窗框。
      • window-text - Text in windows.窗口中的文本。
    • On macOS
      • alternate-selected-control-text - The text on a selected surface in a list or table. 列表或表格中选定曲面上的文本。deprecated
      • control-background - The background of a large interface element, such as a browser or table.大型界面元素(如浏览器或表格)的背景。
      • control - The surface of a control.控件的表面。
      • control-text -The text of a control that isn’t disabled.未被禁用的控件的文本。
      • disabled-control-text - The text of a control that’s disabled.被禁用的控件的文本。
      • find-highlight - The color of a find indicator.查找指示器的颜色。
      • grid - The gridlines of an interface element such as a table.界面元素(如表)的网格线。
      • header-text - The text of a header cell in a table.表中标题单元格的文本。
      • highlight - The virtual light source onscreen.屏幕上的虚拟光源。
      • keyboard-focus-indicator - The ring that appears around the currently focused control when using the keyboard for interface navigation.使用键盘进行界面导航时,出现在当前聚焦控件周围的环。
      • label - The text of a label containing primary content.包含主要内容的标签的文本。
      • link - A link to other content.指向其他内容的链接。
      • placeholder-text - A placeholder string in a control or text view.控件或文本视图中的占位符字符串。
      • quaternary-label - The text of a label of lesser importance than a tertiary label such as watermark text.与第三级标签(如水印文本)相比,重要性较低的标签的文本。
      • scrubber-textured-background - The background of a scrubber in the Touch Bar.触摸条中洗涤器的背景。
      • secondary-label - The text of a label of lesser importance than a normal label such as a label used to represent a subheading or additional information.重要性低于普通标签的标签文本,例如用于表示副标题或附加信息的标签。
      • selected-content-background - The background for selected content in a key window or view.关键窗口或视图中所选内容的背景。
      • selected-control - The surface of a selected control.选定控件的曲面。
      • selected-control-text - The text of a selected control.所选控件的文本。
      • selected-menu-item-text - The text of a selected menu.所选菜单的文本。
      • selected-text-background - The background of selected text.所选文本的背景。
      • selected-text - Selected text.所选文本。
      • separator - A separator between different sections of content.内容不同部分之间的分隔符。
      • shadow - The virtual shadow cast by a raised object onscreen.屏幕上凸起的物体投射的虚拟阴影。
      • tertiary-label - The text of a label of lesser importance than a secondary label such as a label used to represent disabled text.重要性低于次要标签的标签文本,例如用于表示禁用文本的标签。
      • text-background - Text background.文本背景。
      • text - The text in a document.文档中的文本。
      • under-page-background - The background behind a document's content.文档内容背后的背景。
      • unemphasized-selected-content-background - The selected content in a non-key window or view.在非关键窗口或视图中选择的内容。
      • unemphasized-selected-text-background - A background for selected text in a non-key window or view.非关键窗口或视图中所选文本的背景。
      • unemphasized-selected-text - Selected text in a non-key window or view.在非关键窗口或视图中选择的文本。
      • window-background - The background of a window.窗口的背景。
      • window-frame-text - The text in the window's titlebar area.窗口标题栏区域中的文本。

Returns返回string - The system color setting in RGB hexadecimal form (#ABCDEF). RGB十六进制形式的系统颜色设置(#ABCDEF)。See the Windows docs and the macOS docs for more details.有关更多详细信息,请参阅Windows文档macOS文档

The following colors are only available on macOS 10.14: find-highlight, selected-content-background, separator, unemphasized-selected-content-background, unemphasized-selected-text-background, and unemphasized-selected-text.以下颜色仅在macOS 10.14上可用:find-highlightselected-content-backgroundseparatorunemphasized-selected-content-backgroundunemphasized-selected-text-backgroundunemphasized-selected-text

systemPreferences.getSystemColor(color) macOS

  • color string - One of the following values:以下值之一:
    • blue
    • brown
    • gray
    • green
    • orange
    • pink
    • purple
    • red
    • yellow

Returns返回string - The standard system color formatted as #RRGGBBAA.标准系统颜色,格式为#RRGGBBAA

Returns one of several standard system colors that automatically adapt to vibrancy and changes in accessibility settings like 'Increase contrast' and 'Reduce transparency'. 返回几种标准系统颜色中的一种,这些颜色会自动适应活力和辅助功能设置的变化,如“增加对比度”和“降低透明度”。See Apple Documentation for more details.有关更多详细信息,请参阅Apple文档

systemPreferences.isInvertedColorScheme() Windows Deprecated

Returns返回boolean - true if an inverted color scheme (a high contrast color scheme with light text and dark backgrounds) is active, false otherwise.如果反转配色方案(具有浅色文本和深色背景的高对比度配色方案)处于活动状态,则为true,否则为false

Deprecated: Should use the new nativeTheme.shouldUseInvertedColorScheme API.应该使用新的nativeTheme.shouldUseInvertedColorScheme API。

systemPreferences.isHighContrastColorScheme() macOS Windows Deprecated

Returns返回boolean - true if a high contrast theme is active, false otherwise.如果高对比度主题处于活动状态,则为true,否则为false

Deprecated: Should use the new nativeTheme.shouldUseHighContrastColors API.应该使用新的nativeTheme.shouldUseHighContrastColors API。

systemPreferences.getEffectiveAppearance() macOS

Returns返回string - Can be dark, light or unknown.可以是darklightruknown

Gets the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance获取当前应用于应用程序的macOS外观设置,映射到NSApplication.effectiveAppearance

systemPreferences.getAppLevelAppearance() macOS Deprecated

Returns返回string | null - Can be dark, light or unknown.可以是darklightknown

Gets the macOS appearance setting that you have declared you want for your application, maps to NSApplication.appearance. 获取您为应用程序声明的macOS外观设置,映射到NSApplication.appearanceYou can use the setAppLevelAppearance API to set this value.您可以使用setAppLevelAppearance API来设置此值。

systemPreferences.setAppLevelAppearance(appearance) macOS Deprecated

  • appearance string | null - Can be dark or light可以是darklight

Sets the appearance setting for your application, this should override the system default and override the value of getEffectiveAppearance.设置应用程序的外观设置,这将覆盖系统默认值并覆盖getEffectiveAppearance的值。

systemPreferences.canPromptTouchID() macOS

Returns返回boolean - whether or not this device has the ability to use Touch ID.该设备是否具有使用Touch ID的能力。

NOTE: This API will return false on macOS systems older than Sierra 10.12.2.在Sierra 10.12.2之前的macOS系统上,此API将返回false

systemPreferences.promptTouchID(reason) macOS

  • reason string - The reason you are asking for Touch ID authentication您要求Touch ID身份验证的原因

Returns返回Promise<void> - resolves if the user has successfully authenticated with Touch ID.解决用户是否已成功使用Touch ID进行身份验证。

const { systemPreferences } = require('electron')

systemPreferences.promptTouchID('To get consent for a Security-Gated Thing').then(success => {
console.log('You have successfully authenticated with Touch ID!')
}).catch(err => {
console.log(err)
})

This API itself will not protect your user data; rather, it is a mechanism to allow you to do so. 此API本身不会保护您的用户数据;相反,它是一种允许你这样做的机制。Native apps will need to set Access Control Constants like kSecAccessControlUserPresence on their keychain entry so that reading it would auto-prompt for Touch ID biometric consent. 本地应用程序需要在其钥匙链条目上设置访问控制常量,如kSecAccessControlUserPresence,以便读取该常量时会自动提示Touch ID生物识别同意。This could be done with node-keytar, such that one would store an encryption key with node-keytar and only fetch it if promptTouchID() resolves.这可以通过node-keytar来完成,这样就可以使用node-keytar存储加密密钥,并且只有在promptTouchID()解析时才能获取它。

NOTE: This API will return a rejected Promise on macOS systems older than Sierra 10.12.2.此API将在早于Sierra 10.12.2的macOS系统上返回被拒绝的Promise。

systemPreferences.isTrustedAccessibilityClient(prompt) macOS

  • prompt boolean - whether or not the user will be informed via prompt if the current process is untrusted.如果当前进程不可信,则是否将通过提示通知用户。

Returns返回boolean - true if the current process is a trusted accessibility client and false if it is not.如果当前进程是受信任的可访问性客户端,则为true;如果不是,则为false

systemPreferences.getMediaAccessStatus(mediaType) Windows macOS

  • mediaType string - Can be microphone, camera or screen.可以是microphonecamerascreen

Returns返回string - Can be not-determined, granted, denied, restricted or unknown.可以是not-determinedgranteddeniedrestrictedunknown

This user consent was not required on macOS 10.13 High Sierra or lower so this method will always return granted. 在macOS 10.13 High Sierra或更低版本上不需要此用户同意,因此此方法将始终返回grantedmacOS 10.14 Mojave or higher requires consent for microphone and camera access. macOS 10.14 Mojave或更高版本需要获得microphonecamera访问许可。macOS 10.15 Catalina or higher requires consent for screen access.macOS 10.15 Catalina或更高版本需要获得同意才能访问screen

Windows 10 has a global setting controlling microphone and camera access for all win32 applications. Windows 10具有全局设置,用于控制所有win32应用程序的microphonecamera访问。It will always return granted for screen and for all media types on older versions of Windows.对于screen和旧版本的Windows上的所有媒体类型,它将始终返回granted

systemPreferences.askForMediaAccess(mediaType) macOS

  • mediaType string - the type of media being requested; can be microphone, camera.所请求的媒体类型;可以是microphonecamera

Returns返回Promise<boolean> - A promise that resolves with true if consent was granted and false if it was denied. 一种承诺,如果同意,则为true,如果拒绝,则为falseIf an invalid mediaType is passed, the promise will be rejected. 如果传递了无效的mediaType,则promise将被拒绝。If an access request was denied and later is changed through the System Preferences pane, a restart of the app will be required for the new permissions to take effect. 如果访问请求被拒绝,并且稍后通过“系统首选项”窗格进行更改,则需要重新启动应用程序才能使新权限生效。If access has already been requested and denied, it must be changed through the preference pane; an alert will not pop up and the promise will resolve with the existing access status.如果已经请求并拒绝访问,则必须通过首选项窗格进行更改;不会弹出警报,并且承诺将以现有访问状态解决。

Important: In order to properly leverage this API, you must set the NSMicrophoneUsageDescription and NSCameraUsageDescription strings in your app's Info.plist file. 为了正确利用此API,您必须在应用程序的Info.plist文件中设置NSMicrophoneUsageDescriptionNSCameraUsageDescription字符串。The values for these keys will be used to populate the permission dialogs so that the user will be properly informed as to the purpose of the permission request. 这些密钥的值将用于填充权限对话框,以便正确地通知用户权限请求的目的。See Electron Application Distribution for more information about how to set these in the context of Electron.有关如何在Electron上下文中设置这些应用程序的更多信息,请参阅Electron应用程序分布

This user consent was not required until macOS 10.14 Mojave, so this method will always return true if your system is running 10.13 High Sierra or lower.直到macOS 10.14 Mojave才需要此用户同意,因此如果您的系统运行10.13 High Sierra或更低版本,此方法将始终返回true

systemPreferences.getAnimationSettings()

Returns返回Object:

  • shouldRenderRichAnimation boolean - Returns true if rich animations should be rendered. 如果应该渲染丰富的动画,则返回trueLooks at session type (e.g. remote desktop) and accessibility settings to give guidance for heavy animations.查看会话类型(例如远程桌面)和辅助功能设置,为重动画提供指导。
  • scrollAnimationsEnabledBySystem boolean - Determines on a per-platform basis whether scroll animations (e.g. produced by home/end key) should be enabled.根据每个平台确定是否应启用滚动动画(例如,由主页/结束键生成)。
  • prefersReducedMotion boolean - Determines whether the user desires reduced motion based on platform APIs.确定用户是否希望基于平台API减少运动。

Returns an object with system animation settings.返回具有系统动画设置的对象。

Properties属性

systemPreferences.appLevelAppearance macOS

A string property that can be dark, light or unknown. string属性,可以是darklightknownIt determines the macOS appearance setting for your application. 它决定了应用程序的macOS外观设置。This maps to values in: NSApplication.appearance. 这将映射到:NSApplication.appearance中的值。Setting this will override the system default as well as the value of getEffectiveAppearance.设置此项将覆盖系统默认值以及getEffectiveAppearance的值。

Possible values that can be set are dark and light, and possible return values are dark, light, and unknown.可以设置的可能值为darklight,可能的返回值为darklightknown

This property is only available on macOS 10.14 Mojave or newer.此属性仅在macOS 10.14 Mojave或更新版本上可用。

systemPreferences.effectiveAppearance macOS Readonly

A string property that can be dark, light or unknown.string属性,可以是darklightknown

Returns the macOS appearance setting that is currently applied to your application, maps to 返回当前应用于应用程序的macOS外观设置,映射到NSApplication.effectiveAppearance