mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 11:42:21 +08:00
fix: update profile after restart clash
This commit is contained in:
parent
72c2b306cf
commit
579f36a1dd
|
@ -142,10 +142,27 @@ pub fn patch_profile(
|
||||||
|
|
||||||
/// restart the sidecar
|
/// restart the sidecar
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn restart_sidecar(clash_state: State<'_, ClashState>) {
|
pub fn restart_sidecar(
|
||||||
let mut clash_arc = clash_state.0.lock().unwrap();
|
clash_state: State<'_, ClashState>,
|
||||||
if let Err(err) = clash_arc.restart_sidecar() {
|
profiles_state: State<'_, ProfilesState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let mut clash = clash_state.0.lock().unwrap();
|
||||||
|
|
||||||
|
match clash.restart_sidecar() {
|
||||||
|
Ok(_) => {
|
||||||
|
let profiles = profiles_state.0.lock().unwrap();
|
||||||
|
match profiles.activate(clash.info.clone()) {
|
||||||
|
Ok(()) => Ok(()),
|
||||||
|
Err(err) => {
|
||||||
log::error!("{}", err);
|
log::error!("{}", err);
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("{}", err);
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,18 @@ fn main() -> std::io::Result<()> {
|
||||||
}
|
}
|
||||||
"restart_clash" => {
|
"restart_clash" => {
|
||||||
let clash_state = app_handle.state::<states::ClashState>();
|
let clash_state = app_handle.state::<states::ClashState>();
|
||||||
let mut clash_arc = clash_state.0.lock().unwrap();
|
let mut clash = clash_state.0.lock().unwrap();
|
||||||
if let Err(err) = clash_arc.restart_sidecar() {
|
match clash.restart_sidecar() {
|
||||||
|
Ok(_) => {
|
||||||
|
let profiles = app_handle.state::<states::ProfilesState>();
|
||||||
|
let profiles = profiles.0.lock().unwrap();
|
||||||
|
if let Err(err) = profiles.activate(clash.info.clone()) {
|
||||||
log::error!("{}", err);
|
log::error!("{}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(err) => log::error!("{}", err),
|
||||||
|
}
|
||||||
|
}
|
||||||
"quit" => {
|
"quit" => {
|
||||||
api::process::kill_children();
|
api::process::kill_children();
|
||||||
resolve::resolve_reset(app_handle);
|
resolve::resolve_reset(app_handle);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user