mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-16 07:52:06 +08:00
feat: add launch guard and secure multi-user service ownership (#7569)
* feat(service): isolate macOS launch and owner runtime * ci(windows): run owner security tests * chore(deps): use kode-bridge v0.4.1 tag * fix(macos): classify installed service state * fix(macos): classify marked unavailable service * fix(macos): gate core startup on service migration * fix(macos): scope service init to supported platforms * feat(macos): prompt before migrating installed service * fix(macos): shorten sidecar IPC path * build(service): pin helper protocol and artifacts * fix(core): require confirmed service and sidecar readiness * fix(macos): harden launch roots and singleton state * fix(ui): refresh migration state before restart * fix(macos): linearize service migration lifecycle * fix(ui): keep service migration state fresh * feat(service): track authenticated owner sessions * fix(service): preserve newer owner sessions * feat(macos): route service proxy changes through helper * fix(macos): serialize service proxy guard * fix(macos): close service proxy owner lifecycle * fix(macos): close remaining proxy stop races * fix(app): do not cancel controlled service stop * fix(lifecycle): keep controlled updates cancellation-safe * fix(macos): stage dev core for service * test(macos): exercise staged core cleanup * fix(dev): await controlled macOS exit * chore: update changelog * fix(macos): recover sidecar after service install failure Allow the existing sidecar to continue when service installation leaves the manager in InstallRequired, then settle the session state as SidecarAllowed. Show neutral status text while the migration dialog waits for its final state. * fix(macos): stage dev service tools before elevation * fix(macos): localize launch guard prompts * fix(service): address cross-platform integration issues * feat: support seamless service migration * fix: pass Windows service installer path safely * fix(prebuild): derive service release from Cargo dependency * fix(dev): preserve service installation state * fix: resolve clippy warnings in service lifecycle
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
import { Alert } from '@mui/material'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { BaseDialog } from '@/components/base'
|
||||
import { fetchSystemState } from '@/hooks/use-system-state'
|
||||
import { useVisibility } from '@/hooks/use-visibility'
|
||||
import {
|
||||
continueWithSidecar,
|
||||
getRunningMode,
|
||||
getServiceInstallState,
|
||||
installService,
|
||||
reinstallService,
|
||||
repairService,
|
||||
restartCore,
|
||||
type ServiceInstallState,
|
||||
} from '@/services/cmds'
|
||||
import { showNotice } from '@/services/notice-service'
|
||||
import { setCacheDataAsync, useQuery } from '@/services/query-client'
|
||||
const installStateQueryKey = ['getServiceInstallState'] as const
|
||||
|
||||
export const ServiceMigrationDialog = () => {
|
||||
const { t } = useTranslation()
|
||||
const pageVisible = useVisibility()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [stateRefreshFailed, setStateRefreshFailed] = useState(false)
|
||||
const [workflowIncomplete, setWorkflowIncomplete] = useState(false)
|
||||
const { data: state } = useQuery({
|
||||
queryKey: installStateQueryKey,
|
||||
queryFn: getServiceInstallState,
|
||||
enabled: true,
|
||||
retry: 1,
|
||||
refetchInterval: pageVisible ? 2000 : false,
|
||||
})
|
||||
const dialogState = stateRefreshFailed ? 'unavailable' : state
|
||||
const open =
|
||||
loading ||
|
||||
workflowIncomplete ||
|
||||
dialogState === 'installRequired' ||
|
||||
dialogState === 'needsReinstall' ||
|
||||
dialogState === 'unavailable'
|
||||
const showCheckingMessage =
|
||||
loading ||
|
||||
(dialogState !== 'installRequired' &&
|
||||
dialogState !== 'needsReinstall' &&
|
||||
dialogState !== 'unavailable')
|
||||
|
||||
const refreshInstallState = async () => {
|
||||
try {
|
||||
const data = await getServiceInstallState()
|
||||
await setCacheDataAsync<ServiceInstallState>(installStateQueryKey, data)
|
||||
setStateRefreshFailed(false)
|
||||
return data
|
||||
} catch (error) {
|
||||
setStateRefreshFailed(true)
|
||||
await setCacheDataAsync<ServiceInstallState>(
|
||||
installStateQueryKey,
|
||||
'unavailable',
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
const refreshSystemAndRunning = async () => {
|
||||
const [systemState, runningMode] = await Promise.all([
|
||||
fetchSystemState(),
|
||||
getRunningMode(),
|
||||
])
|
||||
await Promise.all([
|
||||
setCacheDataAsync(['getSystemState'], { ...systemState, runningMode }),
|
||||
setCacheDataAsync(['getRunningMode'], runningMode),
|
||||
])
|
||||
}
|
||||
|
||||
const handleServiceAction = async () => {
|
||||
setLoading(true)
|
||||
setWorkflowIncomplete(true)
|
||||
let actionSucceeded = false
|
||||
try {
|
||||
if (dialogState === 'installRequired') {
|
||||
await installService()
|
||||
} else if (dialogState === 'unavailable') {
|
||||
await repairService()
|
||||
} else {
|
||||
await reinstallService()
|
||||
}
|
||||
actionSucceeded = true
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
|
||||
let initialRefreshSucceeded = false
|
||||
try {
|
||||
await refreshInstallState()
|
||||
initialRefreshSucceeded = true
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
if (!actionSucceeded || !initialRefreshSucceeded) {
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
let restartSucceeded = false
|
||||
try {
|
||||
await restartCore()
|
||||
restartSucceeded = true
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
|
||||
let finalRefreshSucceeded = false
|
||||
try {
|
||||
await refreshInstallState()
|
||||
finalRefreshSucceeded = true
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
let revalidationSucceeded = false
|
||||
try {
|
||||
await refreshSystemAndRunning()
|
||||
revalidationSucceeded = true
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
if (restartSucceeded && finalRefreshSucceeded && revalidationSucceeded) {
|
||||
setWorkflowIncomplete(false)
|
||||
showNotice.success('layout.components.serviceMigration.success')
|
||||
}
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
const handleContinue = async () => {
|
||||
setLoading(true)
|
||||
setWorkflowIncomplete(true)
|
||||
let startupError: unknown
|
||||
try {
|
||||
await continueWithSidecar()
|
||||
} catch (error) {
|
||||
startupError = error
|
||||
}
|
||||
|
||||
let installRefreshSucceeded = false
|
||||
try {
|
||||
await refreshInstallState()
|
||||
installRefreshSucceeded = true
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
let revalidationSucceeded = false
|
||||
try {
|
||||
await refreshSystemAndRunning()
|
||||
revalidationSucceeded = true
|
||||
} catch (error) {
|
||||
showNotice.error(error)
|
||||
}
|
||||
if (startupError) {
|
||||
showNotice.error(startupError)
|
||||
} else if (installRefreshSucceeded && revalidationSucceeded) {
|
||||
setWorkflowIncomplete(false)
|
||||
}
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseDialog
|
||||
open={open}
|
||||
title={t('layout.components.serviceMigration.title')}
|
||||
okBtn={t(
|
||||
dialogState === 'installRequired'
|
||||
? 'settings.sections.proxyControl.actions.installService'
|
||||
: dialogState === 'unavailable'
|
||||
? 'layout.components.serviceMigration.repair'
|
||||
: 'layout.components.serviceMigration.reinstall',
|
||||
)}
|
||||
cancelBtn={t('layout.components.serviceMigration.continueSidecar')}
|
||||
disableOk={loading}
|
||||
disableCancel={loading}
|
||||
loading={loading}
|
||||
onOk={() => void handleServiceAction()}
|
||||
onCancel={() => void handleContinue()}
|
||||
>
|
||||
<Alert severity="warning">
|
||||
{t(
|
||||
showCheckingMessage
|
||||
? 'layout.components.serviceMigration.checkingMessage'
|
||||
: dialogState === 'installRequired' || dialogState === 'unavailable'
|
||||
? 'layout.components.serviceMigration.unavailableMessage'
|
||||
: 'layout.components.serviceMigration.message',
|
||||
)}
|
||||
</Alert>
|
||||
</BaseDialog>
|
||||
)
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import { useVerge } from '@/hooks/use-verge'
|
||||
import { useClashConfigData, useSystemData } from '@/providers/app-data-context'
|
||||
import {
|
||||
getAutotemProxy,
|
||||
getEmbeddedServerPort,
|
||||
getNetworkInterfacesInfo,
|
||||
getSystemHostname,
|
||||
getSystemProxy,
|
||||
@@ -134,6 +135,13 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
pac_content: pac_file_content ?? DEFAULT_PAC,
|
||||
proxy_host: proxy_host ?? '127.0.0.1',
|
||||
})
|
||||
const [embeddedServerPort, setEmbeddedServerPort] = useState<number | null>(
|
||||
null,
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
getEmbeddedServerPort().then(setEmbeddedServerPort).catch(console.error)
|
||||
}, [])
|
||||
|
||||
const separator = useMemo(() => (isWindows ? ';' : ','), [isWindows])
|
||||
|
||||
@@ -203,10 +211,10 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
])
|
||||
const getCurrentPacUrl = useMemo(() => {
|
||||
const host = value.proxy_host || '127.0.0.1'
|
||||
// 根据环境判断PAC端口
|
||||
const port = import.meta.env.DEV ? 11233 : 33331
|
||||
return `http://${host}:${port}/commands/pac`
|
||||
}, [value.proxy_host])
|
||||
return embeddedServerPort
|
||||
? `http://${host}:${embeddedServerPort}/commands/pac`
|
||||
: '-'
|
||||
}, [embeddedServerPort, value.proxy_host])
|
||||
|
||||
const bypassError =
|
||||
value.enable_bypass_check &&
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { alpha, Box, Button, LinearProgress } from '@mui/material'
|
||||
import { relaunch } from '@tauri-apps/plugin-process'
|
||||
import { open as openUrl } from '@tauri-apps/plugin-shell'
|
||||
import type { DownloadEvent } from '@tauri-apps/plugin-updater'
|
||||
import { useLockFn } from 'ahooks'
|
||||
@@ -17,6 +16,7 @@ import type { Options as ReactMarkdownOptions } from 'react-markdown'
|
||||
|
||||
import { BaseDialog, DialogRef } from '@/components/base'
|
||||
import { useUpdate } from '@/hooks/use-update'
|
||||
import { restartApp } from '@/services/cmds'
|
||||
import { showNotice } from '@/services/notice-service'
|
||||
import { useSetUpdateState, useUpdateState } from '@/services/states'
|
||||
|
||||
@@ -197,7 +197,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
|
||||
try {
|
||||
await updateInfo.downloadAndInstall(onDownloadEvent)
|
||||
await relaunch()
|
||||
await restartApp()
|
||||
} catch (err: any) {
|
||||
showNotice.error(err)
|
||||
} finally {
|
||||
|
||||
@@ -132,7 +132,7 @@ const ProxyControlSwitches = ({
|
||||
const { t } = useTranslation()
|
||||
const { verge, mutateVerge, patchVerge } = useVerge()
|
||||
const { installServiceAndRestartCore } = useServiceInstaller()
|
||||
const { uninstallServiceAndRestartCore } = useServiceUninstaller()
|
||||
const { uninstallServiceAndStartSidecar } = useServiceUninstaller()
|
||||
const { indicator: systemProxyIndicator, toggleSystemProxy } =
|
||||
useSystemProxyState()
|
||||
const { isServiceOk, isTunModeAvailable, mutateSystemState } =
|
||||
@@ -169,11 +169,7 @@ const ProxyControlSwitches = ({
|
||||
|
||||
const onUninstallService = useLockFn(async () => {
|
||||
try {
|
||||
if (verge?.enable_tun_mode) {
|
||||
await handleTunToggle(false)
|
||||
}
|
||||
await uninstallServiceAndRestartCore()
|
||||
await mutateSystemState()
|
||||
await uninstallServiceAndStartSidecar()
|
||||
} catch (err) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
|
||||
@@ -1,46 +1,33 @@
|
||||
import { useCallback } from 'react'
|
||||
|
||||
import { restartCore, stopCore, uninstallService } from '@/services/cmds'
|
||||
import { uninstallService } from '@/services/cmds'
|
||||
import { showNotice } from '@/services/notice-service'
|
||||
|
||||
const executeWithErrorHandling = async (
|
||||
operation: () => Promise<void>,
|
||||
loadingKey: string,
|
||||
successKey?: string,
|
||||
) => {
|
||||
try {
|
||||
showNotice.info(loadingKey)
|
||||
await operation()
|
||||
if (successKey) {
|
||||
showNotice.success(successKey)
|
||||
}
|
||||
} catch (err) {
|
||||
showNotice.error(err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
import { useSystemState } from './use-system-state'
|
||||
|
||||
export const useServiceUninstaller = () => {
|
||||
const uninstallServiceAndRestartCore = useCallback(async () => {
|
||||
const { mutateSystemState } = useSystemState()
|
||||
|
||||
const uninstallServiceAndStartSidecar = useCallback(async () => {
|
||||
let uninstallError: unknown
|
||||
showNotice.info('settings.statuses.clashService.uninstalling')
|
||||
try {
|
||||
await executeWithErrorHandling(
|
||||
() => stopCore(),
|
||||
'settings.statuses.clash.stopping',
|
||||
)
|
||||
await executeWithErrorHandling(
|
||||
() => uninstallService(),
|
||||
'settings.statuses.clashService.uninstalling',
|
||||
await uninstallService()
|
||||
showNotice.success(
|
||||
'settings.feedback.notifications.clashService.uninstallSuccess',
|
||||
)
|
||||
} catch (ignore) {
|
||||
} finally {
|
||||
await executeWithErrorHandling(
|
||||
() => restartCore(),
|
||||
'settings.statuses.clash.restarting',
|
||||
'settings.feedback.notifications.clash.restartSuccess',
|
||||
)
|
||||
} catch (error) {
|
||||
uninstallError = error
|
||||
}
|
||||
}, [])
|
||||
|
||||
return { uninstallServiceAndRestartCore }
|
||||
try {
|
||||
await mutateSystemState()
|
||||
} catch (error) {
|
||||
if (!uninstallError) throw error
|
||||
}
|
||||
|
||||
if (uninstallError) throw uninstallError
|
||||
}, [mutateSystemState])
|
||||
|
||||
return { uninstallServiceAndStartSidecar }
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { closeAllConnections } from 'tauri-plugin-mihomo-api'
|
||||
|
||||
import { useVerge } from '@/hooks/use-verge'
|
||||
import { useClashConfigData, useSystemData } from '@/providers/app-data-context'
|
||||
import { getAutotemProxy } from '@/services/cmds'
|
||||
import { getAutotemProxy, getEmbeddedServerPort } from '@/services/cmds'
|
||||
import { revalidateQueries, useQuery } from '@/services/query-client'
|
||||
|
||||
// 系统代理状态检测统一逻辑
|
||||
@@ -17,6 +17,10 @@ export const useSystemProxyState = () => {
|
||||
refetchOnWindowFocus: true,
|
||||
refetchOnReconnect: true,
|
||||
})
|
||||
const { data: pacPort } = useQuery({
|
||||
queryKey: ['getEmbeddedServerPort'],
|
||||
queryFn: getEmbeddedServerPort,
|
||||
})
|
||||
|
||||
const {
|
||||
enable_system_proxy,
|
||||
@@ -30,7 +34,7 @@ export const useSystemProxyState = () => {
|
||||
const host = proxy_host || '127.0.0.1'
|
||||
if (proxy_auto_config) {
|
||||
if (!autoproxy?.enable) return false
|
||||
const pacPort = import.meta.env.DEV ? 11233 : 33331
|
||||
if (!pacPort) return false
|
||||
return autoproxy.url === `http://${host}:${pacPort}/commands/pac`
|
||||
} else {
|
||||
if (!sysproxy?.enable) return false
|
||||
|
||||
@@ -1,24 +1,58 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
import { getRunningMode, isAdmin, isServiceAvailable } from '@/services/cmds'
|
||||
import {
|
||||
getRunningMode,
|
||||
getServiceInstallState,
|
||||
isAdmin,
|
||||
isServiceAvailable,
|
||||
type RunningMode,
|
||||
type ServiceInstallState,
|
||||
} from '@/services/cmds'
|
||||
import { showNotice } from '@/services/notice-service'
|
||||
import { useQuery } from '@/services/query-client'
|
||||
|
||||
import { useVerge } from './use-verge'
|
||||
import { useVisibility } from './use-visibility'
|
||||
|
||||
interface SystemState {
|
||||
runningMode: 'Sidecar' | 'Service'
|
||||
export interface SystemState {
|
||||
runningMode: RunningMode
|
||||
isAdminMode: boolean
|
||||
isServiceOk: boolean
|
||||
serviceInstallState: ServiceInstallState | null
|
||||
}
|
||||
|
||||
const defaultSystemState = {
|
||||
runningMode: 'Sidecar',
|
||||
isAdminMode: false,
|
||||
isServiceOk: false,
|
||||
serviceInstallState: null,
|
||||
} as SystemState
|
||||
|
||||
export const fetchSystemState = async (): Promise<SystemState> => {
|
||||
const [runningMode, isAdminMode, isServiceOk, serviceInstallState] =
|
||||
await Promise.all([
|
||||
getRunningMode(),
|
||||
isAdmin(),
|
||||
isServiceAvailable(),
|
||||
getServiceInstallState().catch(() => null),
|
||||
])
|
||||
return {
|
||||
runningMode,
|
||||
isAdminMode,
|
||||
isServiceOk,
|
||||
serviceInstallState,
|
||||
}
|
||||
}
|
||||
|
||||
const isServiceChoicePending = (
|
||||
state: ServiceInstallState | null,
|
||||
serviceAvailable: boolean,
|
||||
queryFailed: boolean,
|
||||
) =>
|
||||
queryFailed ||
|
||||
state === 'sidecarAllowed' ||
|
||||
!(state === 'notInstalled' || (state === 'ready' && serviceAvailable))
|
||||
|
||||
// Grace period for service initialization during startup
|
||||
const STARTUP_GRACE_MS = 10_000
|
||||
|
||||
@@ -39,16 +73,10 @@ export function useSystemState() {
|
||||
data: systemState = defaultSystemState,
|
||||
refetch: mutateSystemState,
|
||||
isLoading,
|
||||
error: systemStateError,
|
||||
} = useQuery({
|
||||
queryKey: ['getSystemState'],
|
||||
queryFn: async () => {
|
||||
const [runningMode, isAdminMode, isServiceOk] = await Promise.all([
|
||||
getRunningMode(),
|
||||
isAdmin(),
|
||||
isServiceAvailable(),
|
||||
])
|
||||
return { runningMode, isAdminMode, isServiceOk } as SystemState
|
||||
},
|
||||
queryFn: fetchSystemState,
|
||||
refetchInterval: pageVisible ? (isStartingUp ? 2000 : 30000) : false,
|
||||
refetchOnWindowFocus: true,
|
||||
refetchOnReconnect: true,
|
||||
@@ -57,6 +85,11 @@ export function useSystemState() {
|
||||
const isSidecarMode = systemState.runningMode === 'Sidecar'
|
||||
const isServiceMode = systemState.runningMode === 'Service'
|
||||
const isTunModeAvailable = systemState.isAdminMode || systemState.isServiceOk
|
||||
const serviceChoicePending = isServiceChoicePending(
|
||||
systemState.serviceInstallState,
|
||||
systemState.isServiceOk,
|
||||
systemStateError !== undefined,
|
||||
)
|
||||
|
||||
return {
|
||||
runningMode: systemState.runningMode,
|
||||
@@ -65,6 +98,7 @@ export function useSystemState() {
|
||||
isSidecarMode,
|
||||
isServiceMode,
|
||||
isTunModeAvailable,
|
||||
serviceChoicePending,
|
||||
mutateSystemState,
|
||||
isLoading,
|
||||
isStartingUp,
|
||||
@@ -73,7 +107,8 @@ export function useSystemState() {
|
||||
|
||||
export function useTunAvailabilityGuard() {
|
||||
const { verge, patchVerge } = useVerge()
|
||||
const { isTunModeAvailable, isLoading, isStartingUp } = useSystemState()
|
||||
const { isTunModeAvailable, serviceChoicePending, isLoading, isStartingUp } =
|
||||
useSystemState()
|
||||
const disablingTunRef = useRef(false)
|
||||
const cooldownTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const enable_tun_mode = verge?.enable_tun_mode
|
||||
@@ -85,6 +120,7 @@ export function useTunAvailabilityGuard() {
|
||||
!disablingTunRef.current &&
|
||||
enable_tun_mode &&
|
||||
!isTunModeAvailable &&
|
||||
!serviceChoicePending &&
|
||||
!isLoading &&
|
||||
!isStartingUp
|
||||
) {
|
||||
@@ -117,5 +153,12 @@ export function useTunAvailabilityGuard() {
|
||||
disablingTunRef.current = false
|
||||
}
|
||||
}
|
||||
}, [enable_tun_mode, isTunModeAvailable, patchVerge, isLoading, isStartingUp])
|
||||
}, [
|
||||
enable_tun_mode,
|
||||
isTunModeAvailable,
|
||||
serviceChoicePending,
|
||||
patchVerge,
|
||||
isLoading,
|
||||
isStartingUp,
|
||||
])
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Свернуть панель навигации",
|
||||
"expandNavBar": "Развернуть панель навигации"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "Collapse navigation bar",
|
||||
"expandNavBar": "Expand navigation bar"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "Service update required",
|
||||
"message": "An older Clash Verge service installation was detected. Reinstall it to use the current secure IPC protocol, or continue with Sidecar for this session.",
|
||||
"checkingMessage": "Checking the system service status and current running mode. Please wait…",
|
||||
"unavailableMessage": "The required Clash Verge service is not available. Install or repair it, or continue with Sidecar for this session.",
|
||||
"reinstall": "Reinstall service",
|
||||
"repair": "Repair service",
|
||||
"continueSidecar": "Continue with Sidecar",
|
||||
"success": "The Clash Verge service was updated successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "收起导航栏",
|
||||
"expandNavBar": "展开导航栏"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "需要更新系统服务",
|
||||
"message": "检测到旧版 Clash Verge 系统服务。重新安装后可使用当前安全 IPC 协议,也可以仅在本次会话继续使用 Sidecar。",
|
||||
"checkingMessage": "正在确认系统服务状态及当前运行模式,请稍候……",
|
||||
"unavailableMessage": "所需的 Clash Verge 系统服务当前不可用。你可以安装或修复服务,或仅在本次会话继续使用 Sidecar。",
|
||||
"reinstall": "重新安装服务",
|
||||
"repair": "修复服务",
|
||||
"continueSidecar": "继续使用 Sidecar",
|
||||
"success": "Clash Verge 系统服务已更新"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
"collapseNavBar": "收起導覽列",
|
||||
"expandNavBar": "展開導覽列"
|
||||
}
|
||||
},
|
||||
"serviceMigration": {
|
||||
"title": "需要更新系統服務",
|
||||
"message": "偵測到舊版 Clash Verge 系統服務。重新安裝後可使用目前的安全 IPC 協定,也可以僅在本次工作階段繼續使用 Sidecar。",
|
||||
"checkingMessage": "正在確認系統服務狀態及目前執行模式,請稍候……",
|
||||
"unavailableMessage": "所需的 Clash Verge 系統服務目前不可用。你可以安裝或修復服務,或僅在本次工作階段繼續使用 Sidecar。",
|
||||
"reinstall": "重新安裝服務",
|
||||
"repair": "修復服務",
|
||||
"continueSidecar": "繼續使用 Sidecar",
|
||||
"success": "Clash Verge 系統服務已更新"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import { BaseErrorBoundary } from '@/components/base'
|
||||
import { LayoutItem } from '@/components/layout/layout-item'
|
||||
import { LayoutTraffic } from '@/components/layout/layout-traffic'
|
||||
import { NoticeManager } from '@/components/layout/notice-manager'
|
||||
import { ServiceMigrationDialog } from '@/components/layout/service-migration-dialog'
|
||||
import { UpdateButton } from '@/components/layout/update-button'
|
||||
import {
|
||||
WindowControls,
|
||||
@@ -262,6 +263,7 @@ const Layout = () => {
|
||||
<ThemeProvider theme={theme}>
|
||||
{/* 左侧底部窗口控制按钮 */}
|
||||
<NoticeManager position={verge?.notice_position} />
|
||||
<ServiceMigrationDialog />
|
||||
<div
|
||||
style={{
|
||||
animation: 'fadeIn 0.5s',
|
||||
|
||||
+33
-7
@@ -190,12 +190,12 @@ export async function getAutotemProxy() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function changeClashCore(clashCore: string) {
|
||||
return invoke<string | null>('change_clash_core', { clashCore })
|
||||
export async function getEmbeddedServerPort() {
|
||||
return invoke<number>('get_embedded_server_port')
|
||||
}
|
||||
|
||||
export async function stopCore() {
|
||||
return invoke<void>('stop_core')
|
||||
export async function changeClashCore(clashCore: string) {
|
||||
return invoke<string | null>('change_clash_core', { clashCore })
|
||||
}
|
||||
|
||||
export async function restartCore() {
|
||||
@@ -358,8 +358,10 @@ export async function listLocalBackup() {
|
||||
}
|
||||
|
||||
// 获取当前运行模式
|
||||
export type RunningMode = 'Service' | 'Sidecar' | 'NotRunning'
|
||||
|
||||
export const getRunningMode = async () => {
|
||||
return invoke<string>('get_running_mode')
|
||||
return invoke<RunningMode>('get_running_mode')
|
||||
}
|
||||
|
||||
// 获取应用运行时间
|
||||
@@ -377,12 +379,36 @@ export const uninstallService = async () => {
|
||||
return invoke<void>('uninstall_service')
|
||||
}
|
||||
|
||||
export type ServiceInstallState =
|
||||
| 'checking'
|
||||
| 'notInstalled'
|
||||
| 'installRequired'
|
||||
| 'ready'
|
||||
| 'needsReinstall'
|
||||
| 'sidecarAllowed'
|
||||
| 'unavailable'
|
||||
|
||||
export const getServiceInstallState = async () => {
|
||||
return invoke<ServiceInstallState>('get_service_install_state')
|
||||
}
|
||||
|
||||
export const reinstallService = async () => {
|
||||
return invoke<void>('reinstall_service')
|
||||
}
|
||||
|
||||
export const repairService = async () => {
|
||||
return invoke<void>('repair_service')
|
||||
}
|
||||
|
||||
export const continueWithSidecar = async () => {
|
||||
return invoke<void>('continue_with_sidecar')
|
||||
}
|
||||
|
||||
// 系统服务是否可用
|
||||
export const isServiceAvailable = async () => {
|
||||
try {
|
||||
return await invoke<boolean>('is_service_available')
|
||||
} catch (error) {
|
||||
console.error('Service check failed:', error)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,14 @@ export const translationKeys = [
|
||||
'layout.components.navigation.menu.lock',
|
||||
'layout.components.navigation.menu.collapseNavBar',
|
||||
'layout.components.navigation.menu.expandNavBar',
|
||||
'layout.components.serviceMigration.title',
|
||||
'layout.components.serviceMigration.message',
|
||||
'layout.components.serviceMigration.checkingMessage',
|
||||
'layout.components.serviceMigration.unavailableMessage',
|
||||
'layout.components.serviceMigration.reinstall',
|
||||
'layout.components.serviceMigration.repair',
|
||||
'layout.components.serviceMigration.continueSidecar',
|
||||
'layout.components.serviceMigration.success',
|
||||
'logs.page.title',
|
||||
'logs.actions.showDescending',
|
||||
'logs.actions.showAscending',
|
||||
|
||||
@@ -194,6 +194,16 @@ export interface TranslationResources {
|
||||
unlock: string
|
||||
}
|
||||
}
|
||||
serviceMigration: {
|
||||
checkingMessage: string
|
||||
continueSidecar: string
|
||||
message: string
|
||||
reinstall: string
|
||||
repair: string
|
||||
success: string
|
||||
title: string
|
||||
unavailableMessage: string
|
||||
}
|
||||
}
|
||||
}
|
||||
logs: {
|
||||
|
||||
Reference in New Issue
Block a user