mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:33:45 +08:00
fix: exit_app event
This commit is contained in:
parent
6f1299ce9e
commit
0ac91e36a0
@ -2,14 +2,14 @@ use crate::{
|
|||||||
config::*,
|
config::*,
|
||||||
core::*,
|
core::*,
|
||||||
feat,
|
feat,
|
||||||
utils::{dirs, help},
|
utils::{dirs, help, resolve},
|
||||||
};
|
};
|
||||||
use crate::{ret_err, wrap_err};
|
use crate::{ret_err, wrap_err};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use sysproxy::Sysproxy;
|
use sysproxy::Sysproxy;
|
||||||
|
use tauri::api;
|
||||||
type CmdResult<T = ()> = Result<T, String>;
|
type CmdResult<T = ()> = Result<T, String>;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -266,6 +266,15 @@ pub async fn test_delay(url: String) -> CmdResult<u32> {
|
|||||||
Ok(feat::test_delay(url).await.unwrap_or(10000u32))
|
Ok(feat::test_delay(url).await.unwrap_or(10000u32))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn exit_app(app_handle: tauri::AppHandle) {
|
||||||
|
let _ = resolve::save_window_size_position(&app_handle, true);
|
||||||
|
resolve::resolve_reset();
|
||||||
|
api::process::kill_children();
|
||||||
|
app_handle.exit(0);
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub mod service {
|
pub mod service {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -203,14 +203,8 @@ impl Tray {
|
|||||||
"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" => api::process::restart(&app_handle.env()),
|
"restart_app" => api::process::restart(&app_handle.env()),
|
||||||
"quit" => {
|
"quit" => cmds::exit_app(app_handle.clone()),
|
||||||
let _ = resolve::save_window_size_position(app_handle, true);
|
|
||||||
|
|
||||||
resolve::resolve_reset();
|
|
||||||
api::process::kill_children();
|
|
||||||
app_handle.exit(0);
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -55,6 +55,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
cmds::get_verge_config,
|
cmds::get_verge_config,
|
||||||
cmds::patch_verge_config,
|
cmds::patch_verge_config,
|
||||||
cmds::test_delay,
|
cmds::test_delay,
|
||||||
|
cmds::exit_app,
|
||||||
// cmds::update_hotkeys,
|
// cmds::update_hotkeys,
|
||||||
// profile
|
// profile
|
||||||
cmds::get_profiles,
|
cmds::get_profiles,
|
||||||
@ -102,14 +103,6 @@ fn main() -> std::io::Result<()> {
|
|||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|
||||||
app.run(|app_handle, e| match e {
|
app.run(|app_handle, e| match e {
|
||||||
tauri::RunEvent::ExitRequested { api, .. } => {
|
|
||||||
api.prevent_exit();
|
|
||||||
}
|
|
||||||
tauri::RunEvent::Exit => {
|
|
||||||
resolve::resolve_reset();
|
|
||||||
api::process::kill_children();
|
|
||||||
app_handle.exit(0);
|
|
||||||
}
|
|
||||||
tauri::RunEvent::Updater(tauri::UpdaterEvent::Downloaded) => {
|
tauri::RunEvent::Updater(tauri::UpdaterEvent::Downloaded) => {
|
||||||
resolve::resolve_reset();
|
resolve::resolve_reset();
|
||||||
api::process::kill_children();
|
api::process::kill_children();
|
||||||
|
@ -10,10 +10,9 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { openAppDir, openCoreDir, openLogsDir } from "@/services/cmds";
|
import { exitApp, openAppDir, openCoreDir, openLogsDir } from "@/services/cmds";
|
||||||
import { ArrowForward } from "@mui/icons-material";
|
import { ArrowForward } from "@mui/icons-material";
|
||||||
import { checkUpdate } from "@tauri-apps/api/updater";
|
import { checkUpdate } from "@tauri-apps/api/updater";
|
||||||
import { exit } from "@tauri-apps/api/process";
|
|
||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
import { version } from "@root/package.json";
|
import { version } from "@root/package.json";
|
||||||
import { DialogRef, Notice } from "@/components/base";
|
import { DialogRef, Notice } from "@/components/base";
|
||||||
@ -314,7 +313,7 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
size="small"
|
size="small"
|
||||||
sx={{ my: "2px" }}
|
sx={{ my: "2px" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
exit(0);
|
exitApp();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ArrowForward />
|
<ArrowForward />
|
||||||
|
@ -199,3 +199,7 @@ export async function invoke_uwp_tool() {
|
|||||||
export async function getPortableFlag() {
|
export async function getPortableFlag() {
|
||||||
return invoke<boolean>("get_portable_flag");
|
return invoke<boolean>("get_portable_flag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function exitApp() {
|
||||||
|
return invoke("exit_app");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user