mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 03:13:44 +08:00
Remove color detection for tray icons
Always use white text with black shadow regardless of icon type
This commit is contained in:
parent
0b8d08d13b
commit
9dfd9bad20
@ -94,13 +94,6 @@ impl SpeedRate {
|
|||||||
image::DynamicImage::new_rgba8(0, 0)
|
image::DynamicImage::new_rgba8(0, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
// 判断是否为彩色图标
|
|
||||||
let is_colorful = if let Some(bytes) = icon_bytes.clone() {
|
|
||||||
!crate::utils::help::is_monochrome_image_from_bytes(&bytes).unwrap_or(false)
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
let total_width = match (is_custom_icon, icon_bytes.is_some()) {
|
let total_width = match (is_custom_icon, icon_bytes.is_some()) {
|
||||||
(true, true) => 510,
|
(true, true) => 510,
|
||||||
(true, false) => 740,
|
(true, false) => 740,
|
||||||
@ -127,19 +120,11 @@ impl SpeedRate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 选择文本颜色
|
// 选择文本颜色
|
||||||
let (text_color, shadow_color) = if is_colorful {
|
|
||||||
// 彩色图标使用黑色文本和轻微白色阴影
|
|
||||||
(
|
|
||||||
Rgba([255u8, 255u8, 255u8, 255u8]),
|
|
||||||
Rgba([0u8, 0u8, 0u8, 160u8]),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// 单色图标使用白色文本和轻微黑色阴影
|
// 单色图标使用白色文本和轻微黑色阴影
|
||||||
(
|
let (text_color, shadow_color) = (
|
||||||
Rgba([255u8, 255u8, 255u8, 255u8]),
|
Rgba([255u8, 255u8, 255u8, 255u8]),
|
||||||
Rgba([0u8, 0u8, 0u8, 120u8]),
|
Rgba([0u8, 0u8, 0u8, 120u8]),
|
||||||
)
|
);
|
||||||
};
|
|
||||||
// 减小字体大小以适应文本区域
|
// 减小字体大小以适应文本区域
|
||||||
let font_data = include_bytes!("../../../assets/fonts/SF-Pro.ttf");
|
let font_data = include_bytes!("../../../assets/fonts/SF-Pro.ttf");
|
||||||
let font = FontArc::try_from_vec(font_data.to_vec()).unwrap();
|
let font = FontArc::try_from_vec(font_data.to_vec()).unwrap();
|
||||||
|
@ -125,18 +125,18 @@ pub fn open_file(_: tauri::AppHandle, path: PathBuf) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
// #[cfg(target_os = "macos")]
|
||||||
pub fn is_monochrome_image_from_bytes(data: &[u8]) -> anyhow::Result<bool> {
|
// pub fn is_monochrome_image_from_bytes(data: &[u8]) -> anyhow::Result<bool> {
|
||||||
let img = image::load_from_memory(data)?;
|
// let img = image::load_from_memory(data)?;
|
||||||
let rgb_img = img.to_rgb8();
|
// let rgb_img = img.to_rgb8();
|
||||||
|
|
||||||
for pixel in rgb_img.pixels() {
|
// for pixel in rgb_img.pixels() {
|
||||||
if pixel[0] != pixel[1] || pixel[1] != pixel[2] {
|
// if pixel[0] != pixel[1] || pixel[1] != pixel[2] {
|
||||||
return Ok(false);
|
// return Ok(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Ok(true)
|
// Ok(true)
|
||||||
}
|
// }
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn linux_elevator() -> String {
|
pub fn linux_elevator() -> String {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user