✨ Support Mac dark mode
This commit is contained in:
8
bin/README.md
vendored
8
bin/README.md
vendored
@@ -146,6 +146,14 @@ Sets whether the window is always at the top level, defaults to `false`.
|
|||||||
--always-on-top
|
--always-on-top
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### [dark-mode]
|
||||||
|
|
||||||
|
Force Mac to package applications using dark mode, default is `false`.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
--dark-mode
|
||||||
|
```
|
||||||
|
|
||||||
#### [disabled-web-shortcuts]
|
#### [disabled-web-shortcuts]
|
||||||
|
|
||||||
Sets whether to disable web shortcuts in the original Pake container, defaults to `false`.
|
Sets whether to disable web shortcuts in the original Pake container, defaults to `false`.
|
||||||
|
|||||||
8
bin/README_CN.md
vendored
8
bin/README_CN.md
vendored
@@ -146,6 +146,14 @@ pake [url] [options]
|
|||||||
--always-on-top
|
--always-on-top
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### [dark-mode]
|
||||||
|
|
||||||
|
强制 Mac 打包应用使用黑暗模式,默认为 `false`。
|
||||||
|
|
||||||
|
```shell
|
||||||
|
--dark-mode
|
||||||
|
```
|
||||||
|
|
||||||
#### [disabled-web-shortcuts]
|
#### [disabled-web-shortcuts]
|
||||||
|
|
||||||
设置是否禁用原有 Pake 容器里面的网页操作快捷键,默认为 `false`。
|
设置是否禁用原有 Pake 容器里面的网页操作快捷键,默认为 `false`。
|
||||||
|
|||||||
1
bin/cli.ts
vendored
1
bin/cli.ts
vendored
@@ -38,6 +38,7 @@ program
|
|||||||
new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp(),
|
new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT.targets).hideHelp(),
|
||||||
)
|
)
|
||||||
.addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT.alwaysOnTop).hideHelp())
|
.addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT.alwaysOnTop).hideHelp())
|
||||||
|
.addOption(new Option('--dark-mode', 'Force Mac app to use dark mode').default(DEFAULT.darkMode).hideHelp())
|
||||||
.addOption(
|
.addOption(
|
||||||
new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
|
new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
|
||||||
.default(DEFAULT.disabledWebShortcuts)
|
.default(DEFAULT.disabledWebShortcuts)
|
||||||
|
|||||||
1
bin/defaults.ts
vendored
1
bin/defaults.ts
vendored
@@ -8,6 +8,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
|||||||
resizable: true,
|
resizable: true,
|
||||||
hideTitleBar: false,
|
hideTitleBar: false,
|
||||||
alwaysOnTop: false,
|
alwaysOnTop: false,
|
||||||
|
darkMode: false,
|
||||||
disabledWebShortcuts: false,
|
disabledWebShortcuts: false,
|
||||||
activationShortcut: '',
|
activationShortcut: '',
|
||||||
userAgent: '',
|
userAgent: '',
|
||||||
|
|||||||
2
bin/helpers/merge.ts
vendored
2
bin/helpers/merge.ts
vendored
@@ -14,6 +14,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
fullscreen,
|
fullscreen,
|
||||||
hideTitleBar,
|
hideTitleBar,
|
||||||
alwaysOnTop,
|
alwaysOnTop,
|
||||||
|
darkMode,
|
||||||
disabledWebShortcuts,
|
disabledWebShortcuts,
|
||||||
activationShortcut,
|
activationShortcut,
|
||||||
userAgent,
|
userAgent,
|
||||||
@@ -39,6 +40,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
hide_title_bar: hideTitleBar,
|
hide_title_bar: hideTitleBar,
|
||||||
activation_shortcut: activationShortcut,
|
activation_shortcut: activationShortcut,
|
||||||
always_on_top: alwaysOnTop,
|
always_on_top: alwaysOnTop,
|
||||||
|
dark_mode: darkMode,
|
||||||
disabled_web_shortcuts: disabledWebShortcuts,
|
disabled_web_shortcuts: disabledWebShortcuts,
|
||||||
};
|
};
|
||||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
|
|||||||
4
bin/types.ts
vendored
4
bin/types.ts
vendored
@@ -27,6 +27,10 @@ export interface PakeCliOptions {
|
|||||||
// Enable windows always on top, default false
|
// Enable windows always on top, default false
|
||||||
alwaysOnTop: boolean;
|
alwaysOnTop: boolean;
|
||||||
|
|
||||||
|
|
||||||
|
// Force Mac to use dark mode, default false
|
||||||
|
darkMode: boolean;
|
||||||
|
|
||||||
// Disable web shortcuts, default false
|
// Disable web shortcuts, default false
|
||||||
disabledWebShortcuts: boolean;
|
disabledWebShortcuts: boolean;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
"width": 1200,
|
"width": 1200,
|
||||||
"height": 780,
|
"height": 780,
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
|
"dark_mode": false,
|
||||||
"always_on_top": false,
|
"always_on_top": false,
|
||||||
"activation_shortcut": "",
|
"activation_shortcut": "",
|
||||||
"disabled_web_shortcuts": false
|
"disabled_web_shortcuts": false
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ pub struct WindowConfig {
|
|||||||
pub resizable: bool,
|
pub resizable: bool,
|
||||||
pub url_type: String,
|
pub url_type: String,
|
||||||
pub always_on_top: bool,
|
pub always_on_top: bool,
|
||||||
|
pub dark_mode: bool,
|
||||||
pub disabled_web_shortcuts: bool,
|
pub disabled_web_shortcuts: bool,
|
||||||
pub activation_shortcut: String,
|
pub activation_shortcut: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::app::config::PakeConfig;
|
use crate::app::config::PakeConfig;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tauri::{App, Window, WindowBuilder, WindowUrl};
|
use tauri::{App, Theme, Window, WindowBuilder, WindowUrl};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use tauri::TitleBarStyle;
|
use tauri::TitleBarStyle;
|
||||||
@@ -45,7 +45,12 @@ pub fn build_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wi
|
|||||||
} else {
|
} else {
|
||||||
TitleBarStyle::Visible
|
TitleBarStyle::Visible
|
||||||
};
|
};
|
||||||
window_builder = window_builder.title_bar_style(title_bar_style)
|
|
||||||
|
window_builder = window_builder.title_bar_style(title_bar_style);
|
||||||
|
|
||||||
|
if window_config.dark_mode {
|
||||||
|
window_builder = window_builder.theme(Some(Theme::Dark));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
|||||||
Reference in New Issue
Block a user