fix(service): avoid sticky availability probes

This commit is contained in:
wonfen
2026-07-25 15:22:46 +08:00
parent 7796259b03
commit e599a9d02c
10 changed files with 68 additions and 203 deletions
+1 -8
View File
@@ -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 {
+6 -9
View File
@@ -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',
])
}),
-8
View File
@@ -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')
}