mirror of
https://github.com/safing/portmaster
synced 2025-09-04 19:49:15 +00:00
[desktop] Fix traymenu exit button
This commit is contained in:
parent
4ffd5f2079
commit
a984032621
6 changed files with 306 additions and 292 deletions
559
desktop/tauri/src-tauri/Cargo.lock
generated
559
desktop/tauri/src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -12,11 +12,11 @@ rust-version = "1.60"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0.0-beta.13", features = [] }
|
tauri-build = { version = "2.0.0-beta.15", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Tauri
|
# Tauri
|
||||||
tauri = { version = "2.0.0-beta.16", features = ["tray-icon", "image-png", "config-json5"] }
|
tauri = { version = "2.0.0-beta.19", features = ["tray-icon", "image-png", "config-json5"] }
|
||||||
tauri-plugin-shell = "2.0.0-beta"
|
tauri-plugin-shell = "2.0.0-beta"
|
||||||
tauri-plugin-dialog = "2.0.0-beta"
|
tauri-plugin-dialog = "2.0.0-beta"
|
||||||
tauri-plugin-clipboard-manager = "2.0.0-beta"
|
tauri-plugin-clipboard-manager = "2.0.0-beta"
|
||||||
|
@ -26,7 +26,7 @@ tauri-plugin-cli = "2.0.0-beta"
|
||||||
tauri-plugin-notification = "2.0.0-beta"
|
tauri-plugin-notification = "2.0.0-beta"
|
||||||
tauri-plugin-log = "2.0.0-beta"
|
tauri-plugin-log = "2.0.0-beta"
|
||||||
|
|
||||||
tauri-cli = "2.0.0-beta.13"
|
tauri-cli = "2.0.0-beta.17"
|
||||||
|
|
||||||
# General
|
# General
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
|
@ -216,9 +216,10 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RunEvent::ExitRequested { api, .. } => {
|
// TODO(vladimir): why was this needed?
|
||||||
api.prevent_exit();
|
// RunEvent::ExitRequested { api, .. } => {
|
||||||
}
|
// api.prevent_exit();
|
||||||
|
// }
|
||||||
_ => {}
|
_ => {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,6 @@ impl<R: Runtime> PortmasterInterface<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handlers.push(Box::new(handler));
|
handlers.push(Box::new(handler));
|
||||||
|
|
||||||
debug!("number of registered handlers: {}", handlers.len());
|
debug!("number of registered handlers: {}", handlers.len());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,9 +206,8 @@ impl<R: Runtime> PortmasterInterface<R> {
|
||||||
//// Internal functions
|
//// Internal functions
|
||||||
fn start_notification_handler(&self) {
|
fn start_notification_handler(&self) {
|
||||||
if let Some(api) = self.get_api() {
|
if let Some(api) = self.get_api() {
|
||||||
let cli = api.clone();
|
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
notifications::notification_handler(cli).await;
|
notifications::notification_handler(api).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,9 +219,10 @@ impl<R: Runtime> PortmasterInterface<R> {
|
||||||
self.is_reachable.store(true, Ordering::Relaxed);
|
self.is_reachable.store(true, Ordering::Relaxed);
|
||||||
|
|
||||||
// store the new api client.
|
// store the new api client.
|
||||||
let mut guard = self.api.lock().unwrap();
|
{
|
||||||
*guard = Some(api.clone());
|
let mut guard = self.api.lock().unwrap();
|
||||||
drop(guard);
|
*guard = Some(api.clone());
|
||||||
|
}
|
||||||
|
|
||||||
// fire-off the notification handler.
|
// fire-off the notification handler.
|
||||||
if self.handle_notifications.load(Ordering::Relaxed) {
|
if self.handle_notifications.load(Ordering::Relaxed) {
|
||||||
|
@ -247,9 +246,10 @@ impl<R: Runtime> PortmasterInterface<R> {
|
||||||
self.is_reachable.store(false, Ordering::Relaxed);
|
self.is_reachable.store(false, Ordering::Relaxed);
|
||||||
|
|
||||||
// clear the current api client reference.
|
// clear the current api client reference.
|
||||||
let mut guard = self.api.lock().unwrap();
|
{
|
||||||
*guard = None;
|
let mut guard = self.api.lock().unwrap();
|
||||||
drop(guard);
|
*guard = None;
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(mut handlers) = self.handlers.lock() {
|
if let Ok(mut handlers) = self.handlers.lock() {
|
||||||
for handler in handlers.iter_mut() {
|
for handler in handlers.iter_mut() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use tauri::{
|
||||||
SubmenuBuilder,
|
SubmenuBuilder,
|
||||||
},
|
},
|
||||||
tray::{ClickType, TrayIcon, TrayIconBuilder},
|
tray::{ClickType, TrayIcon, TrayIconBuilder},
|
||||||
Manager, Wry,
|
Wry,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -93,7 +93,7 @@ pub fn setup_tray_menu(
|
||||||
.cancel_button_label("No")
|
.cancel_button_label("No")
|
||||||
.show(move |answer| {
|
.show(move |answer| {
|
||||||
if answer {
|
if answer {
|
||||||
let _ = handle.emit("exit-requested", "");
|
// let _ = handle.emit("exit-requested", "");
|
||||||
handle.exit(0);
|
handle.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -131,7 +131,7 @@ pub fn may_navigate_to_ui(win: &mut WebviewWindow, force: bool) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if force || cfg!(debug_assertions) || win.url().as_str() == "tauri://localhost" {
|
if force || cfg!(debug_assertions) || win.url().unwrap().as_str() == "tauri://localhost" {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
if let Ok(target_url) = std::env::var("TAURI_PM_URL") {
|
if let Ok(target_url) = std::env::var("TAURI_PM_URL") {
|
||||||
debug!("[tauri] navigating to {}", target_url);
|
debug!("[tauri] navigating to {}", target_url);
|
||||||
|
@ -157,7 +157,7 @@ pub fn may_navigate_to_ui(win: &mut WebviewWindow, force: bool) {
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
"not navigating to user interface: current url: {}",
|
"not navigating to user interface: current url: {}",
|
||||||
win.url().as_str()
|
win.url().unwrap().as_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue