mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 03:23:57 +08:00
fix: restart clash core after change it
This commit is contained in:
parent
05b910dc17
commit
541b78ba6f
@ -40,10 +40,21 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<String>>
|
||||
.await
|
||||
{
|
||||
Ok(_) => {
|
||||
log::info!(target: "app", "core changed to {clash_core}");
|
||||
handle::Handle::notice_message("config_core::change_success", &clash_core);
|
||||
handle::Handle::refresh_clash();
|
||||
Ok(None)
|
||||
// 切换内核后重启内核
|
||||
match CoreManager::global().restart_core().await {
|
||||
Ok(_) => {
|
||||
log::info!(target: "app", "core changed and restarted to {clash_core}");
|
||||
handle::Handle::notice_message("config_core::change_success", &clash_core);
|
||||
handle::Handle::refresh_clash();
|
||||
Ok(None)
|
||||
}
|
||||
Err(err) => {
|
||||
let error_msg = format!("Core changed but failed to restart: {}", err);
|
||||
log::error!(target: "app", "{}", error_msg);
|
||||
handle::Handle::notice_message("config_core::change_error", &error_msg);
|
||||
Ok(Some(error_msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
let error_msg = err.to_string();
|
||||
|
@ -45,13 +45,18 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
|
||||
try {
|
||||
closeAllConnections();
|
||||
await changeClashCore(core);
|
||||
const errorMsg = await changeClashCore(core);
|
||||
|
||||
if (errorMsg) {
|
||||
Notice.error(errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
mutateVerge();
|
||||
setTimeout(() => {
|
||||
mutate("getClashConfig");
|
||||
mutate("getVersion");
|
||||
}, 100);
|
||||
// Notice.success(t("Switched to _clash Core", { core: `${core}` }), 1000);
|
||||
}, 500);
|
||||
} catch (err: any) {
|
||||
Notice.error(err?.message || err.toString());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user