fix: safely restore selected proxy nodes

This commit is contained in:
wonfen
2026-07-16 04:16:42 +08:00
parent 6c149d6234
commit cd20bdb6a1
6 changed files with 471 additions and 77 deletions
+14
View File
@@ -155,6 +155,10 @@ export const AppDataProvider = ({
refreshProxy().catch(() => {})
}
const handleRefreshProfiles = () => {
void revalidateQueries([['getProfiles']])
}
const initializeListeners = async () => {
try {
const unlistenProfile = await listen<string>(
@@ -166,6 +170,16 @@ export const AppDataProvider = ({
console.error('[AppDataProvider] 监听 Profile 事件失败:', error)
}
try {
const unlistenProfiles = await listen(
'verge://refresh-profiles',
handleRefreshProfiles,
)
cleanupFns.push(unlistenProfiles)
} catch (error) {
console.error('[AppDataProvider] 监听 Profiles 刷新事件失败:', error)
}
try {
const unlistenProxy = await listen(
'verge://refresh-proxy-config',