fix: kill clash when exit in service mode, close #241
This commit is contained in:
parent
c9d9909d74
commit
294d980b52
@ -22,6 +22,9 @@ pub struct Service {
|
|||||||
sidecar: Option<CommandChild>,
|
sidecar: Option<CommandChild>,
|
||||||
|
|
||||||
logs: Arc<RwLock<VecDeque<String>>>,
|
logs: Arc<RwLock<VecDeque<String>>>,
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
use_service_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
@ -31,6 +34,7 @@ impl Service {
|
|||||||
Service {
|
Service {
|
||||||
sidecar: None,
|
sidecar: None,
|
||||||
logs: Arc::new(RwLock::new(queue)),
|
logs: Arc::new(RwLock::new(queue)),
|
||||||
|
use_service_mode: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +50,8 @@ impl Service {
|
|||||||
verge.enable_service_mode.clone().unwrap_or(false)
|
verge.enable_service_mode.clone().unwrap_or(false)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.use_service_mode = enable;
|
||||||
|
|
||||||
if !enable {
|
if !enable {
|
||||||
return self.start_clash_by_sidecar();
|
return self.start_clash_by_sidecar();
|
||||||
}
|
}
|
||||||
@ -74,14 +80,8 @@ impl Service {
|
|||||||
{
|
{
|
||||||
let _ = self.stop_clash_by_sidecar();
|
let _ = self.stop_clash_by_sidecar();
|
||||||
|
|
||||||
let enable = {
|
if self.use_service_mode {
|
||||||
let data = Data::global();
|
tauri::async_runtime::block_on(async move {
|
||||||
let verge = data.verge.lock();
|
|
||||||
verge.enable_service_mode.clone().unwrap_or(false)
|
|
||||||
};
|
|
||||||
|
|
||||||
if enable {
|
|
||||||
tauri::async_runtime::spawn(async move {
|
|
||||||
log_if_err!(Self::stop_clash_by_service().await);
|
log_if_err!(Self::stop_clash_by_service().await);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user