✨ Support setting activationShortcut
This commit is contained in:
31
bin/README.md
vendored
31
bin/README.md
vendored
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Ensure that your Node.js version is 16.0 or higher (e.g., 16.8). Avoid using `sudo` for the installation. If you encounter permission issues with npm, refer to [How to fix npm throwing error without sudo](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo).
|
Ensure that your Node.js version is 18.0 or higher (e.g., 18.20.2). Avoid using `sudo` for the installation. If you encounter permission issues with npm, refer to [How to fix npm throwing error without sudo](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install pake-cli -g
|
npm install pake-cli -g
|
||||||
@@ -81,7 +81,7 @@ Various options are available for customization. You can pass corresponding argu
|
|||||||
Specify the application name. If not provided, you will be prompted to enter it. It is recommended to use English.
|
Specify the application name. If not provided, you will be prompted to enter it. It is recommended to use English.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--name <value>
|
--name <string>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [icon]
|
#### [icon]
|
||||||
@@ -112,12 +112,12 @@ Set the width of the application window. Default is `1200px`.
|
|||||||
--width <number>
|
--width <number>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [transparent]
|
#### [hide-title-bar]
|
||||||
|
|
||||||
Enable or disable immersive header. Default is `false`. Use the following command to enable this feature, macOS only.
|
Enable or disable immersive header. Default is `false`. Use the following command to enable this feature, macOS only.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--transparent
|
--hide-title-bar
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [fullscreen]
|
#### [fullscreen]
|
||||||
@@ -129,6 +129,15 @@ screen.
|
|||||||
--fullscreen
|
--fullscreen
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### [activation-shortcut]
|
||||||
|
|
||||||
|
Set the activation shortcut for the application. Default is ` `, it does not take effect, you can customize the activation shortcut with the following commands, e.g. `CmdOrControl+Shift+P`, use can refer to [available-modifiers](https://www.electronjs.org/docs/latest/api/accelerator#available-modifiers).
|
||||||
|
|
||||||
|
```shell
|
||||||
|
--activation-shortcut <string>
|
||||||
|
```
|
||||||
|
|
||||||
#### [always-on-top]
|
#### [always-on-top]
|
||||||
|
|
||||||
Sets whether the window is always at the top level, defaults to `false`.
|
Sets whether the window is always at the top level, defaults to `false`.
|
||||||
@@ -154,15 +163,15 @@ Package the application to support both Intel and M1 chips, exclusively for macO
|
|||||||
- Note: After enabling this option, Rust must be installed using rustup from the official Rust website. Installation via brew is not supported.
|
- Note: After enabling this option, Rust must be installed using rustup from the official Rust website. Installation via brew is not supported.
|
||||||
- For Intel chip users, install the arm64 cross-platform package to support M1 chips using the following command:
|
- For Intel chip users, install the arm64 cross-platform package to support M1 chips using the following command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
rustup target add aarch64-apple-darwin
|
rustup target add aarch64-apple-darwin
|
||||||
```
|
```
|
||||||
|
|
||||||
- For M1 chip users, install the x86 cross-platform package to support Intel chips using the following command:
|
- For M1 chip users, install the x86 cross-platform package to support Intel chips using the following command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
rustup target add x86_64-apple-darwin
|
rustup target add x86_64-apple-darwin
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Usage
|
##### Usage
|
||||||
|
|
||||||
@@ -183,7 +192,7 @@ Select the output package format for Linux. Options include `deb`, `appimage`, o
|
|||||||
Customize the browser user agent. Default is empty.
|
Customize the browser user agent. Default is empty.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--user-agent <value>
|
--user-agent <string>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [show-system-tray]
|
#### [show-system-tray]
|
||||||
|
|||||||
34
bin/README_CN.md
vendored
34
bin/README_CN.md
vendored
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
请确保您的 Node.js 版本为 16 或更高版本(例如 16.8)。请避免使用 `sudo` 进行安装。如果 npm 报告权限问题,请参考 [如何在不使用 sudo 的情况下修复 npm 报错](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo)。
|
请确保您的 Node.js 版本为 18 或更高版本(例如 18.7)。请避免使用 `sudo` 进行安装。如果 npm 报告权限问题,请参考 [如何在不使用 sudo 的情况下修复 npm 报错](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo)。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install pake-cli -g
|
npm install pake-cli -g
|
||||||
@@ -79,10 +79,10 @@ pake [url] [options]
|
|||||||
|
|
||||||
#### [name]
|
#### [name]
|
||||||
|
|
||||||
指定应用程序的名称。如果在输入时未指定,系统会提示您输入。建议使用英文名称。
|
指定应用程序的名称,如果在输入时未指定,系统会提示您输入,建议使用单个英文名称,不要出现下划线或者中文。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--name <value>
|
--name <string>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [icon]
|
#### [icon]
|
||||||
@@ -114,12 +114,12 @@ pake [url] [options]
|
|||||||
--width <number>
|
--width <number>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [transparent]
|
#### [hide-title-bar]
|
||||||
|
|
||||||
设置是否启用沉浸式头部,默认为 `false`(不启用)。当前只对 macOS 上有效。
|
设置是否启用沉浸式头部,默认为 `false`(不启用)。当前只对 macOS 上有效。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--transparent
|
--hide-title-bar
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [fullscreen]
|
#### [fullscreen]
|
||||||
@@ -130,6 +130,14 @@ pake [url] [options]
|
|||||||
--fullscreen
|
--fullscreen
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### [activation-shortcut]
|
||||||
|
|
||||||
|
设置应用程序的激活快捷键。默认为空,不生效,可以使用以下命令自定义激活快捷键,例如 `CmdOrControl+Shift+P`,使用可参考 [available-modifiers](https://www.electronjs.org/docs/latest/api/accelerator#available-modifiers)。
|
||||||
|
|
||||||
|
```shell
|
||||||
|
--activation-shortcut <string>
|
||||||
|
```
|
||||||
|
|
||||||
#### [always-on-top]
|
#### [always-on-top]
|
||||||
|
|
||||||
设置是否窗口一直在最顶层,默认为 `false`。
|
设置是否窗口一直在最顶层,默认为 `false`。
|
||||||
@@ -155,15 +163,15 @@ pake [url] [options]
|
|||||||
- 注意:启用此选项后,需要使用 rust 官网的 rustup 安装 rust,不支持通过 brew 安装。
|
- 注意:启用此选项后,需要使用 rust 官网的 rustup 安装 rust,不支持通过 brew 安装。
|
||||||
- 对于 Intel 芯片用户,需要安装 arm64 跨平台包,以使安装包支持 M1 芯片。使用以下命令安装:
|
- 对于 Intel 芯片用户,需要安装 arm64 跨平台包,以使安装包支持 M1 芯片。使用以下命令安装:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
rustup target add aarch64-apple-darwin
|
rustup target add aarch64-apple-darwin
|
||||||
```
|
```
|
||||||
|
|
||||||
- 对于 M1 芯片用户,需要安装 x86 跨平台包,以使安装包支持 Intel 芯片。使用以下命令安装:
|
- 对于 M1 芯片用户,需要安装 x86 跨平台包,以使安装包支持 Intel 芯片。使用以下命令安装:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
rustup target add x86_64-apple-darwin
|
rustup target add x86_64-apple-darwin
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 使用方法
|
##### 使用方法
|
||||||
|
|
||||||
@@ -177,7 +185,7 @@ rustup target add x86_64-apple-darwin
|
|||||||
Linux,默认为 `all`。
|
Linux,默认为 `all`。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--targets <value>
|
--targets <string>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [user-agent]
|
#### [user-agent]
|
||||||
@@ -185,7 +193,7 @@ Linux,默认为 `all`。
|
|||||||
自定义浏览器的用户代理请求头,默认为空。
|
自定义浏览器的用户代理请求头,默认为空。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--user-agent <value>
|
--user-agent <string>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### [show-system-tray]
|
#### [show-system-tray]
|
||||||
|
|||||||
1
bin/defaults.ts
vendored
1
bin/defaults.ts
vendored
@@ -9,6 +9,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
|||||||
transparent: false,
|
transparent: false,
|
||||||
alwaysOnTop: false,
|
alwaysOnTop: false,
|
||||||
disabledWebShortcuts: false,
|
disabledWebShortcuts: false,
|
||||||
|
activationShortcut: '',
|
||||||
userAgent: '',
|
userAgent: '',
|
||||||
showSystemTray: false,
|
showSystemTray: false,
|
||||||
multiArch: false,
|
multiArch: false,
|
||||||
|
|||||||
3
bin/types.ts
vendored
3
bin/types.ts
vendored
@@ -30,6 +30,9 @@ export interface PakeCliOptions {
|
|||||||
// Disable web shortcuts, default false
|
// Disable web shortcuts, default false
|
||||||
disabledWebShortcuts: boolean;
|
disabledWebShortcuts: boolean;
|
||||||
|
|
||||||
|
// Set a shortcut key to wake up the app, default empty
|
||||||
|
activationShortcut: string;
|
||||||
|
|
||||||
// Custom User-Agent, default off
|
// Custom User-Agent, default off
|
||||||
userAgent: string;
|
userAgent: string;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"height": 780,
|
"height": 780,
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"always_on_top": false,
|
"always_on_top": false,
|
||||||
|
"activation_shortcut": "",
|
||||||
"disabled_web_shortcuts": false
|
"disabled_web_shortcuts": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pub struct WindowConfig {
|
|||||||
pub url_type: String,
|
pub url_type: String,
|
||||||
pub always_on_top: bool,
|
pub always_on_top: bool,
|
||||||
pub disabled_web_shortcuts: bool,
|
pub disabled_web_shortcuts: bool,
|
||||||
|
pub activation_shortcut: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ mod util;
|
|||||||
use app::{invoke, menu, window};
|
use app::{invoke, menu, window};
|
||||||
use invoke::{download_file, download_file_by_binary};
|
use invoke::{download_file, download_file_by_binary};
|
||||||
use menu::{get_system_tray, system_tray_handle};
|
use menu::{get_system_tray, system_tray_handle};
|
||||||
|
use tauri::{GlobalShortcutManager, Manager};
|
||||||
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
||||||
use util::{get_data_dir, get_pake_config};
|
use util::{get_data_dir, get_pake_config};
|
||||||
use window::get_window;
|
use window::get_window;
|
||||||
@@ -28,6 +29,9 @@ pub fn run_app() {
|
|||||||
.on_system_tray_event(system_tray_handle);
|
.on_system_tray_event(system_tray_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the value of toggle_app_shortcut before pake_config is moved
|
||||||
|
let activation_shortcut = pake_config.windows[0].activation_shortcut.clone();
|
||||||
|
|
||||||
tauri_app
|
tauri_app
|
||||||
.plugin(windowStatePlugin::default().build())
|
.plugin(windowStatePlugin::default().build())
|
||||||
.plugin(tauri_plugin_oauth::init())
|
.plugin(tauri_plugin_oauth::init())
|
||||||
@@ -35,10 +39,28 @@ pub fn run_app() {
|
|||||||
download_file,
|
download_file,
|
||||||
download_file_by_binary
|
download_file_by_binary
|
||||||
])
|
])
|
||||||
.setup(|app| {
|
.setup(move |app| {
|
||||||
let _window = get_window(app, pake_config, data_dir);
|
let _window = get_window(app, pake_config, data_dir);
|
||||||
// Prevent initial shaking
|
// Prevent initial shaking
|
||||||
_window.show().unwrap();
|
_window.show().unwrap();
|
||||||
|
|
||||||
|
if !activation_shortcut.is_empty() {
|
||||||
|
let app_handle = app.app_handle().clone();
|
||||||
|
app_handle
|
||||||
|
.global_shortcut_manager()
|
||||||
|
.register(activation_shortcut.as_str(), move || {
|
||||||
|
let window = app_handle.get_window("pake").unwrap();
|
||||||
|
match window.is_visible().unwrap() {
|
||||||
|
true => window.hide().unwrap(),
|
||||||
|
false => {
|
||||||
|
window.show().unwrap();
|
||||||
|
window.set_focus().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.expect("Error registering global evoke shortcuts!");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.on_window_event(|event| {
|
.on_window_event(|event| {
|
||||||
|
|||||||
Reference in New Issue
Block a user