feat: Service Mode for Linux (#804)

This commit is contained in:
HZ is not Chatty
2024-03-31 16:16:23 +08:00
committed by GitHub
parent 503579a638
commit b0f1ce1fa0
12 changed files with 180 additions and 29 deletions

View File

@@ -17,7 +17,8 @@ interface Props {
onError?: (err: Error) => void;
}
const isWIN = getSystem() === "windows";
const isServiceModeAvailable =
getSystem() === "windows" || getSystem() === "linux";
const SettingSystem = ({ onError }: Props) => {
const { t } = useTranslation();
@@ -26,7 +27,7 @@ const SettingSystem = ({ onError }: Props) => {
// service mode
const { data: serviceStatus } = useSWR(
isWIN ? "checkService" : null,
isServiceModeAvailable ? "checkService" : null,
checkService,
{
revalidateIfStale: false,
@@ -56,7 +57,7 @@ const SettingSystem = ({ onError }: Props) => {
<SettingList title={t("System Setting")}>
<SysproxyViewer ref={sysproxyRef} />
<TunViewer ref={tunRef} />
{isWIN && (
{isServiceModeAvailable && (
<ServiceViewer ref={serviceRef} enable={!!enable_service_mode} />
)}
@@ -66,7 +67,9 @@ const SettingSystem = ({ onError }: Props) => {
<>
<Tooltip
title={
isWIN ? t("Tun Mode Info Windows") : t("Tun Mode Info Unix")
isServiceModeAvailable
? t("Tun Mode Info Windows")
: t("Tun Mode Info Unix")
}
placement="top"
>
@@ -102,7 +105,7 @@ const SettingSystem = ({ onError }: Props) => {
</GuardState>
</SettingItem>
{isWIN && (
{isServiceModeAvailable && (
<SettingItem
label={t("Service Mode")}
extra={