fix: restart core or change can not remember proxy select in Global mode with sidecar #5466

This commit is contained in:
Tunglies
2025-12-02 16:25:13 +08:00
parent 1393828078
commit 550a7e0bb9

View File

@@ -7,7 +7,7 @@ use crate::{
constants,
core::{CoreManager, handle, validate::CoreConfigValidator},
};
use clash_verge_logging::{Type, logging};
use clash_verge_logging::{Type, logging, logging_error};
use compact_str::CompactString;
use serde_yaml_ng::Mapping;
use smartstring::alias::String;
@@ -46,6 +46,11 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<String>>
match CoreManager::global().change_core(&clash_core).await {
Ok(_) => {
logging_error!(
Type::Core,
Config::profiles().await.latest_arc().save_file().await
);
// 切换内核后重启内核
match CoreManager::global().restart_core().await {
Ok(_) => {
@@ -89,6 +94,10 @@ pub async fn start_core() -> CmdResult {
/// 关闭核心
#[tauri::command]
pub async fn stop_core() -> CmdResult {
logging_error!(
Type::Core,
Config::profiles().await.latest_arc().save_file().await
);
let result = CoreManager::global().stop_core().await.stringify_err();
if result.is_ok() {
handle::Handle::refresh_clash();
@@ -99,6 +108,10 @@ pub async fn stop_core() -> CmdResult {
/// 重启核心
#[tauri::command]
pub async fn restart_core() -> CmdResult {
logging_error!(
Type::Core,
Config::profiles().await.latest_arc().save_file().await
);
let result = CoreManager::global().restart_core().await.stringify_err();
if result.is_ok() {
handle::Handle::refresh_clash();