From a3a04a05d975696033777f35d0628f31ec54c3f0 Mon Sep 17 00:00:00 2001 From: oomeow Date: Sun, 27 Sep 2026 22:48:55 +0800 Subject: [PATCH] fix(profiles): skip reloading current profile on URL import --- Changelog.md | 1 + src/pages/profiles.tsx | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index c5786a35f..740934193 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ 🐞 修复问题 - 修复「代理集合」「规则集合」订阅响应较慢时更新误报失败、且不显示真实失败原因的问题 +- 修复通过 URL 导入订阅时,即使导入的订阅并非当前使用的订阅,也会重新加载当前配置的问题 **🖥️ Windows** diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx index 2bd7484d9..239fd4932 100644 --- a/src/pages/profiles.tsx +++ b/src/pages/profiles.tsx @@ -221,10 +221,12 @@ const ProfilePage = () => { } setLoading(true) + const prevCurrent = profiles.current + const handleImportSuccess = async (noticeKey: string) => { showNotice.success(noticeKey) setUrl('') - await performRobustRefresh() + await performRobustRefresh(prevCurrent) } try { await importProfile(url) @@ -260,7 +262,7 @@ const ProfilePage = () => { } // `useProfiles` already retries three times; add only one business-level retry. - const performRobustRefresh = async () => { + const performRobustRefresh = async (prevCurrent?: string) => { let retryCount = 0 const maxRetries = 1 const baseDelay = 200 @@ -269,13 +271,15 @@ const ProfilePage = () => { try { debugLog(`[导入刷新] 第${retryCount + 1}次尝试刷新配置数据`) - await mutateProfiles() + const fresh = await fetchProfilesIntoCache() await new Promise((resolve) => setTimeout(resolve, baseDelay * (retryCount + 1)), ) - await onEnhance(false) + if (fresh?.current !== prevCurrent) { + await onEnhance(false) + } return } catch (error) { console.error(`[导入刷新] 第${retryCount + 1}次刷新失败:`, error) @@ -288,8 +292,10 @@ const ProfilePage = () => { console.warn(`[导入刷新] 常规刷新失败,尝试清除缓存重新获取`) try { - await fetchProfilesIntoCache() - await onEnhance(false) + const fresh = await fetchProfilesIntoCache() + if (fresh?.current !== prevCurrent) { + await onEnhance(false) + } showNotice.error( 'profiles.page.feedback.notifications.importNeedsRefresh', 3000,