mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 03:32:36 +08:00
feat: show system proxy info
This commit is contained in:
parent
df5953dd7b
commit
7fc9631434
|
@ -1,5 +1,6 @@
|
|||
import useSWR, { useSWRConfig } from "swr";
|
||||
import {
|
||||
Box,
|
||||
List,
|
||||
ListItemText,
|
||||
ListSubheader,
|
||||
|
@ -12,6 +13,7 @@ import { version } from "../../package.json";
|
|||
import GuardState from "./guard-state";
|
||||
import SettingItem from "./setting-item";
|
||||
import PaletteSwitch from "./palette-switch";
|
||||
import SysproxyTooltip from "./sysproxy-tooltip";
|
||||
|
||||
interface Props {
|
||||
onError?: (err: Error) => void;
|
||||
|
@ -84,7 +86,14 @@ const SettingVerge = ({ onError }: Props) => {
|
|||
</SettingItem>
|
||||
|
||||
<SettingItem>
|
||||
<ListItemText primary="System Proxy" />
|
||||
<ListItemText
|
||||
primary={
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
System Proxy
|
||||
<SysproxyTooltip />
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
<GuardState
|
||||
value={proxy}
|
||||
valueProps="checked"
|
||||
|
|
53
src/components/sysproxy-tooltip.tsx
Normal file
53
src/components/sysproxy-tooltip.tsx
Normal file
|
@ -0,0 +1,53 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { InfoRounded } from "@mui/icons-material";
|
||||
import { ClickAwayListener, Tooltip } from "@mui/material";
|
||||
import { getSystemProxy } from "../services/cmds";
|
||||
|
||||
const SysproxyTooltip = () => {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [info, setInfo] = useState<any>({});
|
||||
|
||||
const onShow = async () => {
|
||||
const data = await getSystemProxy();
|
||||
console.log(data);
|
||||
setInfo(data ?? {});
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const timer = setTimeout(() => setOpen(false), 2000);
|
||||
return () => clearTimeout(timer);
|
||||
}, [open]);
|
||||
|
||||
// todo: add error info
|
||||
const showTitle = (
|
||||
<div>
|
||||
<div>Enable: {(!!info.enable).toString()}</div>
|
||||
<div>Server: {info.server}</div>
|
||||
<div>Bypass: {info.bypass}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<ClickAwayListener onClickAway={() => setOpen(false)}>
|
||||
<Tooltip
|
||||
PopperProps={{
|
||||
disablePortal: true,
|
||||
}}
|
||||
onClose={() => setOpen(false)}
|
||||
open={open}
|
||||
disableFocusListener
|
||||
disableHoverListener
|
||||
disableTouchListener
|
||||
placement="top"
|
||||
title={showTitle}
|
||||
arrow
|
||||
>
|
||||
<InfoRounded fontSize="small" onClick={onShow} />
|
||||
</Tooltip>
|
||||
</ClickAwayListener>
|
||||
);
|
||||
};
|
||||
|
||||
export default SysproxyTooltip;
|
|
@ -63,3 +63,7 @@ export async function getVergeConfig() {
|
|||
export async function patchVergeConfig(payload: CmdType.VergeConfig) {
|
||||
return invoke<void>("patch_verge_config", { payload });
|
||||
}
|
||||
|
||||
export async function getSystemProxy() {
|
||||
return invoke<any>("get_sys_proxy");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user