mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-19 18:32:10 +08:00
fix: harden home clash-mode card against /configs read failures
Recover from controller read/switch failures on the mode card instead of showing a bare "communication error": - fall back to the tolerant get_clash_mode command (then runtime config) when the live /configs mode is unavailable, - optimistically reflect the clicked mode and write it through to the getClashConfig cache so a failed refetch can't flash back the old value, - surface patch failures via showNotice on both the home card and the proxies page (patchClashMode can now reject), and - revalidate getClashMode/getRuntimeConfig on refresh-clash-config so a once-empty fallback can recover.
This commit is contained in:
@@ -47,6 +47,8 @@ export const useLayoutEvents = (
|
||||
'getProxies',
|
||||
'getVersion',
|
||||
'getClashConfig',
|
||||
'getClashMode',
|
||||
'getRuntimeConfig',
|
||||
'getProxyProviders',
|
||||
'getRules',
|
||||
'getRuleProviders',
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
patchClashMode,
|
||||
updateProxyChainConfigInRuntime,
|
||||
} from '@/services/cmds'
|
||||
import { showNotice } from '@/services/notice-service'
|
||||
import { debugLog } from '@/utils/debug'
|
||||
|
||||
const MODES = ['rule', 'global', 'direct'] as const
|
||||
@@ -61,8 +62,13 @@ const ProxyPage = () => {
|
||||
if (mode !== curMode && verge?.auto_close_connection) {
|
||||
closeAllConnections()
|
||||
}
|
||||
await patchClashMode(mode)
|
||||
refreshClashConfig()
|
||||
try {
|
||||
// patchClashMode 在后端 PATCH 失败时会 reject,需提示用户而非静默失败
|
||||
await patchClashMode(mode)
|
||||
refreshClashConfig()
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
})
|
||||
|
||||
const onToggleChainMode = useLockFn(async () => {
|
||||
|
||||
Reference in New Issue
Block a user