feat: update tray tooltip to include reassembled version format #4727

This commit is contained in:
Tunglies
2025-10-09 05:53:49 +08:00
Unverified
parent 57c031a8f8
commit 4417fe6cd9
2 changed files with 19 additions and 12 deletions

4
src-tauri/Cargo.lock generated
View File

@@ -2244,9 +2244,9 @@ dependencies = [
[[package]]
name = "flexi_logger"
version = "0.31.6"
version = "0.31.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec8ef54b052574866f68674c7646369a05dda785cf0ab8e3be94992fd92cd64b"
checksum = "31e5335674a3a259527f97e9176a3767dcc9b220b8e29d643daeb2d6c72caf8b"
dependencies = [
"chrono",
"log",

View File

@@ -412,17 +412,24 @@ impl Tray {
let tun_text = t("TUN").await;
let profile_text = t("Profile").await;
let version = env!("CARGO_PKG_VERSION");
let v = env!("CARGO_PKG_VERSION");
let reassembled_version = v.split_once('+').map_or(v.to_string(), |(main, rest)| {
format!("{main}+{}", rest.split('.').next().unwrap_or(""))
});
let tooltip = format!(
"Clash Verge {}\n{}: {}\n{}: {}\n{}: {}",
reassembled_version,
sys_proxy_text,
switch_map[system_proxy],
tun_text,
switch_map[tun_mode],
profile_text,
current_profile_name
);
if let Some(tray) = app_handle.tray_by_id("main") {
let _ = tray.set_tooltip(Some(&format!(
"Clash Verge {version}\n{}: {}\n{}: {}\n{}: {}",
sys_proxy_text,
switch_map[system_proxy],
tun_text,
switch_map[tun_mode],
profile_text,
current_profile_name
)));
let _ = tray.set_tooltip(Some(&tooltip));
} else {
log::warn!(target: "app", "更新托盘提示失败: 托盘不存在");
}