Skip to content
Snippets Groups Projects
Commit c1bcfc67 authored by GyDi's avatar GyDi
Browse files

feat: system proxy command demo

parent 3a9734e9
No related branches found
No related tags found
No related merge requests found
import { useState } from "react";
import { useRecoilState } from "recoil";
import {
Box,
......@@ -14,6 +15,7 @@ import {
} from "@mui/material";
import { atomPaletteMode } from "../states/setting";
import PaletteSwitch from "../components/palette-switch";
import { setSysProxy } from "../services/command";
const MiniListItem = styled(ListItem)(({ theme }) => ({
paddingTop: 5,
......@@ -22,6 +24,20 @@ const MiniListItem = styled(ListItem)(({ theme }) => ({
const SettingPage = () => {
const [mode, setMode] = useRecoilState(atomPaletteMode);
const [proxy, setProxy] = useState(false);
const onSysproxy = (enable: boolean) => {
const value = proxy;
setProxy(enable);
setSysProxy(enable)
.then(() => {
console.log("success");
})
.catch((err) => {
setProxy(value); // recover
console.log(err);
});
};
return (
<Box sx={{ width: 0.9, maxWidth: "850px", mx: "auto", mb: 2 }}>
......@@ -48,7 +64,11 @@ const SettingPage = () => {
<MiniListItem>
<ListItemText primary="设置系统代理" />
<Switch edge="end" />
<Switch
edge="end"
checked={proxy}
onChange={(_e, c) => onSysproxy(c)}
/>
</MiniListItem>
<MiniListItem>
......
......@@ -48,3 +48,7 @@ export async function setProfiles(current: number, profile: ProfileItem) {
export async function putProfiles(current: number) {
return invoke<void>("put_profiles", { current });
}
export async function setSysProxy(enable: boolean) {
return invoke<void>("set_sys_proxy", { enable });
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment