mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-04 13:10:11 +08:00
chore(deps): update tauri (#8764)
* chore(deps): update tauri * fix(installer): align NSIS locale variables with Tauri 2.13 * chore(tray): migrate template icons to Tauri 2.13 APIs * fix(core): resolve the bundled core for validation fingerprints * fix(deps): resolve Tauri 2.13 with the patched WebDriver * fix(tray): wake the main window from Linux tray clicks Use StatusNotifierItem activation to wake the dashboard, including lightweight mode. Closes #8517 * fix(tray): gate template icon handling to macOS at compile time * fix(deps): select GTK3 for Linux dialogs * fix(linux): return when the startup dialog cannot initialize GTK --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com>
This commit is contained in:
co-authored by
renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Tunglies
parent
16ef6fbc34
commit
a76818326d
@@ -296,19 +296,16 @@ impl Tray {
|
||||
|
||||
let (_is_custom_icon, icon_bytes) = TrayState::get_tray_icon(verge).await;
|
||||
|
||||
let template = {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
verge.tray_icon.as_ref().is_none_or(|v| v == "monochrome")
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
false
|
||||
}
|
||||
};
|
||||
let icon = Some(tauri::image::Image::from_bytes(&icon_bytes)?);
|
||||
|
||||
logging_error!(Type::Tray, tray.set_icon_with_as_template(icon, template));
|
||||
#[cfg(target_os = "macos")]
|
||||
let result = if verge.tray_icon.as_ref().is_none_or(|v| v == "monochrome") {
|
||||
tray.set_icon_templated(icon)
|
||||
} else {
|
||||
tray.set_icon(icon)
|
||||
};
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let result = tray.set_icon(icon);
|
||||
logging_error!(Type::Tray, result);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -404,26 +401,21 @@ impl Tray {
|
||||
let icon_bytes = TrayState::get_tray_icon(&verge).await.1;
|
||||
let icon = tauri::image::Image::from_bytes(&icon_bytes)?;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let builder = TrayIconBuilder::with_id(TRAY_ID).icon(icon).icon_as_template(false);
|
||||
let builder = TrayIconBuilder::with_id(TRAY_ID);
|
||||
#[cfg(target_os = "macos")]
|
||||
let builder = if verge.tray_icon.as_ref().is_none_or(|v| v == "monochrome") {
|
||||
builder.icon_templated(icon)
|
||||
} else {
|
||||
builder.icon(icon)
|
||||
};
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let builder = builder.icon(icon);
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
let show_menu_on_left_click = verge.tray_event.as_ref().is_some_and(|v| v == "tray_menu");
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let mut builder = TrayIconBuilder::with_id(TRAY_ID).icon(icon).icon_as_template(false);
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let is_monochrome = verge.tray_icon.as_ref().is_none_or(|v| v == "monochrome");
|
||||
builder = builder.icon_as_template(is_monochrome);
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
{
|
||||
if !show_menu_on_left_click {
|
||||
builder = builder.show_menu_on_left_click(false);
|
||||
}
|
||||
}
|
||||
let builder = builder.show_menu_on_left_click(show_menu_on_left_click);
|
||||
|
||||
let tray = builder.build(app_handle)?;
|
||||
tray.on_tray_icon_event(on_tray_icon_event);
|
||||
@@ -870,9 +862,14 @@ fn on_tray_icon_event(_tray_icon: &TrayIcon, tray_event: TrayIconEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const CLICK_STATE: MouseButtonState = if cfg!(target_os = "linux") {
|
||||
MouseButtonState::Up
|
||||
} else {
|
||||
MouseButtonState::Down
|
||||
};
|
||||
if let TrayIconEvent::Click {
|
||||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Down,
|
||||
button_state: CLICK_STATE,
|
||||
..
|
||||
} = tray_event
|
||||
{
|
||||
@@ -882,9 +879,13 @@ fn on_tray_icon_event(_tray_icon: &TrayIcon, tray_event: TrayIconEvent) {
|
||||
}
|
||||
|
||||
AsyncHandler::spawn(|| async move {
|
||||
let verge = Config::verge().await.data_arc();
|
||||
let verge_tray_event = verge.tray_event.clone().unwrap_or_else(|| "main_window".into());
|
||||
let verge_tray_action = TrayAction::from(verge_tray_event.as_str());
|
||||
let configured_event = if cfg!(target_os = "linux") {
|
||||
None
|
||||
} else {
|
||||
Config::verge().await.data_arc().tray_event.clone()
|
||||
};
|
||||
let verge_tray_event = configured_event.as_deref().unwrap_or("main_window");
|
||||
let verge_tray_action = TrayAction::from(verge_tray_event);
|
||||
logging!(debug, Type::Tray, "tray event: {verge_tray_action:?}");
|
||||
match verge_tray_action {
|
||||
TrayAction::SystemProxy => {
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::{
|
||||
sync::LazyLock,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
};
|
||||
use tauri::Manager as _;
|
||||
use tauri_plugin_shell::ShellExt as _;
|
||||
use tokio::fs;
|
||||
use tristr::alias::String;
|
||||
@@ -26,9 +27,10 @@ async fn validation_fingerprint(yaml: &str) -> u64 {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
yaml.hash(&mut hasher);
|
||||
core.as_str().hash(&mut hasher);
|
||||
let binary = std::env::current_exe()
|
||||
.into_iter()
|
||||
.map(|exe| exe.with_file_name(format!("{}{}", core.as_str(), std::env::consts::EXE_SUFFIX)));
|
||||
let binary = handle::Handle::app_handle()
|
||||
.path()
|
||||
.resolve_external_bin(core.as_str())
|
||||
.into_iter();
|
||||
// The test run reads geo databases from the app dir; a geo update must revalidate.
|
||||
let geo = dirs::app_home_dir().into_iter().flat_map(|dir| {
|
||||
super::runtime_bundle::GEO_ASSETS
|
||||
|
||||
@@ -30,6 +30,29 @@ pub(crate) fn report_error(error: &anyhow::Error) {
|
||||
}
|
||||
};
|
||||
|
||||
show_error_dialog(&message);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn show_error_dialog(message: &str) {
|
||||
use gtk::prelude::DialogExt as _;
|
||||
|
||||
// rfd's GTK3 MessageDialog waits indefinitely if its GTK worker fails to initialize.
|
||||
if gtk::init().is_err() {
|
||||
return;
|
||||
}
|
||||
|
||||
gtk::MessageDialog::builder()
|
||||
.message_type(gtk::MessageType::Error)
|
||||
.title("Clash Verge startup failed")
|
||||
.text(message)
|
||||
.buttons(gtk::ButtonsType::Ok)
|
||||
.build()
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn show_error_dialog(message: &str) {
|
||||
let _ = rfd::MessageDialog::new()
|
||||
.set_level(rfd::MessageLevel::Error)
|
||||
.set_title("Clash Verge startup failed")
|
||||
|
||||
Reference in New Issue
Block a user