mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
feat: Try support service mode for MacOS
This commit is contained in:
@@ -17,24 +17,17 @@ interface Props {
|
||||
onError?: (err: Error) => void;
|
||||
}
|
||||
|
||||
const isServiceModeAvailable =
|
||||
getSystem() === "windows" || getSystem() === "linux";
|
||||
|
||||
const SettingSystem = ({ onError }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { verge, mutateVerge, patchVerge } = useVerge();
|
||||
|
||||
// service mode
|
||||
const { data: serviceStatus } = useSWR(
|
||||
isServiceModeAvailable ? "checkService" : null,
|
||||
checkService,
|
||||
{
|
||||
revalidateIfStale: false,
|
||||
shouldRetryOnError: false,
|
||||
focusThrottleInterval: 36e5, // 1 hour
|
||||
}
|
||||
);
|
||||
const { data: serviceStatus } = useSWR("checkService", checkService, {
|
||||
revalidateIfStale: false,
|
||||
shouldRetryOnError: false,
|
||||
focusThrottleInterval: 36e5, // 1 hour
|
||||
});
|
||||
|
||||
const serviceRef = useRef<DialogRef>(null);
|
||||
const sysproxyRef = useRef<DialogRef>(null);
|
||||
@@ -57,22 +50,13 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
<SettingList title={t("System Setting")}>
|
||||
<SysproxyViewer ref={sysproxyRef} />
|
||||
<TunViewer ref={tunRef} />
|
||||
{isServiceModeAvailable && (
|
||||
<ServiceViewer ref={serviceRef} enable={!!enable_service_mode} />
|
||||
)}
|
||||
<ServiceViewer ref={serviceRef} enable={!!enable_service_mode} />
|
||||
|
||||
<SettingItem
|
||||
label={t("Tun Mode")}
|
||||
extra={
|
||||
<>
|
||||
<Tooltip
|
||||
title={
|
||||
isServiceModeAvailable
|
||||
? t("Tun Mode Info Windows")
|
||||
: t("Tun Mode Info Unix")
|
||||
}
|
||||
placement="top"
|
||||
>
|
||||
<Tooltip title={t("Tun Mode Info")} placement="top">
|
||||
<IconButton color="inherit" size="small">
|
||||
<InfoRounded
|
||||
fontSize="inherit"
|
||||
@@ -105,39 +89,37 @@ const SettingSystem = ({ onError }: Props) => {
|
||||
</GuardState>
|
||||
</SettingItem>
|
||||
|
||||
{isServiceModeAvailable && (
|
||||
<SettingItem
|
||||
label={t("Service Mode")}
|
||||
extra={
|
||||
<IconButton
|
||||
color="inherit"
|
||||
size="small"
|
||||
onClick={() => serviceRef.current?.open()}
|
||||
>
|
||||
<PrivacyTipRounded
|
||||
fontSize="inherit"
|
||||
style={{ cursor: "pointer", opacity: 0.75 }}
|
||||
/>
|
||||
</IconButton>
|
||||
}
|
||||
>
|
||||
<GuardState
|
||||
value={enable_service_mode ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_service_mode: e })}
|
||||
onGuard={(e) => patchVerge({ enable_service_mode: e })}
|
||||
<SettingItem
|
||||
label={t("Service Mode")}
|
||||
extra={
|
||||
<IconButton
|
||||
color="inherit"
|
||||
size="small"
|
||||
onClick={() => serviceRef.current?.open()}
|
||||
>
|
||||
<Switch
|
||||
edge="end"
|
||||
disabled={
|
||||
serviceStatus !== "active" && serviceStatus !== "installed"
|
||||
}
|
||||
<PrivacyTipRounded
|
||||
fontSize="inherit"
|
||||
style={{ cursor: "pointer", opacity: 0.75 }}
|
||||
/>
|
||||
</GuardState>
|
||||
</SettingItem>
|
||||
)}
|
||||
</IconButton>
|
||||
}
|
||||
>
|
||||
<GuardState
|
||||
value={enable_service_mode ?? false}
|
||||
valueProps="checked"
|
||||
onCatch={onError}
|
||||
onFormat={onSwitchFormat}
|
||||
onChange={(e) => onChangeData({ enable_service_mode: e })}
|
||||
onGuard={(e) => patchVerge({ enable_service_mode: e })}
|
||||
>
|
||||
<Switch
|
||||
edge="end"
|
||||
disabled={
|
||||
serviceStatus !== "active" && serviceStatus !== "installed"
|
||||
}
|
||||
/>
|
||||
</GuardState>
|
||||
</SettingItem>
|
||||
|
||||
<SettingItem
|
||||
label={t("System Proxy")}
|
||||
|
||||
@@ -169,7 +169,6 @@
|
||||
"MTU": "Max Transmission Unit",
|
||||
|
||||
"Portable Updater Error": "The portable version does not support in-app updates. Please manually download and replace it",
|
||||
"Tun Mode Info Windows": "The Tun mode requires granting core-related permissions. Please enable service mode before using it",
|
||||
"Tun Mode Info Unix": "The Tun mode requires granting core-related permissions. Before using it, please authorize the core in the core settings",
|
||||
"Tun Mode Info": "The Tun mode requires granting core-related permissions. Please enable service mode before using it",
|
||||
"System and Mixed Can Only be Used in Service Mode": "System and Mixed Can Only be Used in Service Mode"
|
||||
}
|
||||
|
||||
@@ -177,7 +177,6 @@
|
||||
"Reset to Default": "重置为默认值",
|
||||
|
||||
"Portable Updater Error": "便携版不支持应用内更新,请手动下载替换",
|
||||
"Tun Mode Info Windows": "Tun模式需要授予内核相关权限,使用前请先开启服务模式",
|
||||
"Tun Mode Info Unix": "Tun模式需要授予内核相关权限,使用前请先在内核设置中给内核授权",
|
||||
"Tun Mode Info": "Tun模式需要授予内核相关权限,使用前请先开启服务模式",
|
||||
"System and Mixed Can Only be Used in Service Mode": "System和Mixed只能在服务模式下使用"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user