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