pake-cli 2.3.7 → 2.4.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +27 -15
- package/dist/dev.js +644 -639
- package/dist/dev.js.map +1 -1
- package/package.json +4 -3
- package/src-tauri/.pake/pake.json +29 -0
- package/src-tauri/.pake/tauri.conf.json +75 -0
- package/src-tauri/.pake/tauri.macos.conf.json +29 -0
- package/src-tauri/Cargo.lock +193 -143
- package/src-tauri/Cargo.toml +5 -5
- package/src-tauri/pake.json +4 -1
- package/src-tauri/rust_proxy.toml +1 -5
- package/src-tauri/src/app/config.rs +7 -4
- package/src-tauri/src/app/menu.rs +1 -1
- package/src-tauri/src/app/window.rs +7 -6
- package/src-tauri/src/inject/event.js +11 -9
- package/src-tauri/src/inject/style.js +1 -1
- package/src-tauri/src/main.rs +26 -4
- package/src-tauri/src/util.rs +3 -0
package/src-tauri/Cargo.toml
CHANGED
|
@@ -7,17 +7,17 @@ license = "MIT"
|
|
|
7
7
|
repository = "https://github.com/tw93/Pake"
|
|
8
8
|
default-run = "app"
|
|
9
9
|
edition = "2021"
|
|
10
|
-
rust-version = "1.
|
|
10
|
+
rust-version = "1.78.0"
|
|
11
11
|
|
|
12
12
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
13
13
|
|
|
14
14
|
[build-dependencies]
|
|
15
|
-
tauri-build = { version = "1.5.
|
|
15
|
+
tauri-build = { version = "1.5.2", features = [] }
|
|
16
16
|
|
|
17
17
|
[dependencies]
|
|
18
|
-
serde_json = "1.0.
|
|
19
|
-
serde = { version = "1.0.
|
|
20
|
-
tauri = { version = "1.
|
|
18
|
+
serde_json = "1.0.116"
|
|
19
|
+
serde = { version = "1.0.200", features = ["derive"] }
|
|
20
|
+
tauri = { version = "1.6.3", features = ["api-all", "system-tray"] }
|
|
21
21
|
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
|
22
22
|
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "main" }
|
|
23
23
|
|
package/src-tauri/pake.json
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
"windows": [
|
|
3
3
|
{
|
|
4
4
|
"url": "https://weread.qq.com",
|
|
5
|
+
"url_type": "web",
|
|
5
6
|
"transparent": true,
|
|
6
7
|
"fullscreen": false,
|
|
7
8
|
"width": 1200,
|
|
8
9
|
"height": 780,
|
|
9
10
|
"resizable": true,
|
|
10
|
-
"
|
|
11
|
+
"always_on_top": false,
|
|
12
|
+
"activation_shortcut": "",
|
|
13
|
+
"disabled_web_shortcuts": false
|
|
11
14
|
}
|
|
12
15
|
],
|
|
13
16
|
"user_agent": {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
[source.crates-io]
|
|
2
|
-
|
|
3
|
-
replace-with = 'rsproxy'
|
|
4
|
-
|
|
2
|
+
replace-with = 'rsproxy-sparse'
|
|
5
3
|
[source.rsproxy]
|
|
6
4
|
registry = "https://rsproxy.cn/crates.io-index"
|
|
7
5
|
[source.rsproxy-sparse]
|
|
8
6
|
registry = "sparse+https://rsproxy.cn/index/"
|
|
9
|
-
|
|
10
7
|
[registries.rsproxy]
|
|
11
8
|
index = "https://rsproxy.cn/crates.io-index"
|
|
12
|
-
|
|
13
9
|
[net]
|
|
14
10
|
git-fetch-with-cli = true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
use serde::Deserialize;
|
|
1
|
+
use serde::{Deserialize, Serialize};
|
|
2
2
|
|
|
3
|
-
#[derive(Debug, Deserialize)]
|
|
3
|
+
#[derive(Debug, Serialize, Deserialize)]
|
|
4
4
|
pub struct WindowConfig {
|
|
5
5
|
pub url: String,
|
|
6
6
|
pub transparent: bool,
|
|
@@ -9,9 +9,12 @@ pub struct WindowConfig {
|
|
|
9
9
|
pub height: f64,
|
|
10
10
|
pub resizable: bool,
|
|
11
11
|
pub url_type: String,
|
|
12
|
+
pub always_on_top: bool,
|
|
13
|
+
pub disabled_web_shortcuts: bool,
|
|
14
|
+
pub activation_shortcut: String,
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
#[derive(Debug, Deserialize)]
|
|
17
|
+
#[derive(Debug, Serialize, Deserialize)]
|
|
15
18
|
pub struct PlatformSpecific<T> {
|
|
16
19
|
pub macos: T,
|
|
17
20
|
pub linux: T,
|
|
@@ -43,7 +46,7 @@ where
|
|
|
43
46
|
pub type UserAgent = PlatformSpecific<String>;
|
|
44
47
|
pub type FunctionON = PlatformSpecific<bool>;
|
|
45
48
|
|
|
46
|
-
#[derive(Debug, Deserialize)]
|
|
49
|
+
#[derive(Debug, Serialize, Deserialize)]
|
|
47
50
|
pub struct PakeConfig {
|
|
48
51
|
pub windows: Vec<WindowConfig>,
|
|
49
52
|
pub user_agent: UserAgent,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use tauri::{CustomMenuItem,Manager, SystemTray, SystemTrayEvent, SystemTrayMenu};
|
|
1
|
+
use tauri::{CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu};
|
|
2
2
|
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
|
3
3
|
|
|
4
4
|
pub fn get_system_tray() -> SystemTray {
|
|
@@ -19,6 +19,11 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
|
|
19
19
|
_ => panic!("url type can only be web or local"),
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
let config_script = format!(
|
|
23
|
+
"window.pakeConfig = {}",
|
|
24
|
+
serde_json::to_string(&window_config).unwrap()
|
|
25
|
+
);
|
|
26
|
+
|
|
22
27
|
let mut window_builder = WindowBuilder::new(app, "pake", url)
|
|
23
28
|
.title("")
|
|
24
29
|
.user_agent(user_agent)
|
|
@@ -27,18 +32,14 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
|
|
27
32
|
.fullscreen(window_config.fullscreen)
|
|
28
33
|
.inner_size(window_config.width, window_config.height)
|
|
29
34
|
.disable_file_drop_handler()
|
|
35
|
+
.always_on_top(window_config.always_on_top)
|
|
36
|
+
.initialization_script(&config_script)
|
|
30
37
|
.initialization_script(include_str!("../inject/component.js"))
|
|
31
38
|
.initialization_script(include_str!("../inject/event.js"))
|
|
32
39
|
.initialization_script(include_str!("../inject/style.js"))
|
|
33
40
|
//This is necessary to allow for file injection by external developers for customization purposes.
|
|
34
41
|
.initialization_script(include_str!("../inject/custom.js"));
|
|
35
42
|
|
|
36
|
-
// For dynamic display of header styles
|
|
37
|
-
if window_config.transparent {
|
|
38
|
-
let transparent_script = "window.pakeWindowTitleTransparent = true;";
|
|
39
|
-
window_builder = window_builder.initialization_script(transparent_script);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
43
|
#[cfg(target_os = "macos")]
|
|
43
44
|
{
|
|
44
45
|
let title_bar_style = if window_config.transparent {
|
|
@@ -63,7 +63,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
63
63
|
const appWindow = tauri.window.appWindow;
|
|
64
64
|
const invoke = tauri.tauri.invoke;
|
|
65
65
|
|
|
66
|
-
if(!document.getElementById('pake-top-dom')){
|
|
66
|
+
if (!document.getElementById('pake-top-dom')) {
|
|
67
67
|
const topDom = document.createElement('div');
|
|
68
68
|
topDom.id = 'pake-top-dom';
|
|
69
69
|
document.body.appendChild(topDom);
|
|
@@ -88,14 +88,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
if (window['pakeConfig']?.disabled_web_shortcuts !== true) {
|
|
92
|
+
document.addEventListener('keyup', (event) => {
|
|
93
|
+
if (/windows|linux/i.test(navigator.userAgent) && event.ctrlKey) {
|
|
94
|
+
handleShortcut(event);
|
|
95
|
+
}
|
|
96
|
+
if (/macintosh|mac os x/i.test(navigator.userAgent) && event.metaKey) {
|
|
97
|
+
handleShortcut(event);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
99
101
|
|
|
100
102
|
// Collect blob urls to blob by overriding window.URL.createObjectURL
|
|
101
103
|
function collectUrlToBlobs() {
|
|
@@ -412,7 +412,7 @@ window.addEventListener('DOMContentLoaded', _event => {
|
|
|
412
412
|
}
|
|
413
413
|
`;
|
|
414
414
|
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
415
|
-
if (window
|
|
415
|
+
if (window['pakeConfig']?.transparent && isMac) {
|
|
416
416
|
const topPaddingStyleElement = document.createElement('style');
|
|
417
417
|
topPaddingStyleElement.innerHTML = topPaddingCSS;
|
|
418
418
|
document.head.appendChild(topPaddingStyleElement);
|
package/src-tauri/src/main.rs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#![cfg_attr(
|
|
2
|
-
all(not(debug_assertions), target_os = "windows"),
|
|
3
|
-
windows_subsystem = "windows"
|
|
2
|
+
all(not(debug_assertions), target_os = "windows"),
|
|
3
|
+
windows_subsystem = "windows"
|
|
4
4
|
)]
|
|
5
5
|
|
|
6
6
|
mod app;
|
|
7
7
|
mod util;
|
|
8
8
|
|
|
9
|
-
use app::{invoke,
|
|
9
|
+
use app::{invoke, menu, window};
|
|
10
10
|
use invoke::{download_file, download_file_by_binary};
|
|
11
11
|
use menu::{get_system_tray, system_tray_handle};
|
|
12
|
+
use tauri::{GlobalShortcutManager, Manager};
|
|
12
13
|
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
|
13
14
|
use util::{get_data_dir, get_pake_config};
|
|
14
15
|
use window::get_window;
|
|
@@ -28,6 +29,9 @@ pub fn run_app() {
|
|
|
28
29
|
.on_system_tray_event(system_tray_handle);
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
// Save the value of toggle_app_shortcut before pake_config is moved
|
|
33
|
+
let activation_shortcut = pake_config.windows[0].activation_shortcut.clone();
|
|
34
|
+
|
|
31
35
|
tauri_app
|
|
32
36
|
.plugin(windowStatePlugin::default().build())
|
|
33
37
|
.plugin(tauri_plugin_oauth::init())
|
|
@@ -35,10 +39,28 @@ pub fn run_app() {
|
|
|
35
39
|
download_file,
|
|
36
40
|
download_file_by_binary
|
|
37
41
|
])
|
|
38
|
-
.setup(|app| {
|
|
42
|
+
.setup(move |app| {
|
|
39
43
|
let _window = get_window(app, pake_config, data_dir);
|
|
40
44
|
// Prevent initial shaking
|
|
41
45
|
_window.show().unwrap();
|
|
46
|
+
|
|
47
|
+
if !activation_shortcut.is_empty() {
|
|
48
|
+
let app_handle = app.app_handle().clone();
|
|
49
|
+
app_handle
|
|
50
|
+
.global_shortcut_manager()
|
|
51
|
+
.register(activation_shortcut.as_str(), move || {
|
|
52
|
+
let window = app_handle.get_window("pake").unwrap();
|
|
53
|
+
match window.is_visible().unwrap() {
|
|
54
|
+
true => window.hide().unwrap(),
|
|
55
|
+
false => {
|
|
56
|
+
window.show().unwrap();
|
|
57
|
+
window.set_focus().unwrap();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.expect("Error registering global evoke shortcuts!");
|
|
62
|
+
}
|
|
63
|
+
|
|
42
64
|
Ok(())
|
|
43
65
|
})
|
|
44
66
|
.on_window_event(|event| {
|
package/src-tauri/src/util.rs
CHANGED
|
@@ -7,12 +7,15 @@ pub fn get_pake_config() -> (PakeConfig, Config) {
|
|
|
7
7
|
#[cfg(feature = "cli-build")]
|
|
8
8
|
let pake_config: PakeConfig = serde_json::from_str(include_str!("../.pake/pake.json"))
|
|
9
9
|
.expect("Failed to parse pake config");
|
|
10
|
+
|
|
10
11
|
#[cfg(not(feature = "cli-build"))]
|
|
11
12
|
let pake_config: PakeConfig =
|
|
12
13
|
serde_json::from_str(include_str!("../pake.json")).expect("Failed to parse pake config");
|
|
14
|
+
|
|
13
15
|
#[cfg(feature = "cli-build")]
|
|
14
16
|
let tauri_config: Config = serde_json::from_str(include_str!("../.pake/tauri.conf.json"))
|
|
15
17
|
.expect("Failed to parse tauri config");
|
|
18
|
+
|
|
16
19
|
#[cfg(not(feature = "cli-build"))]
|
|
17
20
|
let tauri_config: Config = serde_json::from_str(include_str!("../tauri.conf.json"))
|
|
18
21
|
.expect("Failed to parse tauri config");
|