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", "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]] [[package]]
name = "cfg-expr" name = "cfg-expr"
version = "0.9.1" version = "0.9.1"
@ -1901,7 +1912,16 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20b2b533137b9cad970793453d4f921c2e91312a6d88b1085c07bc15fc51bb3b" checksum = "20b2b533137b9cad970793453d4f921c2e91312a6d88b1085c07bc15fc51bb3b"
dependencies = [ 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]] [[package]]
@ -4141,12 +4161,14 @@ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"http", "http",
"ignore", "ignore",
"infer 0.9.0",
"minisign-verify", "minisign-verify",
"objc", "objc",
"once_cell", "once_cell",
"open 3.4.0", "open 3.4.0",
"os_pipe", "os_pipe",
"percent-encoding", "percent-encoding",
"png",
"rand 0.8.5", "rand 0.8.5",
"raw-window-handle", "raw-window-handle",
"regex 1.7.1", "regex 1.7.1",
@ -4282,7 +4304,7 @@ dependencies = [
"glob", "glob",
"heck 0.4.1", "heck 0.4.1",
"html5ever", "html5ever",
"infer", "infer 0.7.0",
"json-patch", "json-patch",
"kuchiki", "kuchiki",
"memchr", "memchr",

View File

@ -37,7 +37,7 @@ parking_lot = "0.12.0"
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json","rustls-tls"] } 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" } tauri-runtime-wry = { version = "0.12" }
window-vibrancy = { version = "0.3.0" } window-vibrancy = { version = "0.3.0" }
window-shadows = { version = "0.2.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 system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
let tun_mode = verge.enable_tun_mode.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("system_proxy").set_selected(*system_proxy);
let _ = tray.get_item("tun_mode").set_selected(*tun_mode); let _ = tray.get_item("tun_mode").set_selected(*tun_mode);