diff --git a/src-tauri/src/enhance/tun.rs b/src-tauri/src/enhance/tun.rs index f7484b6b..3d8fa518 100644 --- a/src-tauri/src/enhance/tun.rs +++ b/src-tauri/src/enhance/tun.rs @@ -30,7 +30,10 @@ pub async fn use_tun(mut config: Mapping, enable: bool, origin_dns_val: Mapping) val.as_mapping().cloned().unwrap_or(Mapping::new()) }); let ipv6_key = Value::from("ipv6"); - let ipv6_val = config.get(&ipv6_key).and_then(|v| v.as_bool()).unwrap_or(false); + let ipv6_val = config + .get(&ipv6_key) + .and_then(|v| v.as_bool()) + .unwrap_or(false); if enable { revise!(dns_val, "enable", true); diff --git a/src-tauri/src/feat.rs b/src-tauri/src/feat.rs index 388c2406..098997d9 100644 --- a/src-tauri/src/feat.rs +++ b/src-tauri/src/feat.rs @@ -137,16 +137,14 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> { if patch.get("secret").is_some() || patch.get("external-controller").is_some() { Config::generate().await?; CoreManager::global().restart_core().await?; - handle::Handle::refresh_clash(); } else { if patch.get("mode").is_some() { log_err!(handle::Handle::update_systray_part()); } - Config::runtime().latest().patch_config(patch); - update_core_config(false).await?; + CoreManager::global().update_config().await?; } - + handle::Handle::refresh_clash(); >::Ok(()) }; match res { @@ -246,11 +244,11 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> { should_update_systray_part = true; } if should_restart_core { - Config::generate().await?; CoreManager::global().restart_core().await?; } if should_update_clash_config { - update_core_config(false).await?; + CoreManager::global().update_config().await?; + handle::Handle::refresh_clash(); } if should_update_launch { sysopt::Sysopt::global().update_launch()?; @@ -316,31 +314,19 @@ pub async fn update_profile(uid: String, option: Option) -> Result<() }; if should_update { - update_core_config(true).await?; + match CoreManager::global().update_config().await { + Ok(_) => { + handle::Handle::refresh_clash(); + } + Err(err) => { + log::error!(target: "app", "{err}"); + } + } } Ok(()) } -/// 更新订阅 -async fn update_core_config(notice: bool) -> Result<()> { - match CoreManager::global().update_config().await { - Ok(_) => { - handle::Handle::refresh_clash(); - if notice { - handle::Handle::notice_message("set_config::ok", "ok"); - } - Ok(()) - } - Err(err) => { - if notice { - handle::Handle::notice_message("set_config::error", format!("{err}")); - } - Err(err) - } - } -} - /// copy env variable pub fn copy_clash_env() { let app_handle = handle::Handle::global().app_handle().unwrap(); diff --git a/src/locales/en.json b/src/locales/en.json index 2eca4953..3e7b6f72 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -352,7 +352,6 @@ "Match Whole Word": "Match Whole Word", "Use Regular Expression": "Use Regular Expression", "Profile Imported Successfully": "Profile Imported Successfully", - "Clash Config Updated": "Clash Config Updated", "Profile Switched": "Profile Switched", "Profile Reactivated": "Profile Reactivated", "Only YAML Files Supported": "Only YAML Files Supported", diff --git a/src/locales/fa.json b/src/locales/fa.json index 336b6c44..c072994a 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -354,7 +354,6 @@ "Match Whole Word": "تطبیق کل کلمه", "Use Regular Expression": "استفاده از عبارت منظم", "Profile Imported Successfully": "پروفایل با موفقیت وارد شد", - "Clash Config Updated": "پیکربندی Clash به‌روزرسانی شد", "Profile Switched": "پروفایل تغییر یافت", "Profile Reactivated": "پروفایل مجدداً فعال شد", "Only YAML Files Supported": "فقط فایل‌های YAML پشتیبانی می‌شوند", diff --git a/src/locales/ru.json b/src/locales/ru.json index e09af779..777efac9 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -354,7 +354,6 @@ "Match Whole Word": "Полное совпадение слова", "Use Regular Expression": "Использовать регулярные выражения", "Profile Imported Successfully": "Профиль успешно импортирован", - "Clash Config Updated": "Clash конфигурация Обновлена", "Profile Switched": "Профиль изменен", "Profile Reactivated": "Профиль повторно активирован", "Only YAML Files Supported": "Поддерживаются только файлы YAML", diff --git a/src/locales/zh.json b/src/locales/zh.json index 09a1b4a9..80fe1715 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -354,7 +354,6 @@ "Match Whole Word": "全字匹配", "Use Regular Expression": "使用正则表达式", "Profile Imported Successfully": "导入订阅成功", - "Clash Config Updated": "Clash 配置已更新", "Profile Switched": "订阅已切换", "Profile Reactivated": "订阅已激活", "Only YAML Files Supported": "仅支持 YAML 文件", diff --git a/src/pages/_layout.tsx b/src/pages/_layout.tsx index 19d4f8c0..87d5b5b2 100644 --- a/src/pages/_layout.tsx +++ b/src/pages/_layout.tsx @@ -77,12 +77,6 @@ const Layout = () => { navigate("/profile"); Notice.error(msg); break; - case "set_config::ok": - Notice.success(t("Clash Config Updated")); - break; - case "set_config::error": - Notice.error(msg); - break; default: break; }