pake-cli 3.0.3 → 3.1.0

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.
Files changed (61) hide show
  1. package/dist/cli.js +14 -14
  2. package/dist/dev.js +6 -5
  3. package/dist/dev.js.map +1 -1
  4. package/package.json +2 -2
  5. package/src-tauri/.pake/pake.json +30 -0
  6. package/src-tauri/.pake/tauri.conf.json +24 -0
  7. package/src-tauri/.pake/tauri.macos.conf.json +15 -0
  8. package/src-tauri/Cargo.lock +180 -20
  9. package/src-tauri/Cargo.toml +6 -6
  10. package/src-tauri/capabilities/default.json +7 -1
  11. package/src-tauri/gen/schemas/acl-manifests.json +1 -1
  12. package/src-tauri/gen/schemas/capabilities.json +1 -1
  13. package/src-tauri/gen/schemas/desktop-schema.json +165 -0
  14. package/src-tauri/gen/schemas/macOS-schema.json +165 -0
  15. package/src-tauri/icons/excalidraw.icns +0 -0
  16. package/src-tauri/icons/gemini.icns +0 -0
  17. package/src-tauri/icons/xiaohongshu.icns +0 -0
  18. package/src-tauri/png/chatgpt_512.png +0 -0
  19. package/src-tauri/png/excalidraw_256.ico +0 -0
  20. package/src-tauri/png/excalidraw_32.ico +0 -0
  21. package/src-tauri/png/excalidraw_512.png +0 -0
  22. package/src-tauri/png/flomo_512.png +0 -0
  23. package/src-tauri/png/gemini_256.ico +0 -0
  24. package/src-tauri/png/gemini_32.ico +0 -0
  25. package/src-tauri/png/gemini_512.png +0 -0
  26. package/src-tauri/png/icon_512.png +0 -0
  27. package/src-tauri/png/lizhi_512.png +0 -0
  28. package/src-tauri/png/programmusic_512.png +0 -0
  29. package/src-tauri/png/qwerty_512.png +0 -0
  30. package/src-tauri/png/twitter_512.png +0 -0
  31. package/src-tauri/png/wechat_512.png +0 -0
  32. package/src-tauri/png/weread_512.png +0 -0
  33. package/src-tauri/png/xiaohongshu_256.ico +0 -0
  34. package/src-tauri/png/xiaohongshu_32.ico +0 -0
  35. package/src-tauri/png/xiaohongshu_512.png +0 -0
  36. package/src-tauri/png/youtube_512.png +0 -0
  37. package/src-tauri/png/youtubemusic_512.png +0 -0
  38. package/src-tauri/src/app/invoke.rs +20 -0
  39. package/src-tauri/src/app/mod.rs +1 -1
  40. package/src-tauri/src/app/setup.rs +95 -0
  41. package/src-tauri/src/app/window.rs +6 -2
  42. package/src-tauri/src/inject/event.js +32 -1
  43. package/src-tauri/src/inject/style.js +12 -4
  44. package/src-tauri/src/lib.rs +34 -87
  45. package/src-tauri/src/util.rs +1 -2
  46. package/src-tauri/icons/coderunner.icns +0 -0
  47. package/src-tauri/icons/devv.icns +0 -0
  48. package/src-tauri/icons/juchats.icns +0 -0
  49. package/src-tauri/icons/poe.icns +0 -0
  50. package/src-tauri/icons/reference.icns +0 -0
  51. package/src-tauri/icons/xiaoyuzhou.icns +0 -0
  52. package/src-tauri/png/coderunner_256.ico +0 -0
  53. package/src-tauri/png/coderunner_32.ico +0 -0
  54. package/src-tauri/png/coderunner_512.png +0 -0
  55. package/src-tauri/png/poe_256.ico +0 -0
  56. package/src-tauri/png/poe_32.ico +0 -0
  57. package/src-tauri/png/poe_512.png +0 -0
  58. package/src-tauri/png/reference_256.ico +0 -0
  59. package/src-tauri/png/reference_32.ico +0 -0
  60. package/src-tauri/png/reference_512.png +0 -0
  61. package/src-tauri/src/app/menu.rs +0 -36
@@ -2,120 +2,67 @@
2
2
  mod app;
3
3
  mod util;
4
4
 
5
- use app::{invoke, menu::set_system_tray, window};
6
- use invoke::{download_file, download_file_by_binary};
7
- use std::str::FromStr;
8
- use std::sync::{Arc, Mutex};
9
- use std::time::{Duration, Instant};
10
-
5
+ use std::time::Duration;
11
6
  use tauri::Manager;
12
- use tauri_plugin_global_shortcut::{GlobalShortcutExt, Shortcut};
13
- use tauri_plugin_window_state::Builder as windowStatePlugin;
14
- use util::{get_data_dir, get_pake_config};
15
- use window::get_window;
7
+ use tauri_plugin_window_state::Builder as WindowStatePlugin;
8
+ use tauri_plugin_window_state::StateFlags;
9
+
10
+ use app::{
11
+ invoke::{download_file, download_file_by_binary, send_notification},
12
+ setup::{set_global_shortcut, set_system_tray},
13
+ window::set_window,
14
+ };
15
+ use util::get_pake_config;
16
16
 
17
17
  pub fn run_app() {
18
18
  let (pake_config, tauri_config) = get_pake_config();
19
-
20
19
  let tauri_app = tauri::Builder::default();
21
20
 
22
21
  let show_system_tray = pake_config.show_system_tray();
23
-
24
- // Save the value of toggle_app_shortcut before pake_config is moved
25
22
  let activation_shortcut = pake_config.windows[0].activation_shortcut.clone();
26
23
  let init_fullscreen = pake_config.windows[0].fullscreen;
27
24
 
28
- let window_state_plugin = if init_fullscreen {
29
- windowStatePlugin::default()
30
- .with_state_flags(tauri_plugin_window_state::StateFlags::FULLSCREEN)
31
- .build()
32
- } else {
33
- windowStatePlugin::default().build()
34
- };
25
+ let window_state_plugin = WindowStatePlugin::default()
26
+ .with_state_flags(if init_fullscreen {
27
+ StateFlags::FULLSCREEN
28
+ } else {
29
+ // Prevent flickering on the first open.
30
+ StateFlags::all() & !StateFlags::VISIBLE
31
+ })
32
+ .build();
35
33
 
36
34
  tauri_app
37
35
  .plugin(window_state_plugin)
38
36
  .plugin(tauri_plugin_oauth::init())
39
37
  .plugin(tauri_plugin_http::init())
40
38
  .plugin(tauri_plugin_shell::init())
39
+ .plugin(tauri_plugin_notification::init())
41
40
  .plugin(tauri_plugin_single_instance::init(|_, _, _| ()))
42
41
  .invoke_handler(tauri::generate_handler![
43
42
  download_file,
44
- download_file_by_binary
43
+ download_file_by_binary,
44
+ send_notification,
45
45
  ])
46
46
  .setup(move |app| {
47
- let data_dir = get_data_dir(app.app_handle(), tauri_config.clone());
48
-
49
- let _window = get_window(app, &pake_config, data_dir);
50
-
51
- // Prevent initial shaking
52
- _window.show().unwrap();
53
-
54
- if show_system_tray {
55
- let _ = set_system_tray(app.app_handle());
56
- } else {
57
- app.app_handle().remove_tray_by_id("pake-tray");
58
- }
59
-
60
- if !activation_shortcut.is_empty() {
61
- let app_handle = app.app_handle().clone();
62
- let shortcut_hotkey = Shortcut::from_str(activation_shortcut.as_str()).unwrap();
63
- let last_triggered = Arc::new(Mutex::new(Instant::now()));
64
-
65
- app_handle
66
- .plugin(
67
- tauri_plugin_global_shortcut::Builder::new()
68
- .with_handler({
69
- let last_triggered = Arc::clone(&last_triggered);
70
- move |app, event, _shortcut| {
71
- // Fixed the bug of tauri's hidden call, which caused repeated execution
72
- let now = Instant::now();
73
- let mut last = last_triggered.lock().unwrap();
74
- if now.duration_since(*last) < Duration::from_millis(500) {
75
- return;
76
- }
77
- *last = now;
78
-
79
- if shortcut_hotkey.eq(event) {
80
- let window = app.get_webview_window("pake").unwrap();
81
- let is_visible = window.is_visible().unwrap();
82
-
83
- match is_visible {
84
- true => {
85
- window.minimize().unwrap();
86
- }
87
- false => {
88
- window.unminimize().unwrap();
89
- window.set_focus().unwrap();
90
- }
91
- }
92
- }
93
- }
94
- })
95
- .build(),
96
- )
97
- .expect("Error registering global evoke shortcuts!");
98
-
99
- app.global_shortcut().register(shortcut_hotkey)?;
100
- }
101
-
47
+ let window = set_window(app, &pake_config, &tauri_config);
48
+ set_system_tray(app.app_handle(), show_system_tray).unwrap();
49
+ set_global_shortcut(app.app_handle(), activation_shortcut).unwrap();
50
+ // Prevent flickering on the first open.
51
+ window.show().unwrap();
102
52
  Ok(())
103
53
  })
104
54
  .on_window_event(|_window, _event| {
105
55
  #[cfg(target_os = "macos")]
106
56
  if let tauri::WindowEvent::CloseRequested { api, .. } = _event {
107
57
  let window = _window.clone();
108
- {
109
- tauri::async_runtime::spawn(async move {
110
- if window.is_fullscreen().unwrap_or(false) {
111
- window.set_fullscreen(false).unwrap();
112
- // Give a small delay to ensure the full-screen exit operation is completed.
113
- tokio::time::sleep(Duration::from_millis(900)).await;
114
- }
115
- window.minimize().unwrap();
116
- window.hide().unwrap();
117
- });
118
- }
58
+ tauri::async_runtime::spawn(async move {
59
+ if window.is_fullscreen().unwrap_or(false) {
60
+ window.set_fullscreen(false).unwrap();
61
+ tokio::time::sleep(Duration::from_millis(900)).await;
62
+ }
63
+ window.minimize().unwrap();
64
+ window.hide().unwrap();
65
+ });
119
66
  api.prevent_close();
120
67
  }
121
68
  })
@@ -23,9 +23,8 @@ pub fn get_pake_config() -> (PakeConfig, Config) {
23
23
  (pake_config, tauri_config)
24
24
  }
25
25
 
26
- pub fn get_data_dir(app: &AppHandle, _tauri_config: Config) -> PathBuf {
26
+ pub fn get_data_dir(app: &AppHandle, package_name: String) -> PathBuf {
27
27
  {
28
- let package_name = _tauri_config.product_name.unwrap();
29
28
  let data_dir = app
30
29
  .path()
31
30
  .config_dir()
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,36 +0,0 @@
1
- use tauri::{
2
- menu::{MenuBuilder, MenuItemBuilder},
3
- tray::TrayIconBuilder,
4
- AppHandle, Manager,
5
- };
6
- use tauri_plugin_window_state::{AppHandleExt, StateFlags};
7
-
8
- pub fn set_system_tray(app: &AppHandle) -> tauri::Result<()> {
9
- let hide_app = MenuItemBuilder::with_id("hide_app", "Hide").build(app)?;
10
- let show_app = MenuItemBuilder::with_id("show_app", "Show").build(app)?;
11
- let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
12
- let menu = MenuBuilder::new(app)
13
- .items(&[&hide_app, &show_app, &quit])
14
- .build()?;
15
- app.app_handle().remove_tray_by_id("pake-tray");
16
- let tray = TrayIconBuilder::new()
17
- .menu(&menu)
18
- .on_menu_event(move |app, event| match event.id().as_ref() {
19
- "hide_app" => {
20
- app.get_webview_window("pake").unwrap().minimize().unwrap();
21
- }
22
- "show_app" => {
23
- app.get_webview_window("pake").unwrap().show().unwrap();
24
- }
25
- "quit" => {
26
- let _res = app.save_window_state(StateFlags::all());
27
- std::process::exit(0);
28
- }
29
- _ => (),
30
- })
31
- .icon(app.default_window_icon().unwrap().clone())
32
- .build(app)?;
33
-
34
- tray.set_icon_as_template(false)?;
35
- Ok(())
36
- }