From a1e34a00e60b5a0136bc8e464616c2bc6d9dc061 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Wed, 8 May 2024 17:59:38 +0800 Subject: [PATCH] :sparkles: Add alwaysOnTop feature --- bin/README.md | 7 +++++++ bin/README_CN.md | 10 ++++++++++ bin/defaults.ts | 1 + bin/helpers/merge.ts | 2 ++ bin/types.ts | 3 +++ src-tauri/pake.json | 3 ++- src-tauri/src/app/config.rs | 1 + src-tauri/src/app/window.rs | 1 + 8 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bin/README.md b/bin/README.md index e0131b7..deace75 100644 --- a/bin/README.md +++ b/bin/README.md @@ -121,6 +121,13 @@ Enable or disable immersive header. Default is `false`. Use the following comman --transparent ``` +#### [always-on-top] +Enable the always-on-top feature. Default is `false`. + +```shell +--always-on-top +``` + #### [fullscreen] Determine whether the application launches in full screen. Default is `false`. Use the following command to enable full screen. diff --git a/bin/README_CN.md b/bin/README_CN.md index f23ef78..981a255 100644 --- a/bin/README_CN.md +++ b/bin/README_CN.md @@ -122,6 +122,16 @@ pake [url] [options] --transparent ``` +#### [always-on-top] +设置是否窗口一直在最顶层,默认为 `false`。 + +```shell +--always-on-top +``` + + +```shell + #### [fullscreen] 设置应用程序是否在启动时自动全屏,默认为 `false`。使用以下命令可以设置应用程序启动时自动全屏。 diff --git a/bin/defaults.ts b/bin/defaults.ts index 8403d89..cfaff8b 100644 --- a/bin/defaults.ts +++ b/bin/defaults.ts @@ -7,6 +7,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = { fullscreen: false, resizable: true, transparent: false, + alwaysOnTop: false, userAgent: '', showSystemTray: false, multiArch: false, diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts index 6883dea..9d306e6 100644 --- a/bin/helpers/merge.ts +++ b/bin/helpers/merge.ts @@ -13,6 +13,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon height, fullscreen, transparent, + alwaysOnTop, userAgent, showSystemTray, systemTrayIcon, @@ -32,6 +33,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon height, fullscreen, transparent, + alwaysOnTop, resizable, }; Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions }); diff --git a/bin/types.ts b/bin/types.ts index 74e2b58..f555ed4 100644 --- a/bin/types.ts +++ b/bin/types.ts @@ -24,6 +24,9 @@ export interface PakeCliOptions { // Enable immersive header, default false transparent: boolean; + // Enable windows always on top, default false + alwaysOnTop: boolean; + // Custom User-Agent, default off userAgent: string; diff --git a/src-tauri/pake.json b/src-tauri/pake.json index 9d36efe..49e85bb 100644 --- a/src-tauri/pake.json +++ b/src-tauri/pake.json @@ -7,7 +7,8 @@ "width": 1200, "height": 780, "resizable": true, - "url_type": "web" + "url_type": "web", + "always_on_top": false } ], "user_agent": { diff --git a/src-tauri/src/app/config.rs b/src-tauri/src/app/config.rs index 1460ca8..0610b72 100644 --- a/src-tauri/src/app/config.rs +++ b/src-tauri/src/app/config.rs @@ -9,6 +9,7 @@ pub struct WindowConfig { pub height: f64, pub resizable: bool, pub url_type: String, + pub always_on_top: bool, } #[derive(Debug, Deserialize)] diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs index 64c5db9..fde4f5a 100644 --- a/src-tauri/src/app/window.rs +++ b/src-tauri/src/app/window.rs @@ -27,6 +27,7 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind .fullscreen(window_config.fullscreen) .inner_size(window_config.width, window_config.height) .disable_file_drop_handler() + .always_on_top(window_config.always_on_top) .initialization_script(include_str!("../inject/component.js")) .initialization_script(include_str!("../inject/event.js")) .initialization_script(include_str!("../inject/style.js"))