Π·Π΅ΡΠΊΠ°Π»ΠΎ ΠΈΠ· https://github.com/electron/electron.git
π Add 'isDarkModeEnabled' to app api
This commit is contained in:
Π ΠΎΠ΄ΠΈΡΠ΅Π»Ρ
5839d7dcd5
ΠΠΎΠΌΠΌΠΈΡ
eaac67ac60
|
@ -370,6 +370,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
|||
#if defined(OS_MACOSX)
|
||||
.SetMethod("hide", base::Bind(&Browser::Hide, browser))
|
||||
.SetMethod("show", base::Bind(&Browser::Show, browser))
|
||||
.SetMethod("isDarkModeEnabled", base::Bind(&Browser::IsDarkModeEnabled, browser))
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("setUserTasks",
|
||||
|
|
|
@ -83,6 +83,9 @@ class Browser : public WindowListObserver {
|
|||
// Show the application.
|
||||
void Show();
|
||||
|
||||
// Check if Dark Mode enabled.
|
||||
bool IsDarkModeEnabled();
|
||||
|
||||
// Bounce the dock icon.
|
||||
enum BounceType {
|
||||
BOUNCE_CRITICAL = 0,
|
||||
|
|
|
@ -26,6 +26,11 @@ void Browser::Show() {
|
|||
[[AtomApplication sharedApplication] unhide:nil];
|
||||
}
|
||||
|
||||
bool Browser::IsDarkModeEnabled() {
|
||||
NSString *mode = CFBridgingRelease(CFPreferencesCopyValue((CFStringRef)@"AppleInterfaceStyle", kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost));
|
||||
return [mode isEqualToString: @"Dark"];
|
||||
}
|
||||
|
||||
void Browser::AddRecentDocument(const base::FilePath& path) {
|
||||
NSString* path_string = base::mac::FilePathToNSString(path);
|
||||
if (!path_string)
|
||||
|
|
|
@ -461,6 +461,10 @@ if (browserOptions.transparent) {
|
|||
}
|
||||
```
|
||||
|
||||
### `app.isDarkModeEnabled()` _OS X_
|
||||
|
||||
This method returns `true` if Dark Mode is enabled, and `false` otherwise.
|
||||
|
||||
### `app.commandLine.appendSwitch(switch[, value])`
|
||||
|
||||
Append a switch (with optional `value`) to Chromium's command line.
|
||||
|
|
ΠΠ°Π³ΡΡΠ·ΠΊΠ°β¦
Π‘ΡΡΠ»ΠΊΠ° Π² Π½ΠΎΠ²ΠΎΠΉ Π·Π°Π΄Π°ΡΠ΅