Simplify tray icon template logic and adjust text colors

This commit is contained in:
Tunglies 2025-04-05 19:54:32 +08:00
parent 0b8d08d13b
commit 98de91771e
2 changed files with 5 additions and 10 deletions

View File

@ -309,13 +309,8 @@ impl Tray {
let rate = rate_guard.as_ref(); let rate = rate_guard.as_ref();
let rate_bytes = SpeedRate::add_speed_text(is_custom_icon, bytes, rate).unwrap(); let rate_bytes = SpeedRate::add_speed_text(is_custom_icon, bytes, rate).unwrap();
let _ = tray.set_icon(Some(tauri::image::Image::from_bytes(&rate_bytes)?)); let _ = tray.set_icon(Some(tauri::image::Image::from_bytes(&rate_bytes)?));
if !is_custom_icon { let _ = tray.set_icon_as_template(!is_custom_icon && !is_colorful);
let _ = tray.set_icon_as_template(!is_colorful);
} else {
let _ = tray.set_icon_as_template(false);
}
} }
Ok(()) Ok(())
} }

View File

@ -128,16 +128,16 @@ impl SpeedRate {
// 选择文本颜色 // 选择文本颜色
let (text_color, shadow_color) = if is_colorful { let (text_color, shadow_color) = if is_colorful {
// 彩色图标使用黑色文本和轻微白色阴影
( (
// Rgba([0u8, 0u8, 0u8, 255u8]),
// Rgba([255u8, 255u8, 255u8, 128u8]),
Rgba([255u8, 255u8, 255u8, 255u8]), Rgba([255u8, 255u8, 255u8, 255u8]),
Rgba([0u8, 0u8, 0u8, 160u8]), Rgba([0u8, 0u8, 0u8, 08u8]),
) )
} else { } else {
// 单色图标使用白色文本和轻微黑色阴影
( (
Rgba([255u8, 255u8, 255u8, 255u8]), Rgba([255u8, 255u8, 255u8, 255u8]),
Rgba([0u8, 0u8, 0u8, 120u8]), Rgba([0u8, 0u8, 0u8, 128u8]),
) )
}; };
// 减小字体大小以适应文本区域 // 减小字体大小以适应文本区域