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

refactor: setting page

parent d6c3bc57
No related branches found
No related tags found
No related merge requests found
import { ListItem, styled } from "@mui/material";
const SettingItem = styled(ListItem)(() => ({
paddingTop: 5,
paddingBottom: 5,
}));
export default SettingItem;
import useSWR, { useSWRConfig } from "swr";
import {
List,
ListItemText,
ListSubheader,
TextField,
Switch,
Select,
MenuItem,
} from "@mui/material";
import { getClashConfig, updateConfigs } from "../services/api";
import { patchClashConfig } from "../services/cmds";
import { ApiType } from "../services/types";
import GuardState from "./guard-state";
import SettingItem from "./setting-item";
import { getClashConfig, updateConfigs } from "../../services/api";
import { SettingList, SettingItem } from "./setting";
import { patchClashConfig } from "../../services/cmds";
import { ApiType } from "../../services/types";
import GuardState from "../guard-state";
interface Props {
onError?: (err: Error) => void;
......@@ -30,22 +28,16 @@ const SettingClash = ({ onError }: Props) => {
} = clashConfig ?? {};
const onSwitchFormat = (_e: any, value: boolean) => value;
const onChangeData = (patch: Partial<ApiType.ConfigData>) => {
mutate("getClashConfig", { ...clashConfig, ...patch }, false);
};
const onUpdateData = async (patch: Partial<ApiType.ConfigData>) => {
await updateConfigs(patch);
await patchClashConfig(patch);
};
return (
<List>
<ListSubheader sx={{ background: "transparent" }}>
Clash Setting
</ListSubheader>
<SettingList title="Clash Setting">
<SettingItem>
<ListItemText primary="Allow Lan" />
<GuardState
......@@ -102,7 +94,7 @@ const SettingClash = ({ onError }: Props) => {
disabled
/>
</SettingItem>
</List>
</SettingList>
);
};
......
import useSWR, { useSWRConfig } from "swr";
import {
Box,
List,
ListItemText,
ListSubheader,
Switch,
Typography,
} from "@mui/material";
import { getVergeConfig, patchVergeConfig } from "../services/cmds";
import { CmdType } from "../services/types";
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";
import { Box, ListItemText, Switch, Typography } from "@mui/material";
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
import { SettingList, SettingItem } from "./setting";
import { CmdType } from "../../services/types";
import { version } from "../../../package.json";
import GuardState from "../guard-state";
import PaletteSwitch from "../palette-switch";
import SysproxyTooltip from "../sysproxy-tooltip";
interface Props {
onError?: (err: Error) => void;
......@@ -36,11 +29,7 @@ const SettingVerge = ({ onError }: Props) => {
};
return (
<List>
<ListSubheader sx={{ background: "transparent" }}>
Common Setting
</ListSubheader>
<SettingList title="Common Setting">
<SettingItem>
<ListItemText primary="Theme Mode" />
<GuardState
......@@ -110,7 +99,7 @@ const SettingVerge = ({ onError }: Props) => {
<ListItemText primary="Version" />
<Typography sx={{ py: "6px" }}>v{version}</Typography>
</SettingItem>
</List>
</SettingList>
);
};
......
import React from "react";
import { List, ListItem, ListSubheader, styled } from "@mui/material";
export const SettingItem = styled(ListItem)(() => ({
paddingTop: 5,
paddingBottom: 5,
}));
export const SettingList: React.FC<{
title: string;
}> = (props) => (
<List>
<ListSubheader sx={{ background: "transparent" }} disableSticky>
{props.title}
</ListSubheader>
{props.children}
</List>
);
import { Paper } from "@mui/material";
import BasePage from "../components/base-page";
import SettingVerge from "../components/setting-verge";
import SettingClash from "../components/setting-clash";
import SettingVerge from "../components/setting/setting-verge";
import SettingClash from "../components/setting/setting-clash";
const SettingPage = () => {
return (
......
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