feat: show tray icon variants in different status (#537)

This commit is contained in:
w568w 2023-05-28 02:55:39 +00:00 committed by GitHub
parent fb653ff99d
commit ef5adab638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 3 deletions

26
src-tauri/Cargo.lock generated
View File

@ -450,6 +450,17 @@ dependencies = [
"uuid 0.8.2",
]
[[package]]
name = "cfb"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f"
dependencies = [
"byteorder",
"fnv",
"uuid 1.3.0",
]
[[package]]
name = "cfg-expr"
version = "0.9.1"
@ -1901,7 +1912,16 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20b2b533137b9cad970793453d4f921c2e91312a6d88b1085c07bc15fc51bb3b"
dependencies = [
"cfb",
"cfb 0.6.1",
]
[[package]]
name = "infer"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f178e61cdbfe084aa75a2f4f7a25a5bb09701a47ae1753608f194b15783c937a"
dependencies = [
"cfb 0.7.3",
]
[[package]]
@ -4141,12 +4161,14 @@ dependencies = [
"heck 0.4.1",
"http",
"ignore",
"infer 0.9.0",
"minisign-verify",
"objc",
"once_cell",
"open 3.4.0",
"os_pipe",
"percent-encoding",
"png",
"rand 0.8.5",
"raw-window-handle",
"regex 1.7.1",
@ -4282,7 +4304,7 @@ dependencies = [
"glob",
"heck 0.4.1",
"html5ever",
"infer",
"infer 0.7.0",
"json-patch",
"kuchiki",
"memchr",

View File

@ -37,7 +37,7 @@ parking_lot = "0.12.0"
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json","rustls-tls"] }
tauri = { version = "1.1.1", features = ["global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
tauri = { version = "1.1.1", features = ["global-shortcut-all", "icon-png", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
tauri-runtime-wry = { version = "0.12" }
window-vibrancy = { version = "0.3.0" }
window-shadows = { version = "0.2.0" }

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -107,6 +107,14 @@ impl Tray {
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
let indication_icon = if *system_proxy {
include_bytes!("../../icons/tray-icon-activated.png").to_vec()
} else {
include_bytes!("../../icons/tray-icon.png").to_vec()
};
tray.set_icon(tauri::Icon::Raw(indication_icon))?;
let _ = tray.get_item("system_proxy").set_selected(*system_proxy);
let _ = tray.get_item("tun_mode").set_selected(*tun_mode);