mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:53:44 +08:00
chore:update
This commit is contained in:
parent
82543de95e
commit
f52089a674
@ -18,7 +18,7 @@ pub struct Sysopt {
|
|||||||
/// helps to auto launch the app
|
/// helps to auto launch the app
|
||||||
auto_launch: Arc<Mutex<Option<AutoLaunch>>>,
|
auto_launch: Arc<Mutex<Option<AutoLaunch>>>,
|
||||||
/// record whether the guard async is running or not
|
/// record whether the guard async is running or not
|
||||||
guard_state: Arc<TokioMutex<bool>>,
|
guard_state: Arc<Mutex<bool>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
@ -41,7 +41,6 @@ fn get_bypass() -> String {
|
|||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if custom_bypass.is_empty() {
|
if custom_bypass.is_empty() {
|
||||||
DEFAULT_BYPASS.to_string()
|
DEFAULT_BYPASS.to_string()
|
||||||
} else if use_default {
|
} else if use_default {
|
||||||
@ -58,7 +57,7 @@ impl Sysopt {
|
|||||||
update_sysproxy: Arc::new(TokioMutex::new(false)),
|
update_sysproxy: Arc::new(TokioMutex::new(false)),
|
||||||
reset_sysproxy: Arc::new(TokioMutex::new(false)),
|
reset_sysproxy: Arc::new(TokioMutex::new(false)),
|
||||||
auto_launch: Arc::new(Mutex::new(None)),
|
auto_launch: Arc::new(Mutex::new(None)),
|
||||||
guard_state: Arc::new(TokioMutex::new(false)),
|
guard_state: Arc::new(false.into()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ impl Sysopt {
|
|||||||
|
|
||||||
/// init the sysproxy
|
/// init the sysproxy
|
||||||
pub async fn update_sysproxy(&self) -> Result<()> {
|
pub async fn update_sysproxy(&self) -> Result<()> {
|
||||||
let _ = self.update_sysproxy.lock();
|
let _lock = self.update_sysproxy.lock().await;
|
||||||
|
|
||||||
let port = Config::verge()
|
let port = Config::verge()
|
||||||
.latest()
|
.latest()
|
||||||
@ -160,7 +159,7 @@ impl Sysopt {
|
|||||||
|
|
||||||
/// reset the sysproxy
|
/// reset the sysproxy
|
||||||
pub async fn reset_sysproxy(&self) -> Result<()> {
|
pub async fn reset_sysproxy(&self) -> Result<()> {
|
||||||
let _ = self.reset_sysproxy.lock();
|
let _lock = self.reset_sysproxy.lock().await;
|
||||||
//直接关闭所有代理
|
//直接关闭所有代理
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
{
|
{
|
||||||
@ -280,7 +279,8 @@ impl Sysopt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn guard_proxy(&self) {
|
fn guard_proxy(&self) {
|
||||||
let _ = self.guard_state.lock();
|
let _lock = self.guard_state.lock();
|
||||||
|
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
// default duration is 10s
|
// default duration is 10s
|
||||||
let mut wait_secs = 10u64;
|
let mut wait_secs = 10u64;
|
||||||
@ -367,7 +367,7 @@ impl Sysopt {
|
|||||||
let shell = app_handle.shell();
|
let shell = app_handle.shell();
|
||||||
let output = if pac {
|
let output = if pac {
|
||||||
let address = format!("http://{}:{}/pac", "127.0.0.1", pac_port);
|
let address = format!("http://{}:{}/pac", "127.0.0.1", pac_port);
|
||||||
|
|
||||||
shell
|
shell
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
.command(sysproxy_exe.as_path().to_str().unwrap())
|
||||||
.args(["opac", address.as_str()])
|
.args(["opac", address.as_str()])
|
||||||
@ -377,7 +377,7 @@ impl Sysopt {
|
|||||||
} else {
|
} else {
|
||||||
let address = format!("{}:{}", "127.0.0.1", port);
|
let address = format!("{}:{}", "127.0.0.1", port);
|
||||||
let bypass = get_bypass();
|
let bypass = get_bypass();
|
||||||
|
|
||||||
shell
|
shell
|
||||||
.command(sysproxy_exe.as_path().to_str().unwrap())
|
.command(sysproxy_exe.as_path().to_str().unwrap())
|
||||||
.args(["global", address.as_str(), bypass.as_ref()])
|
.args(["global", address.as_str(), bypass.as_ref()])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user