refactor: remove grant logic

This commit is contained in:
MystiPanda
2024-06-13 16:07:56 +08:00
parent 7b887e4cdd
commit a20d4959bf
6 changed files with 1 additions and 99 deletions

View File

@@ -6,17 +6,9 @@ import { useVerge } from "@/hooks/use-verge";
import { useLockFn } from "ahooks";
import { LoadingButton } from "@mui/lab";
import { SwitchAccessShortcut, RestartAlt } from "@mui/icons-material";
import {
Box,
Button,
Tooltip,
List,
ListItemButton,
ListItemText,
} from "@mui/material";
import { Box, Button, List, ListItemButton, ListItemText } from "@mui/material";
import { changeClashCore, restartSidecar } from "@/services/cmds";
import { closeAllConnections, upgradeCore } from "@/services/api";
import { grantPermission } from "@/services/cmds";
import getSystem from "@/utils/get-system";
const VALID_CORE = [
@@ -58,17 +50,6 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
}
});
const onGrant = useLockFn(async (core: string) => {
try {
await grantPermission(core);
// 自动重启
if (core === clash_core) await restartSidecar();
Notice.success(t("Permissions Granted Successfully for _clash Core", { core: `${core}` }), 1000);
} catch (err: any) {
Notice.error(err?.message || err.toString());
}
});
const onRestart = useLockFn(async () => {
try {
await restartSidecar();
@@ -140,22 +121,6 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
onClick={() => onCoreChange(each.core)}
>
<ListItemText primary={each.name} secondary={`/${each.core}`} />
{(OS === "macos" || OS === "linux") && (
<Tooltip title={t("Tun mode requires")}>
<Button
variant="outlined"
size="small"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
onGrant(each.core);
}}
>
{t("Grant")}
</Button>
</Tooltip>
)}
</ListItemButton>
))}
</List>