✨ 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
|
||||
```
|
||||
|
||||
#### [dark-mode]
|
||||
|
||||
Force Mac to package applications using dark mode, default is `false`.
|
||||
|
||||
```shell
|
||||
--dark-mode
|
||||
```
|
||||
|
||||
#### [disabled-web-shortcuts]
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
#### [dark-mode]
|
||||
|
||||
强制 Mac 打包应用使用黑暗模式,默认为 `false`。
|
||||
|
||||
```shell
|
||||
--dark-mode
|
||||
```
|
||||
|
||||
#### [disabled-web-shortcuts]
|
||||
|
||||
设置是否禁用原有 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(),
|
||||
)
|
||||
.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(
|
||||
new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
|
||||
.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,
|
||||
hideTitleBar: false,
|
||||
alwaysOnTop: false,
|
||||
darkMode: false,
|
||||
disabledWebShortcuts: false,
|
||||
activationShortcut: '',
|
||||
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,
|
||||
hideTitleBar,
|
||||
alwaysOnTop,
|
||||
darkMode,
|
||||
disabledWebShortcuts,
|
||||
activationShortcut,
|
||||
userAgent,
|
||||
@@ -39,6 +40,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
||||
hide_title_bar: hideTitleBar,
|
||||
activation_shortcut: activationShortcut,
|
||||
always_on_top: alwaysOnTop,
|
||||
dark_mode: darkMode,
|
||||
disabled_web_shortcuts: disabledWebShortcuts,
|
||||
};
|
||||
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
|
||||
alwaysOnTop: boolean;
|
||||
|
||||
|
||||
// Force Mac to use dark mode, default false
|
||||
darkMode: boolean;
|
||||
|
||||
// Disable web shortcuts, default false
|
||||
disabledWebShortcuts: boolean;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"width": 1200,
|
||||
"height": 780,
|
||||
"resizable": true,
|
||||
"dark_mode": false,
|
||||
"always_on_top": false,
|
||||
"activation_shortcut": "",
|
||||
"disabled_web_shortcuts": false
|
||||
|
||||
@@ -10,6 +10,7 @@ pub struct WindowConfig {
|
||||
pub resizable: bool,
|
||||
pub url_type: String,
|
||||
pub always_on_top: bool,
|
||||
pub dark_mode: bool,
|
||||
pub disabled_web_shortcuts: bool,
|
||||
pub activation_shortcut: String,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::app::config::PakeConfig;
|
||||
use std::path::PathBuf;
|
||||
use tauri::{App, Window, WindowBuilder, WindowUrl};
|
||||
use tauri::{App, Theme, Window, WindowBuilder, WindowUrl};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::TitleBarStyle;
|
||||
@@ -45,7 +45,12 @@ pub fn build_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wi
|
||||
} else {
|
||||
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"))]
|
||||
|
||||
Reference in New Issue
Block a user