mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-14 21:20:48 +08:00
fix(profiles): skip reloading current profile on URL import (#8092)
Co-authored-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<details>
|
||||
<summary><strong> 🐞 修复问题 </strong></summary>
|
||||
|
||||
- 修复通过 URL 导入订阅时,即使导入的订阅并非当前使用的订阅,也会重新加载当前配置的问题
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ tray:
|
||||
global: Global
|
||||
profiles: Perfis
|
||||
proxies: Proxies
|
||||
testLatency: Test Latency
|
||||
testingLatency: Testing latency…
|
||||
systemProxy: Proxy do sistema
|
||||
tunMode: Modo TUN
|
||||
closeAllConnections: Fechar todas as conexões
|
||||
|
||||
+12
-6
@@ -212,10 +212,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 mutate(() => importProfile(url), {
|
||||
@@ -261,7 +263,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
|
||||
@@ -270,13 +272,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)
|
||||
@@ -289,8 +293,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,
|
||||
|
||||
Reference in New Issue
Block a user