mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
fix(service): fall back after installation verification rejects cores
This commit is contained in:
@@ -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',
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user