diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 0f13f1d..6e17ed3 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -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", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c70150d..f5fc319 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -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" } diff --git a/src-tauri/icons/tray-icon-activated.png b/src-tauri/icons/tray-icon-activated.png new file mode 100644 index 0000000..d30d29b Binary files /dev/null and b/src-tauri/icons/tray-icon-activated.png differ diff --git a/src-tauri/src/core/tray.rs b/src-tauri/src/core/tray.rs index 9d1f846..acf9142 100644 --- a/src-tauri/src/core/tray.rs +++ b/src-tauri/src/core/tray.rs @@ -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);