From df7e52f25c17a5b37afa4e722b9c90c9e4711a35 Mon Sep 17 00:00:00 2001 From: StarsSail <152023695+wysha-object@users.noreply.github.com> Date: Sun, 9 Aug 2026 14:29:01 +0800 Subject: [PATCH] fix: remove unnecessary allow_auto_update default value (#7697) * fix: remove unnecessary allow_auto_update default value * fix: normalize missing profile auto-update state --------- Co-authored-by: wonfen --- src-tauri/src/config/prfitem.rs | 7 ------- src-tauri/src/config/profiles.rs | 6 ++++++ src/components/profile/profile-viewer.tsx | 7 ++++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/config/prfitem.rs b/src-tauri/src/config/prfitem.rs index 88ff36da9..162afaa3d 100644 --- a/src-tauri/src/config/prfitem.rs +++ b/src-tauri/src/config/prfitem.rs @@ -109,7 +109,6 @@ pub struct PrfOption { #[serde(skip_serializing_if = "Option::is_none")] pub danger_accept_invalid_certs: Option, - #[serde(default = "default_allow_auto_update")] #[serde(skip_serializing_if = "Option::is_none")] pub allow_auto_update: Option, @@ -579,12 +578,6 @@ impl PrfItem { } } -// 向前兼容,默认为订阅启用自动更新 -#[allow(clippy::unnecessary_wraps)] -const fn default_allow_auto_update() -> Option { - Some(true) -} - fn allow_auto_update_enabled(option: Option<&PrfOption>) -> bool { option.and_then(|o| o.allow_auto_update).unwrap_or(true) } diff --git a/src-tauri/src/config/profiles.rs b/src-tauri/src/config/profiles.rs index a91cfd68e..b1d067008 100644 --- a/src-tauri/src/config/profiles.rs +++ b/src-tauri/src/config/profiles.rs @@ -138,6 +138,12 @@ impl IProfiles { if item.uid.is_none() { item.uid = Some(help::get_uid("d").into()); } + if item.itype.as_deref() == Some("remote") { + item.option + .get_or_insert_with(PrfOption::default) + .allow_auto_update + .get_or_insert(true); + } } profiles } diff --git a/src/components/profile/profile-viewer.tsx b/src/components/profile/profile-viewer.tsx index c55928577..8ab7c4f5e 100644 --- a/src/components/profile/profile-viewer.tsx +++ b/src/components/profile/profile-viewer.tsx @@ -55,6 +55,7 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) { option: { with_proxy: false, self_proxy: false, + allow_auto_update: true, }, }, }) @@ -418,7 +419,11 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) { {t('profiles.modals.profileForm.fields.allowAutoUpdate')} - + )} />