mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:43:44 +08:00
fix: the shortcut key to exit cannot be used
This commit is contained in:
parent
f31fe1440d
commit
95fb4f2e50
@ -24,6 +24,16 @@ impl Hotkey {
|
|||||||
*self.app_handle.lock() = Some(app_handle.clone());
|
*self.app_handle.lock() = Some(app_handle.clone());
|
||||||
let verge = Config::verge();
|
let verge = Config::verge();
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
log_err!(self.register("CMD+Q", "quit"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
log_err!(self.register("Control+Q", "quit"));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(hotkeys) = verge.latest().hotkeys.as_ref() {
|
if let Some(hotkeys) = verge.latest().hotkeys.as_ref() {
|
||||||
for hotkey in hotkeys.iter() {
|
for hotkey in hotkeys.iter() {
|
||||||
let mut iter = hotkey.split(',');
|
let mut iter = hotkey.split(',');
|
||||||
@ -65,6 +75,7 @@ impl Hotkey {
|
|||||||
"clash_mode_direct" => || feat::change_clash_mode("direct".into()),
|
"clash_mode_direct" => || feat::change_clash_mode("direct".into()),
|
||||||
"toggle_system_proxy" => feat::toggle_system_proxy,
|
"toggle_system_proxy" => feat::toggle_system_proxy,
|
||||||
"toggle_tun_mode" => feat::toggle_tun_mode,
|
"toggle_tun_mode" => feat::toggle_tun_mode,
|
||||||
|
"quit" => feat::quit,
|
||||||
_ => bail!("invalid function \"{func}\""),
|
_ => bail!("invalid function \"{func}\""),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,6 +84,7 @@ impl Hotkey {
|
|||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log::info!(target: "app", "register hotkey {hotkey} {func}");
|
log::info!(target: "app", "register hotkey {hotkey} {func}");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,10 @@ fn on_menu_event(app_handle: &AppHandle, event: MenuEvent) {
|
|||||||
"open_logs_dir" => crate::log_err!(cmds::open_logs_dir()),
|
"open_logs_dir" => crate::log_err!(cmds::open_logs_dir()),
|
||||||
"restart_clash" => feat::restart_clash_core(),
|
"restart_clash" => feat::restart_clash_core(),
|
||||||
"restart_app" => tauri::process::restart(&app_handle.env()),
|
"restart_app" => tauri::process::restart(&app_handle.env()),
|
||||||
"quit" => cmds::exit_app(app_handle.clone()),
|
"quit" => {
|
||||||
|
println!("quit");
|
||||||
|
feat::quit();
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use tauri_plugin_clipboard_manager::ClipboardExt;
|
|||||||
// 打开面板
|
// 打开面板
|
||||||
pub fn open_or_close_dashboard() {
|
pub fn open_or_close_dashboard() {
|
||||||
let handle = handle::Handle::global();
|
let handle = handle::Handle::global();
|
||||||
let app_handle = handle.app_handle.lock();
|
let app_handle = handle.app_handle.lock().clone();
|
||||||
if let Some(app_handle) = app_handle.as_ref() {
|
if let Some(app_handle) = app_handle.as_ref() {
|
||||||
if let Some(window) = app_handle.get_webview_window("main") {
|
if let Some(window) = app_handle.get_webview_window("main") {
|
||||||
if let Ok(true) = window.is_focused() {
|
if let Ok(true) = window.is_focused() {
|
||||||
@ -103,6 +103,17 @@ pub fn toggle_tun_mode() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn quit() {
|
||||||
|
let handle = handle::Handle::global();
|
||||||
|
let app_handle = handle.app_handle.lock().clone();
|
||||||
|
if let Some(app_handle) = app_handle.as_ref() {
|
||||||
|
let _ = resolve::save_window_size_position(&app_handle, true);
|
||||||
|
resolve::resolve_reset();
|
||||||
|
app_handle.exit(0);
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 修改clash的订阅
|
/// 修改clash的订阅
|
||||||
pub async fn patch_clash(patch: Mapping) -> Result<()> {
|
pub async fn patch_clash(patch: Mapping) -> Result<()> {
|
||||||
Config::clash().draft().patch_config(patch.clone());
|
Config::clash().draft().patch_config(patch.clone());
|
||||||
|
@ -46,7 +46,7 @@ pub fn app_home_dir() -> Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let handle = handle::Handle::global();
|
let handle = handle::Handle::global();
|
||||||
let app_handle = handle.app_handle.lock();
|
let app_handle = handle.app_handle.lock().clone();
|
||||||
|
|
||||||
if let Some(app_handle) = app_handle.as_ref() {
|
if let Some(app_handle) = app_handle.as_ref() {
|
||||||
match app_handle.path().data_dir() {
|
match app_handle.path().data_dir() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user