Skip to content

Commit 2676e4f

Browse files
committed
Merge branch 'master' into release
2 parents 326e908 + 30494ed commit 2676e4f

17 files changed

Lines changed: 340 additions & 109 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,7 @@ cython_debug/
210210

211211
# PyPI configuration file
212212
.pypirc
213+
214+
# CLAUDE
215+
CLAUDE.md
216+
.claude/

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@mediapipe/tasks-vision": "^0.10.22-rc.20250304",
2121
"@tauri-apps/api": "^2",
2222
"@tauri-apps/plugin-autostart": "^2.2.0",
23+
"@tauri-apps/plugin-http": "^2.5.6",
2324
"@tauri-apps/plugin-notification": "^2.2.2",
2425
"@tauri-apps/plugin-opener": "^2.2.6",
2526
"@tauri-apps/plugin-process": "^2.3.0",

pnpm-lock.yaml

Lines changed: 15 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ crate-type = ["staticlib", "cdylib", "rlib"]
1818
tauri-build = { version = "2", features = [] }
1919

2020
[dependencies]
21-
tauri = { version = "2", features = ["devtools"] }
21+
tauri = { version = "2", features = ["devtools", "tray-icon"] }
2222
tauri-plugin-opener = "2"
2323
serde = { version = "1", features = ["derive"] }
2424
serde_json = "1"
2525
tauri-plugin-shell = "2"
2626
tauri-plugin-store = "2"
2727
tauri-plugin-notification = "2"
2828
tauri-plugin-process = "2"
29+
tauri-plugin-http = "2"
2930

3031
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
3132
tauri-plugin-autostart = "2"

src-tauri/capabilities/default.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939
"core:window:allow-set-size",
4040

4141
"updater:default",
42-
"process:default"
42+
"process:default",
43+
44+
{
45+
"identifier": "http:default",
46+
"allow": [
47+
{ "url": "http://localhost:62334/*" }
48+
]
49+
},
50+
"http:allow-fetch"
4351
]
4452
}

src-tauri/src/lib.rs

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ async fn run_sidecar(app: tauri::AppHandle) -> Result<String, String> {
2424
start_sidecar(app).await
2525
}
2626

27+
use tauri::menu::{Menu, MenuItem};
28+
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
29+
use tauri::{Emitter, Manager};
2730
use tauri_plugin_autostart::MacosLauncher;
28-
use tauri_plugin_autostart::ManagerExt;
29-
use tauri_plugin_shell::process::CommandEvent;
3031
use tauri_plugin_shell::ShellExt;
3132

3233
#[cfg_attr(mobile, tauri::mobile_entry_point)]
@@ -43,6 +44,7 @@ pub fn run() {
4344
))
4445
.plugin(tauri_plugin_shell::init())
4546
.plugin(tauri_plugin_opener::init())
47+
.plugin(tauri_plugin_http::init())
4648
.setup(|app| {
4749
// 在应用启动时自动启动sidecar
4850
let app_handle = app.handle().clone();
@@ -52,6 +54,46 @@ pub fn run() {
5254
Err(e) => eprintln!("启动sidecar失败: {}", e),
5355
}
5456
});
57+
58+
// 创建系统托盘
59+
let show_item = MenuItem::with_id(app, "show", "显示窗口", true, None::<&str>)?;
60+
let quit_item = MenuItem::with_id(app, "quit", "退出", true, None::<&str>)?;
61+
let menu = Menu::with_items(app, &[&show_item, &quit_item])?;
62+
63+
let _tray = TrayIconBuilder::new()
64+
.icon(app.default_window_icon().unwrap().clone())
65+
.menu(&menu)
66+
.show_menu_on_left_click(false)
67+
.on_menu_event(|app, event| match event.id.as_ref() {
68+
"show" => {
69+
if let Some(window) = app.get_webview_window("main") {
70+
let _ = window.show();
71+
let _ = window.unminimize();
72+
let _ = window.set_focus();
73+
}
74+
}
75+
"quit" => {
76+
let _ = app.emit("tray-quit-requested", ());
77+
}
78+
_ => {}
79+
})
80+
.on_tray_icon_event(|tray, event| {
81+
if let TrayIconEvent::Click {
82+
button: MouseButton::Left,
83+
button_state: MouseButtonState::Up,
84+
..
85+
} = event
86+
{
87+
let app = tray.app_handle();
88+
if let Some(window) = app.get_webview_window("main") {
89+
let _ = window.show();
90+
let _ = window.unminimize();
91+
let _ = window.set_focus();
92+
}
93+
}
94+
})
95+
.build(app)?;
96+
5597
Ok(())
5698
})
5799
.invoke_handler(tauri::generate_handler![greet, run_sidecar])

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "Lazyeat",
4-
"version": "1.1.4",
4+
"version": "1.1.5",
55
"identifier": "com.Lazyeat.maplelost",
66
"build": {
77
"beforeDevCommand": "npm run dev",

0 commit comments

Comments
 (0)