system tray icon

This commit is contained in:
2026-03-27 14:51:25 +08:00
parent a945526808
commit 8a8e77125a
4 changed files with 15 additions and 9 deletions

17
src-tauri/Cargo.lock generated
View File

@@ -1269,6 +1269,7 @@ dependencies = [
"strum",
"tauri",
"tauri-build",
"tauri-macros",
"tauri-plugin-dialog",
"tauri-plugin-global-shortcut",
"tauri-plugin-opener",
@@ -1948,9 +1949,9 @@ dependencies = [
[[package]]
name = "ico"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc50b891e4acf8fe0e71ef88ec43ad82ee07b3810ad09de10f1d01f072ed4b98"
checksum = "3e795dff5605e0f04bff85ca41b51a96b83e80b281e96231bcaaf1ac35103371"
dependencies = [
"byteorder",
"png",
@@ -4734,9 +4735,9 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "2.5.1"
version = "2.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7ef707148f0755110ca54377560ab891d722de4d53297595380a748026f139f"
checksum = "d4a24476afd977c5d5d169f72425868613d82747916dd29e0a357c84c4bd6d29"
dependencies = [
"base64 0.22.1",
"brotli",
@@ -4761,9 +4762,9 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "2.5.1"
version = "2.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71664fd715ee6e382c05345ad258d6d1d50f90cf1b58c0aa726638b33c2a075d"
checksum = "d39b349a98dadaffebb73f0a40dcd1f23c999211e5a2e744403db384d0c33de7"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@@ -5006,9 +5007,9 @@ dependencies = [
[[package]]
name = "tauri-utils"
version = "2.8.0"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6b8bbe426abdbf52d050e52ed693130dbd68375b9ad82a3fb17efb4c8d85673"
checksum = "219a1f983a2af3653f75b5747f76733b0da7ff03069c7a41901a5eb3ace4557d"
dependencies = [
"anyhow",
"brotli",

View File

@@ -50,6 +50,7 @@ enigo = { version = "0.6.1", features = ["wayland"] }
lazy_static = "1.5.0"
mlua = { version = "0.11", default-features = false, features = ["lua54", "vendored", "serde", "async"] }
petpet = "2.4.3"
tauri-macros = "2.5.5"
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-global-shortcut = "2"
tauri-plugin-positioner = "2"

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

View File

@@ -2,11 +2,15 @@ use crate::{
get_app_handle, lock_r, lock_w, services::app_menu::open_app_menu_window, state::FDOLL,
};
use tauri::{
image::Image,
include_image,
menu::{Menu, MenuItem},
tray::TrayIconBuilder,
};
use tracing::error;
const TRAY_ICON: Image<'_> = include_image!("./icons/icon.tray.png");
/// Constructs app system tray.
/// Uses Tauri.
pub fn init_system_tray() {
@@ -34,7 +38,7 @@ pub fn init_system_tray() {
error!("menu item {:?} not handled", event.id);
}
})
.icon(app.default_window_icon().unwrap().clone())
.icon(TRAY_ICON)
.build(app)
.unwrap_or_else(|err| panic!("Failed to build tray: {}", err));
{