mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:43:44 +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
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
log::info!(target: "app", "core changed to {clash_core}");
|
// 切换内核后重启内核
|
||||||
handle::Handle::notice_message("config_core::change_success", &clash_core);
|
match CoreManager::global().restart_core().await {
|
||||||
handle::Handle::refresh_clash();
|
Ok(_) => {
|
||||||
Ok(None)
|
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) => {
|
Err(err) => {
|
||||||
let error_msg = err.to_string();
|
let error_msg = err.to_string();
|
||||||
|
@ -45,13 +45,18 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
closeAllConnections();
|
closeAllConnections();
|
||||||
await changeClashCore(core);
|
const errorMsg = await changeClashCore(core);
|
||||||
|
|
||||||
|
if (errorMsg) {
|
||||||
|
Notice.error(errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mutateVerge();
|
mutateVerge();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
mutate("getClashConfig");
|
mutate("getClashConfig");
|
||||||
mutate("getVersion");
|
mutate("getVersion");
|
||||||
}, 100);
|
}, 500);
|
||||||
// Notice.success(t("Switched to _clash Core", { core: `${core}` }), 1000);
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
Notice.error(err?.message || err.toString());
|
Notice.error(err?.message || err.toString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user