fix(service): fall back after installation verification rejects cores

This commit is contained in:
wonfen
2026-09-24 18:43:26 +08:00
parent 3456de1fb6
commit fbc4b516b8
26 changed files with 266 additions and 44 deletions
+14 -4
View File
@@ -3,17 +3,18 @@ import { useCallback } from 'react'
import { installService, restartCore } from '@/services/cmds'
import { showNotice } from '@/services/notice-service'
const executeWithErrorHandling = async (
operation: () => Promise<void>,
const executeWithErrorHandling = async <T>(
operation: () => Promise<T>,
loadingKey: string,
successKey?: string,
) => {
try {
showNotice.info(loadingKey)
await operation()
const result = await operation()
if (successKey) {
showNotice.success(successKey)
}
return result
} catch (err) {
showNotice.error(err)
throw err
@@ -22,9 +23,18 @@ const executeWithErrorHandling = async (
export const useServiceInstaller = () => {
const installServiceAndRestartCore = useCallback(async () => {
await executeWithErrorHandling(
const outcome = await executeWithErrorHandling(
() => installService(),
'settings.statuses.clashService.installing',
)
if (outcome.status === 'sidecar') {
showNotice.warning(
'settings.feedback.notifications.clashService.permissionFallback',
{ reason: outcome.reason },
)
return
}
showNotice.success(
'settings.feedback.notifications.clashService.installSuccess',
)