mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-21 09:42:09 +08:00
fix(service): avoid sticky availability probes
This commit is contained in:
@@ -7,11 +7,8 @@ import {
|
||||
supportedLanguages,
|
||||
} from '@/services/i18n'
|
||||
|
||||
import { useVerge } from './use-verge'
|
||||
|
||||
export const useI18n = () => {
|
||||
const { i18n, t } = useTranslation()
|
||||
const { patchVerge } = useVerge()
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
const switchLanguage = useCallback(
|
||||
@@ -30,17 +27,13 @@ export const useI18n = () => {
|
||||
setIsLoading(true)
|
||||
try {
|
||||
await changeLanguage(targetLanguage)
|
||||
|
||||
if (patchVerge) {
|
||||
await patchVerge({ language: targetLanguage })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to change language:', error)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
},
|
||||
[i18n.language, patchVerge],
|
||||
[i18n.language],
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
getRunningMode,
|
||||
getServiceInstallState,
|
||||
isAdmin,
|
||||
isServiceAvailable,
|
||||
type RunningMode,
|
||||
type ServiceInstallState,
|
||||
} from '@/services/cmds'
|
||||
@@ -29,17 +28,15 @@ const defaultSystemState = {
|
||||
} as SystemState
|
||||
|
||||
export const fetchSystemState = async (): Promise<SystemState> => {
|
||||
const [runningMode, isAdminMode, isServiceOk, serviceInstallState] =
|
||||
await Promise.all([
|
||||
getRunningMode(),
|
||||
isAdmin(),
|
||||
isServiceAvailable(),
|
||||
getServiceInstallState().catch(() => null),
|
||||
])
|
||||
const [runningMode, isAdminMode, serviceInstallState] = await Promise.all([
|
||||
getRunningMode(),
|
||||
isAdmin(),
|
||||
getServiceInstallState().catch(() => null),
|
||||
])
|
||||
return {
|
||||
runningMode,
|
||||
isAdminMode,
|
||||
isServiceOk,
|
||||
isServiceOk: serviceInstallState === 'ready',
|
||||
serviceInstallState,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ export const useLayoutEvents = (
|
||||
'getSystemProxy',
|
||||
'getAutotemProxy',
|
||||
'getRunningMode',
|
||||
'isServiceAvailable',
|
||||
'getSystemState',
|
||||
])
|
||||
}),
|
||||
|
||||
@@ -404,14 +404,6 @@ export const continueWithSidecar = async () => {
|
||||
return invoke<void>('continue_with_sidecar')
|
||||
}
|
||||
|
||||
// 系统服务是否可用
|
||||
export const isServiceAvailable = async () => {
|
||||
try {
|
||||
return await invoke<boolean>('is_service_available')
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
export const entry_lightweight_mode = async () => {
|
||||
return invoke<void>('entry_lightweight_mode')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user