|
@@ -6,17 +6,9 @@ import { useVerge } from "@/hooks/use-verge";
|
|
import { useLockFn } from "ahooks";
|
|
import { useLockFn } from "ahooks";
|
|
import { LoadingButton } from "@mui/lab";
|
|
import { LoadingButton } from "@mui/lab";
|
|
import { SwitchAccessShortcut, RestartAlt } from "@mui/icons-material";
|
|
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 { changeClashCore, restartSidecar } from "@/services/cmds";
|
|
import { closeAllConnections, upgradeCore } from "@/services/api";
|
|
import { closeAllConnections, upgradeCore } from "@/services/api";
|
|
-import { grantPermission } from "@/services/cmds";
|
|
|
|
import getSystem from "@/utils/get-system";
|
|
import getSystem from "@/utils/get-system";
|
|
|
|
|
|
const VALID_CORE = [
|
|
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 () => {
|
|
const onRestart = useLockFn(async () => {
|
|
try {
|
|
try {
|
|
await restartSidecar();
|
|
await restartSidecar();
|
|
@@ -140,22 +121,6 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
|
|
onClick={() => onCoreChange(each.core)}
|
|
onClick={() => onCoreChange(each.core)}
|
|
>
|
|
>
|
|
<ListItemText primary={each.name} secondary={`/${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>
|
|
</ListItemButton>
|
|
))}
|
|
))}
|
|
</List>
|
|
</List>
|