fixup! feat: Service Mode for Linux (#804)
This commit is contained in:
@@ -185,22 +185,14 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
||||
let tun_tray_icon = patch.tun_tray_icon;
|
||||
|
||||
match {
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
{
|
||||
let service_mode = patch.enable_service_mode;
|
||||
let service_mode = patch.enable_service_mode;
|
||||
|
||||
if service_mode.is_some() {
|
||||
log::debug!(target: "app", "change service mode to {}", service_mode.unwrap());
|
||||
if service_mode.is_some() {
|
||||
log::debug!(target: "app", "change service mode to {}", service_mode.unwrap());
|
||||
|
||||
Config::generate()?;
|
||||
CoreManager::global().run_core().await?;
|
||||
} else if tun_mode.is_some() {
|
||||
update_core_config().await?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
if tun_mode.is_some() {
|
||||
Config::generate()?;
|
||||
CoreManager::global().run_core().await?;
|
||||
} else if tun_mode.is_some() {
|
||||
update_core_config().await?;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,8 @@ import { useTranslation } from "react-i18next";
|
||||
import { Button, ButtonGroup, Tooltip } from "@mui/material";
|
||||
import { checkService } from "@/services/cmds";
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
import getSystem from "@/utils/get-system";
|
||||
import useSWR from "swr";
|
||||
|
||||
const isWIN = getSystem() === "windows";
|
||||
|
||||
interface Props {
|
||||
value?: string;
|
||||
onChange?: (value: string) => void;
|
||||
@@ -17,21 +14,17 @@ export const StackModeSwitch = (props: Props) => {
|
||||
const { verge } = useVerge();
|
||||
const { enable_service_mode } = verge ?? {};
|
||||
// service mode
|
||||
const { data: serviceStatus } = useSWR(
|
||||
isWIN ? "checkService" : null,
|
||||
checkService,
|
||||
{
|
||||
revalidateIfStale: false,
|
||||
shouldRetryOnError: false,
|
||||
}
|
||||
);
|
||||
const { data: serviceStatus } = useSWR("checkService", checkService, {
|
||||
revalidateIfStale: false,
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
title={
|
||||
isWIN && (serviceStatus !== "active" || !enable_service_mode)
|
||||
serviceStatus !== "active" || !enable_service_mode
|
||||
? t("System and Mixed Can Only be Used in Service Mode")
|
||||
: ""
|
||||
}
|
||||
@@ -40,9 +33,7 @@ export const StackModeSwitch = (props: Props) => {
|
||||
<Button
|
||||
variant={value?.toLowerCase() === "system" ? "contained" : "outlined"}
|
||||
onClick={() => onChange?.("system")}
|
||||
disabled={
|
||||
isWIN && (serviceStatus !== "active" || !enable_service_mode)
|
||||
}
|
||||
disabled={serviceStatus !== "active" || !enable_service_mode}
|
||||
sx={{ textTransform: "capitalize" }}
|
||||
>
|
||||
System
|
||||
@@ -58,9 +49,7 @@ export const StackModeSwitch = (props: Props) => {
|
||||
<Button
|
||||
variant={value?.toLowerCase() === "mixed" ? "contained" : "outlined"}
|
||||
onClick={() => onChange?.("mixed")}
|
||||
disabled={
|
||||
isWIN && (serviceStatus !== "active" || !enable_service_mode)
|
||||
}
|
||||
disabled={serviceStatus !== "active" || !enable_service_mode}
|
||||
sx={{ textTransform: "capitalize" }}
|
||||
>
|
||||
Mixed
|
||||
|
||||
Reference in New Issue
Block a user