feat: Support different tray icon for linux

This commit is contained in:
MystiPanda 2023-12-09 11:03:19 +08:00
parent f9b716201f
commit ffaa06560e
9 changed files with 66 additions and 45 deletions

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -135,21 +135,18 @@ 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);
#[cfg(target_os = "windows")] let mut indication_icon = if *system_proxy {
{ include_bytes!("../../icons/tray-icon-activated.png").to_vec()
let mut indication_icon = if *system_proxy { } else {
include_bytes!("../../icons/win-tray-icon-activated.png").to_vec() include_bytes!("../../icons/tray-icon.png").to_vec()
} else { };
include_bytes!("../../icons/win-tray-icon.png").to_vec()
};
if *tun_mode { if *tun_mode {
indication_icon = include_bytes!("../../icons/win-tray-icon-tun.png").to_vec(); indication_icon = include_bytes!("../../icons/tray-icon-tun.png").to_vec();
}
let _ = tray.set_icon(tauri::Icon::Raw(indication_icon));
} }
let _ = 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);
@ -160,7 +157,6 @@ impl Tray {
map map
}; };
#[cfg(not(target_os = "linux"))]
let _ = tray.set_tooltip(&format!( let _ = tray.set_tooltip(&format!(
"Clash Verge {version}\n{}: {}\n{}: {}", "Clash Verge {version}\n{}: {}\n{}: {}",
t!("System Proxy", "系统代理"), t!("System Proxy", "系统代理"),
@ -185,7 +181,6 @@ impl Tray {
pub fn on_system_tray_event(app_handle: &AppHandle, event: SystemTrayEvent) { pub fn on_system_tray_event(app_handle: &AppHandle, event: SystemTrayEvent) {
match event { match event {
#[cfg(not(target_os = "linux"))]
SystemTrayEvent::LeftClick { .. } => Tray::on_left_click(app_handle), SystemTrayEvent::LeftClick { .. } => Tray::on_left_click(app_handle),
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() { SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
mode @ ("rule_mode" | "global_mode" | "direct_mode" | "script_mode") => { mode @ ("rule_mode" | "global_mode" | "direct_mode" | "script_mode") => {

View File

@ -10,13 +10,8 @@
"beforeBuildCommand": "pnpm run web:build" "beforeBuildCommand": "pnpm run web:build"
}, },
"tauri": { "tauri": {
"systemTray": {
"iconPath": "icons/tray-icon.ico",
"iconAsTemplate": true
},
"bundle": { "bundle": {
"active": true, "active": true,
"targets": ["deb", "appimage", "nsis", "app", "dmg", "updater"],
"identifier": "io.github.clash-verge-rev.clash-verge-rev", "identifier": "io.github.clash-verge-rev.clash-verge-rev",
"icon": [ "icon": [
"icons/32x32.png", "icons/32x32.png",
@ -30,32 +25,7 @@
"copyright": "© 2022 zzzgydi All Rights Reserved", "copyright": "© 2022 zzzgydi All Rights Reserved",
"category": "DeveloperTool", "category": "DeveloperTool",
"shortDescription": "A Clash Meta GUI based on tauri.", "shortDescription": "A Clash Meta GUI based on tauri.",
"longDescription": "A Clash Meta GUI based on tauri.", "longDescription": "A Clash Meta GUI based on tauri."
"deb": {
"depends": ["openssl"]
},
"macOS": {
"frameworks": [],
"minimumSystemVersion": "",
"exceptionDomain": "",
"signingIdentity": null,
"entitlements": null
},
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": "",
"webviewInstallMode": {
"type": "embedBootstrapper",
"silent": true
},
"nsis": {
"displayLanguageSelector": true,
"installerIcon": "icons/icon.ico",
"languages": ["SimpChinese", "English"],
"license": "../LICENSE"
}
}
}, },
"updater": { "updater": {
"active": true, "active": true,

View File

@ -0,0 +1,13 @@
{
"tauri": {
"systemTray": {
"iconPath": "icons/tray-icon.png"
},
"bundle": {
"targets": ["deb", "appimage", "updater"],
"deb": {
"depends": ["openssl"]
}
}
}
}

View File

@ -0,0 +1,18 @@
{
"tauri": {
"systemTray": {
"iconPath": "icons/tray-icon.ico",
"iconAsTemplate": true
},
"bundle": {
"targets": ["app", "dmg", "updater"],
"macOS": {
"frameworks": [],
"minimumSystemVersion": "",
"exceptionDomain": "",
"signingIdentity": null,
"entitlements": null
}
}
}
}

View File

@ -0,0 +1,25 @@
{
"tauri": {
"systemTray": {
"iconPath": "icons/tray-icon.png"
},
"bundle": {
"targets": ["nsis", "updater"],
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": "",
"webviewInstallMode": {
"type": "embedBootstrapper",
"silent": true
},
"nsis": {
"displayLanguageSelector": true,
"installerIcon": "icons/icon.ico",
"languages": ["SimpChinese", "English"],
"license": "../LICENSE"
}
}
}
}
}