systemPreferences
获取系统偏好设置。
¥Get system preferences.
const { systemPreferences } = require('electron')
console.log(systemPreferences.isAeroGlassEnabled())
事件
¥Events
systemPreferences
对象发出以下事件:
¥The systemPreferences
object emits the following events:
事件:'accent-color-changed' Windows
¥Event: 'accent-color-changed' Windows
返回:
¥Returns:
-
event
事件¥
event
Event -
newColor
字符串 - 用户指定为其系统强调色的新 RGBA 颜色。¥
newColor
string - The new RGBA color the user assigned to be their system accent color.
事件:'color-changed' Windows
¥Event: 'color-changed' Windows
返回:
¥Returns:
-
event
事件¥
event
Event
方法
¥Methods
systemPreferences.isSwipeTrackingFromScrollEventsEnabled()
macOS
返回 boolean
- 页面之间滑动设置是否打开。
¥Returns boolean
- Whether the Swipe between pages setting is on.
systemPreferences.postNotification(event, userInfo[, deliverImmediately])
macOS
-
event
字符串¥
event
string -
userInfo
记录<字符串,任意>¥
userInfo
Record<string, any> -
deliverImmediately
布尔值(可选) -true
即使订阅应用处于非活动状态,也会立即发布通知。¥
deliverImmediately
boolean (optional) -true
to post notifications immediately even when the subscribing app is inactive.
将 event
作为 macOS 的原生通知发布。userInfo
是一个对象,包含与通知一起发送的用户信息字典。
¥Posts event
as native notifications of macOS. The userInfo
is an Object
that contains the user information dictionary sent along with the notification.
systemPreferences.postLocalNotification(event, userInfo)
macOS
-
event
字符串¥
event
string -
userInfo
记录<字符串,任意>¥
userInfo
Record<string, any>
将 event
作为 macOS 的原生通知发布。userInfo
是一个对象,包含与通知一起发送的用户信息字典。
¥Posts event
as native notifications of macOS. The userInfo
is an Object
that contains the user information dictionary sent along with the notification.
systemPreferences.postWorkspaceNotification(event, userInfo)
macOS
-
event
字符串¥
event
string -
userInfo
记录<字符串,任意>¥
userInfo
Record<string, any>
将 event
作为 macOS 的原生通知发布。userInfo
是一个对象,包含与通知一起发送的用户信息字典。
¥Posts event
as native notifications of macOS. The userInfo
is an Object
that contains the user information dictionary sent along with the notification.
systemPreferences.subscribeNotification(event, callback)
macOS
-
event
字符串 | 无效的¥
event
string | null -
callback
函数¥
callback
Function-
event
字符串¥
event
string -
userInfo
记录<字符串,未知>¥
userInfo
Record<string, unknown> -
object
字符串¥
object
string
-
返回 number
- 本次订阅的 ID
¥Returns number
- The ID of this subscription
订阅 macOS 原生通知,当对应的 event
发生时,callback
会和 callback(event, userInfo)
一起调用。userInfo
是一个对象,包含与通知一起发送的用户信息字典。object
是通知的发送者,目前仅支持 NSString
值。
¥Subscribes to native notifications of macOS, callback
will be called with
callback(event, userInfo)
when the corresponding event
happens. The
userInfo
is an Object that contains the user information dictionary sent
along with the notification. The object
is the sender of the notification,
and only supports NSString
values for now.
返回订阅者的 id
,可用于取消订阅 event
。
¥The id
of the subscriber is returned, which can be used to unsubscribe the
event
.
在底层,该 API 订阅了 NSDistributedNotificationCenter
,event
的示例值为:
¥Under the hood this API subscribes to NSDistributedNotificationCenter
,
example values of event
are:
-
AppleInterfaceThemeChangedNotification
-
AppleAquaColorVariantChanged
-
AppleColorPreferencesChangedNotification
-
AppleShowScrollBarsSettingChanged
如果 event
为 null,则 NSDistributedNotificationCenter
不会将其用作传递给观察者的标准。请参阅 docs 了解更多信息。
¥If event
is null, the NSDistributedNotificationCenter
doesn’t use it as criteria for delivery to the observer. See docs for more information.
systemPreferences.subscribeLocalNotification(event, callback)
macOS
-
event
字符串 | 无效的¥
event
string | null -
callback
函数¥
callback
Function-
event
字符串¥
event
string -
userInfo
记录<字符串,未知>¥
userInfo
Record<string, unknown> -
object
字符串¥
object
string
-
返回 number
- 本次订阅的 ID
¥Returns number
- The ID of this subscription
与 subscribeNotification
相同,但使用 NSNotificationCenter
作为本地默认值。这对于 NSUserDefaultsDidChangeNotification
这样的事件是必要的。
¥Same as subscribeNotification
, but uses NSNotificationCenter
for local defaults.
This is necessary for events such as NSUserDefaultsDidChangeNotification
.
如果 event
为 null,则 NSNotificationCenter
不会将其用作传递给观察者的标准。请参阅 docs 了解更多信息。
¥If event
is null, the NSNotificationCenter
doesn’t use it as criteria for delivery to the observer. See docs for more information.
systemPreferences.subscribeWorkspaceNotification(event, callback)
macOS
-
event
字符串 | 无效的¥
event
string | null -
callback
函数¥
callback
Function-
event
字符串¥
event
string -
userInfo
记录<字符串,未知>¥
userInfo
Record<string, unknown> -
object
字符串¥
object
string
-
返回 number
- 本次订阅的 ID
¥Returns number
- The ID of this subscription
与 subscribeNotification
相同,但使用 NSWorkspace.sharedWorkspace.notificationCenter
。这对于 NSWorkspaceDidActivateApplicationNotification
这样的事件是必要的。
¥Same as subscribeNotification
, but uses NSWorkspace.sharedWorkspace.notificationCenter
.
This is necessary for events such as NSWorkspaceDidActivateApplicationNotification
.
如果 event
为 null,则 NSWorkspaceNotificationCenter
不会将其用作传递给观察者的标准。请参阅 docs 了解更多信息。
¥If event
is null, the NSWorkspaceNotificationCenter
doesn’t use it as criteria for delivery to the observer. See docs for more information.
systemPreferences.unsubscribeNotification(id)
macOS
-
id
整数¥
id
Integer
删除 id
的订阅者。
¥Removes the subscriber with id
.
systemPreferences.unsubscribeLocalNotification(id)
macOS
-
id
整数¥
id
Integer
与 unsubscribeNotification
相同,但从 NSNotificationCenter
中删除订阅者。
¥Same as unsubscribeNotification
, but removes the subscriber from NSNotificationCenter
.
systemPreferences.unsubscribeWorkspaceNotification(id)
macOS
-
id
整数¥
id
Integer
与 unsubscribeNotification
相同,但从 NSWorkspace.sharedWorkspace.notificationCenter
中删除订阅者。
¥Same as unsubscribeNotification
, but removes the subscriber from NSWorkspace.sharedWorkspace.notificationCenter
.
systemPreferences.registerDefaults(defaults)
macOS
-
defaults
Record<string,字符串 | 布尔值 | 数字> - (key: value
) 个用户默认值的字典¥
defaults
Record<string, string | boolean | number> - a dictionary of (key: value
) user defaults
将指定的默认值添加到应用的 NSUserDefaults
。
¥Add the specified defaults to your application's NSUserDefaults
.
systemPreferences.getUserDefault<Type extends keyof UserDefaultTypes>(key, type)
macOS
-
key
字符串¥
key
string -
type
类型 - 可以是string
、boolean
、integer
、float
、double
、url
、array
或dictionary
。¥
type
Type - Can bestring
,boolean
,integer
,float
,double
,url
,array
ordictionary
.
返回 UserDefaultTypes[Type]
- NSUserDefaults
中 key
的值。
¥Returns UserDefaultTypes[Type]
- The value of key
in NSUserDefaults
.
一些流行的 key
和 type
是:
¥Some popular key
and type
s are:
-
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
字符串¥
key
string -
type
类型 - 可以是string
、boolean
、integer
、float
、double
、url
、array
或dictionary
。¥
type
Type - Can bestring
,boolean
,integer
,float
,double
,url
,array
ordictionary
. -
value
用户默认类型[类型]¥
value
UserDefaultTypes[Type]
将 key
的值设置到 NSUserDefaults
中。
¥Set the value of key
in NSUserDefaults
.
请注意,type
应与 value
的实际类型匹配。如果不这样做,则会抛出异常。
¥Note that type
should match actual type of value
. An exception is thrown
if they don't.
一些流行的 key
和 type
是:
¥Some popular key
and type
s are:
ApplePressAndHoldEnabled
:boolean
systemPreferences.removeUserDefault(key)
macOS
-
key
字符串¥
key
string
删除 NSUserDefaults
中的 key
。这可用于恢复先前使用 setUserDefault
设置的 key
的默认值或全局值。
¥Removes the key
in NSUserDefaults
. This can be used to restore the default
or global value of a key
previously set with setUserDefault
.
systemPreferences.isAeroGlassEnabled()
Windows
返回 boolean
- 如果启用 DWM 组成(航空玻璃),则为 true
,否则为 false
。
¥Returns boolean
- true
if DWM composition (Aero Glass) is
enabled, and false
otherwise.
使用它来确定是否应该创建透明窗口的示例(禁用 DWM 合成时透明窗口将无法正常工作):
¥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):
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.loadFile('index.html')
} else {
// No transparency, so we load a fallback that uses basic styles.
win.loadFile('fallback.html')
}
systemPreferences.getAccentColor()
Windows macOS
返回 string
- 用户当前系统范围的强调色偏好(RGBA 十六进制形式)。
¥Returns string
- The users current system wide accent color preference in RGBA
hexadecimal form.
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"
此 API 仅适用于 macOS 10.14 Mojave 或更高版本。
¥This API is only available on macOS 10.14 Mojave or newer.
systemPreferences.getColor(color)
Windows macOS
-
color
字符串 - 以下值之一:¥
color
string - One of the following values:-
在 Windows 上:
¥On Windows:
-
3d-dark-shadow
- 三维显示元素的深色阴影。¥
3d-dark-shadow
- Dark shadow for three-dimensional display elements. -
3d-face
- 三维显示元素和对话框背景的表面颜色。¥
3d-face
- Face color for three-dimensional display elements and for dialog box backgrounds. -
3d-highlight
- 三维显示元素的高亮颜色。¥
3d-highlight
- Highlight color for three-dimensional display elements. -
3d-light
- 三维显示元素的浅色。¥
3d-light
- Light color for three-dimensional display elements. -
3d-shadow
- 三维显示元素的阴影颜色。¥
3d-shadow
- Shadow color for three-dimensional display elements. -
active-border
- 活动窗口边框。¥
active-border
- Active window border. -
active-caption
- 活动窗口标题栏。如果启用了渐变效果,则指定活动窗口标题栏颜色渐变中的左侧颜色。¥
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
- 活动窗口标题栏颜色渐变中的右侧颜色。¥
active-caption-gradient
- Right side color in the color gradient of an active window's title bar. -
app-workspace
- 多文档界面 (MDI) 应用的背景颜色。¥
app-workspace
- Background color of multiple document interface (MDI) applications. -
button-text
- 按钮上的文本。¥
button-text
- Text on push buttons. -
caption-text
- 标题、大小框和滚动条箭头框中的文本。¥
caption-text
- Text in caption, size box, and scroll bar arrow box. -
desktop
- 桌面背景颜色。¥
desktop
- Desktop background color. -
disabled-text
- 灰色(禁用)文本。¥
disabled-text
- Grayed (disabled) text. -
highlight
- 在控件中选择的项目。¥
highlight
- Item(s) selected in a control. -
highlight-text
- 在控件中选择的项目的文本。¥
highlight-text
- Text of item(s) selected in a control. -
hotlight
- 超链接或热跟踪项目的颜色。¥
hotlight
- Color for a hyperlink or hot-tracked item. -
inactive-border
- 非活动窗口边框。¥
inactive-border
- Inactive window border. -
inactive-caption
- 非活动窗口标题。如果启用了渐变效果,则指定非活动窗口标题栏颜色渐变中的左侧颜色。¥
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
- 非活动窗口标题栏颜色渐变中的右侧颜色。¥
inactive-caption-gradient
- Right side color in the color gradient of an inactive window's title bar. -
inactive-caption-text
- 非活动标题中的文本颜色。¥
inactive-caption-text
- Color of text in an inactive caption. -
info-background
- 工具提示控件的背景颜色。¥
info-background
- Background color for tooltip controls. -
info-text
- 工具提示控件的文本颜色。¥
info-text
- Text color for tooltip controls. -
menu
- 菜单背景。¥
menu
- Menu background. -
menu-highlight
- 当菜单显示为扁平菜单时用于高亮菜单项的颜色。¥
menu-highlight
- The color used to highlight menu items when the menu appears as a flat menu. -
menubar
- 当菜单显示为扁平菜单时菜单栏的背景颜色。¥
menubar
- The background color for the menu bar when menus appear as flat menus. -
menu-text
- 菜单中的文本。¥
menu-text
- Text in menus. -
scrollbar
- 滚动条灰色区域。¥
scrollbar
- Scroll bar gray area. -
window
- 窗口背景。¥
window
- Window background. -
window-frame
- 窗框。¥
window-frame
- Window frame. -
window-text
- 窗口中的文本。¥
window-text
- Text in windows.
-
-
在 macOS 上
¥On macOS
-
control-background
- 大型界面元素(例如浏览器或表格)的背景。¥
control-background
- The background of a large interface element, such as a browser or table. -
control
- 控件的表面。¥
control
- The surface of a control. -
control-text
- 未禁用的控件的文本。¥
control-text
-The text of a control that isn’t disabled. -
disabled-control-text
- 禁用的控件的文本。¥
disabled-control-text
- The text of a control that’s disabled. -
find-highlight
- 查找指示器的颜色。¥
find-highlight
- The color of a find indicator. -
grid
- 界面元素(例如表格)的网格线。¥
grid
- The gridlines of an interface element such as a table. -
header-text
- 表中标题单元格的文本。¥
header-text
- The text of a header cell in a table. -
highlight
- 屏幕上的虚拟光源。¥
highlight
- The virtual light source onscreen. -
keyboard-focus-indicator
- 使用键盘进行界面导航时,当前聚焦控件周围出现的环。¥
keyboard-focus-indicator
- The ring that appears around the currently focused control when using the keyboard for interface navigation. -
label
- 包含主要内容的标签文本。¥
label
- The text of a label containing primary content. -
link
- 其他内容的链接。¥
link
- A link to other content. -
placeholder-text
- 控件或文本视图中的占位符字符串。¥
placeholder-text
- A placeholder string in a control or text view. -
quaternary-label
- 重要性低于三级标签的标签文本,例如水印文本。¥
quaternary-label
- The text of a label of lesser importance than a tertiary label such as watermark text. -
scrubber-textured-background
- 触摸栏中洗涤器的背景。¥
scrubber-textured-background
- The background of a scrubber in the Touch Bar. -
secondary-label
- 比普通标签重要性较低的标签文本,例如用于表示副标题或附加信息的标签。¥
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
- 关键窗口或视图中选定内容的背景。¥
selected-content-background
- The background for selected content in a key window or view. -
selected-control
- 选定控件的表面。¥
selected-control
- The surface of a selected control. -
selected-control-text
- 选定控件的文本。¥
selected-control-text
- The text of a selected control. -
selected-menu-item-text
- 所选菜单的文本。¥
selected-menu-item-text
- The text of a selected menu. -
selected-text-background
- 所选文本的背景。¥
selected-text-background
- The background of selected text. -
selected-text
- 选定的文本。¥
selected-text
- Selected text. -
separator
- 不同内容部分之间的分隔符。¥
separator
- A separator between different sections of content. -
shadow
- 屏幕上凸起的对象投射的虚拟阴影。¥
shadow
- The virtual shadow cast by a raised object onscreen. -
tertiary-label
- 重要性低于辅助标签的标签文本,例如用于表示禁用文本的标签。¥
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 background. -
text
- 文档中的文本。¥
text
- The text in a document. -
under-page-background
- 文档内容背后的背景。¥
under-page-background
- The background behind a document's content. -
unemphasized-selected-content-background
- 在非关键窗口或视图中选择的内容。¥
unemphasized-selected-content-background
- The selected content in a non-key window or view. -
unemphasized-selected-text-background
- 非关键窗口或视图中选定文本的背景。¥
unemphasized-selected-text-background
- A background for selected text in a non-key window or view. -
unemphasized-selected-text
- 非关键窗口或视图中的选定文本。¥
unemphasized-selected-text
- Selected text in a non-key window or view. -
window-background
- 窗口的背景。¥
window-background
- The background of a window. -
window-frame-text
- 窗口标题栏区域中的文本。¥
window-frame-text
- The text in the window's titlebar area.
-
-
返回 string
- RGBA 十六进制形式 (#RRGGBBAA
) 的系统颜色设置。有关详细信息,请参阅 Windows 文档 和 macOS 文档。
¥Returns string
- The system color setting in RGBA hexadecimal form (#RRGGBBAA
).
See the Windows docs and the macOS docs for more details.
以下颜色仅适用于 macOS 10.14:find-highlight
、selected-content-background
、separator
、unemphasized-selected-content-background
、unemphasized-selected-text-background
和 unemphasized-selected-text
。
¥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
.
systemPreferences.getSystemColor(color)
macOS
-
color
字符串 - 以下值之一:¥
color
string - One of the following values:-
blue
-
brown
-
gray
-
green
-
orange
-
pink
-
purple
-
red
-
yellow
-
返回 string
- 标准系统颜色格式为 #RRGGBBAA
。
¥Returns string
- The standard system color formatted as #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.
systemPreferences.getEffectiveAppearance()
macOS
返回 string
- 可以是 dark
、light
或 unknown
。
¥Returns string
- Can be dark
, light
or unknown
.
获取当前应用于你的应用的 macOS 外观设置,映射到 NSApplication.effectiveAppearance
¥Gets the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance
systemPreferences.canPromptTouchID()
macOS
返回 boolean
- 该设备是否能够使用 Touch ID。
¥Returns boolean
- whether or not this device has the ability to use Touch ID.
systemPreferences.promptTouchID(reason)
macOS
-
reason
字符串 - 你要求 Touch ID 身份验证的原因¥
reason
string - The reason you are asking for Touch ID authentication
返回 Promise<void>
- 解决用户是否已成功使用 Touch ID 进行身份验证。
¥Returns Promise<void>
- resolves if the user has successfully authenticated with 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)
})
该 API 本身不会保护你的用户数据;相反,它是一种允许你这样做的机制。原生应用需要在其密钥串条目上像 kSecAccessControlUserPresence
一样设置 访问控制常量,以便读取它时会自动提示 Touch ID 生物识别同意。这可以通过 node-keytar
来完成,这样就可以使用 node-keytar
存储加密密钥,并且仅在 promptTouchID()
解析时才获取它。
¥This API itself will not protect your user data; rather, it is a mechanism to allow you to do so. 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. 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.
systemPreferences.isTrustedAccessibilityClient(prompt)
macOS
-
prompt
布尔值 - 如果当前进程不受信任,是否会通过提示通知用户。¥
prompt
boolean - whether or not the user will be informed via prompt if the current process is untrusted.
返回 boolean
- 如果当前进程是受信任的可访问性客户端,则为 true
;如果不是,则为 false
。
¥Returns boolean
- true
if the current process is a trusted accessibility client and false
if it is not.
systemPreferences.getMediaAccessStatus(mediaType)
Windows macOS
-
mediaType
字符串 - 可以是microphone
、camera
或screen
。¥
mediaType
string - Can bemicrophone
,camera
orscreen
.
返回 string
- 可以是 not-determined
、granted
、denied
、restricted
或 unknown
。
¥Returns string
- Can be not-determined
, granted
, denied
, restricted
or unknown
.
macOS 10.13 High Sierra 不需要用户同意,因此此方法将始终返回 granted
。macOS 10.14 Mojave 或更高版本需要同意 microphone
和 camera
访问。macOS 10.15 Catalina 或更高版本需要同意 screen
访问。
¥This user consent was not required on macOS 10.13 High Sierra so this method will always return granted
.
macOS 10.14 Mojave or higher requires consent for microphone
and camera
access.
macOS 10.15 Catalina or higher requires consent for screen
access.
Windows 10 有一个全局设置,控制所有 win32 应用的 microphone
和 camera
访问。对于 screen
以及旧版本 Windows 上的所有媒体类型,它将始终返回 granted
。
¥Windows 10 has a global setting controlling microphone
and camera
access for all win32 applications.
It will always return granted
for screen
and for all media types on older versions of Windows.
systemPreferences.askForMediaAccess(mediaType)
macOS
-
mediaType
字符串 - 请求的媒体类型;可以是microphone
、camera
。¥
mediaType
string - the type of media being requested; can bemicrophone
,camera
.
返回 Promise<boolean>
- 如果同意则以 true
解决,如果拒绝则以 false
解决。如果传递了无效的 mediaType
,则 promise 将被拒绝。如果访问请求被拒绝,并且后来通过“系统偏好设置”窗格进行了更改,则需要重新启动应用才能使新权限生效。如果访问已被请求并被拒绝,则必须通过首选项窗格进行更改;不会弹出警报,并且 promise 将根据现有的访问状态解决。
¥Returns Promise<boolean>
- A promise that resolves with true
if consent was granted and false
if it was denied. If an invalid mediaType
is passed, the promise will be rejected. 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.
重要的:为了正确利用此 API,你需要在应用的 Info.plist
文件中对 NSMicrophoneUsageDescription
和 NSCameraUsageDescription
字符串进行 必须设置 处理。这些键的值将用于填充权限对话框,以便用户正确了解权限请求的目的。有关如何在 Electron 上下文中设置这些的更多信息,请参阅 Electron 应用分发。
¥Important: In order to properly leverage this API, you must set the NSMicrophoneUsageDescription
and NSCameraUsageDescription
strings in your app's Info.plist
file. 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.
在 macOS 10.14 Mojave 之前不需要用户同意,因此如果你的系统运行的是 10.13 High Sierra,则此方法将始终返回 true
。
¥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.
systemPreferences.getAnimationSettings()
返回 Object
:
¥Returns Object
:
-
shouldRenderRichAnimation
布尔值 - 如果应渲染丰富的动画,则返回 true。查看会话类型(例如远程桌面)和辅助功能设置,为繁重的动画提供指导。¥
shouldRenderRichAnimation
boolean - Returns true if rich animations should be rendered. Looks at session type (e.g. remote desktop) and accessibility settings to give guidance for heavy animations. -
scrollAnimationsEnabledBySystem
布尔值 - 根据每个平台确定是否应启用滚动动画(例如由 home/end 键生成)。¥
scrollAnimationsEnabledBySystem
boolean - Determines on a per-platform basis whether scroll animations (e.g. produced by home/end key) should be enabled. -
prefersReducedMotion
布尔值 - 根据平台 API 确定用户是否希望减少运动。¥
prefersReducedMotion
boolean - Determines whether the user desires reduced motion based on platform APIs.
返回具有系统动画设置的对象。
¥Returns an object with system animation settings.
属性
¥Properties
systemPreferences.accessibilityDisplayShouldReduceTransparency
macOS 已弃用
¥systemPreferences.accessibilityDisplayShouldReduceTransparency
macOS Deprecated
boolean
属性,用于确定应用是否避免使用半透明背景。这映射到 NSWorkspace.accessibilityDisplayShouldReduceTransparency
¥A boolean
property which determines whether the app avoids using semitransparent backgrounds. This maps to NSWorkspace.accessibilityDisplayShouldReduceTransparency
已弃用:使用新的 nativeTheme.prefersReducedTransparency
API。
¥Deprecated: Use the new nativeTheme.prefersReducedTransparency
API.
systemPreferences.effectiveAppearance
macOS 只读
¥systemPreferences.effectiveAppearance
macOS Readonly
string
属性可以是 dark
、light
或 unknown
。
¥A string
property that can be dark
, light
or unknown
.
返回当前应用于你的应用的 macOS 外观设置,映射到 NSApplication.effectiveAppearance
¥Returns the macOS appearance setting that is currently applied to your application, maps to NSApplication.effectiveAppearance