feat: adjust setting typography
This commit is contained in:
parent
5eddf4f1aa
commit
40977785c3
67
src/components/setting/setting-system.tsx
Normal file
67
src/components/setting/setting-system.tsx
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import useSWR, { useSWRConfig } from "swr";
|
||||||
|
import { Box, ListItemText, Switch } from "@mui/material";
|
||||||
|
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
||||||
|
import { SettingList, SettingItem } from "./setting";
|
||||||
|
import { CmdType } from "../../services/types";
|
||||||
|
import GuardState from "./guard-state";
|
||||||
|
import SysproxyTooltip from "./sysproxy-tooltip";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
onError?: (err: Error) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SettingSystem = ({ onError }: Props) => {
|
||||||
|
const { mutate } = useSWRConfig();
|
||||||
|
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
||||||
|
|
||||||
|
const {
|
||||||
|
enable_auto_launch: startup = false,
|
||||||
|
enable_system_proxy: proxy = false,
|
||||||
|
} = vergeConfig ?? {};
|
||||||
|
|
||||||
|
const onSwitchFormat = (_e: any, value: boolean) => value;
|
||||||
|
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
|
||||||
|
mutate("getVergeConfig", { ...vergeConfig, ...patch }, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SettingList title="System Setting">
|
||||||
|
<SettingItem>
|
||||||
|
<ListItemText primary="Auto Launch" />
|
||||||
|
<GuardState
|
||||||
|
value={startup}
|
||||||
|
valueProps="checked"
|
||||||
|
onCatch={onError}
|
||||||
|
onFormat={onSwitchFormat}
|
||||||
|
onChange={(e) => onChangeData({ enable_auto_launch: e })}
|
||||||
|
onGuard={(e) => patchVergeConfig({ enable_auto_launch: e })}
|
||||||
|
>
|
||||||
|
<Switch edge="end" />
|
||||||
|
</GuardState>
|
||||||
|
</SettingItem>
|
||||||
|
|
||||||
|
<SettingItem>
|
||||||
|
<ListItemText
|
||||||
|
primary={
|
||||||
|
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||||
|
System Proxy
|
||||||
|
<SysproxyTooltip />
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<GuardState
|
||||||
|
value={proxy}
|
||||||
|
valueProps="checked"
|
||||||
|
onCatch={onError}
|
||||||
|
onFormat={onSwitchFormat}
|
||||||
|
onChange={(e) => onChangeData({ enable_system_proxy: e })}
|
||||||
|
onGuard={(e) => patchVergeConfig({ enable_system_proxy: e })}
|
||||||
|
>
|
||||||
|
<Switch edge="end" />
|
||||||
|
</GuardState>
|
||||||
|
</SettingItem>
|
||||||
|
</SettingList>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SettingSystem;
|
@ -1,12 +1,11 @@
|
|||||||
import useSWR, { useSWRConfig } from "swr";
|
import useSWR, { useSWRConfig } from "swr";
|
||||||
import { Box, ListItemText, Switch, Typography } from "@mui/material";
|
import { ListItemText, Switch, Typography } from "@mui/material";
|
||||||
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
||||||
import { SettingList, SettingItem } from "./setting";
|
import { SettingList, SettingItem } from "./setting";
|
||||||
import { CmdType } from "../../services/types";
|
import { CmdType } from "../../services/types";
|
||||||
import { version } from "../../../package.json";
|
import { version } from "../../../package.json";
|
||||||
import GuardState from "./guard-state";
|
import GuardState from "./guard-state";
|
||||||
import PaletteSwitch from "./palette-switch";
|
import PaletteSwitch from "./palette-switch";
|
||||||
import SysproxyTooltip from "./sysproxy-tooltip";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onError?: (err: Error) => void;
|
onError?: (err: Error) => void;
|
||||||
@ -16,12 +15,8 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
||||||
|
|
||||||
const {
|
const { theme_mode: mode = "light", theme_blur: blur = false } =
|
||||||
theme_mode: mode = "light",
|
vergeConfig ?? {};
|
||||||
theme_blur: blur = false,
|
|
||||||
enable_auto_launch: startup = false,
|
|
||||||
enable_system_proxy: proxy = false,
|
|
||||||
} = vergeConfig ?? {};
|
|
||||||
|
|
||||||
const onSwitchFormat = (_e: any, value: boolean) => value;
|
const onSwitchFormat = (_e: any, value: boolean) => value;
|
||||||
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
|
const onChangeData = (patch: Partial<CmdType.VergeConfig>) => {
|
||||||
@ -29,7 +24,7 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingList title="Common Setting">
|
<SettingList title="Verge Setting">
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Theme Mode" />
|
<ListItemText primary="Theme Mode" />
|
||||||
<GuardState
|
<GuardState
|
||||||
@ -60,41 +55,6 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
</GuardState>
|
</GuardState>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
|
||||||
<ListItemText primary="Auto Launch" />
|
|
||||||
<GuardState
|
|
||||||
value={startup}
|
|
||||||
valueProps="checked"
|
|
||||||
onCatch={onError}
|
|
||||||
onFormat={onSwitchFormat}
|
|
||||||
onChange={(e) => onChangeData({ enable_auto_launch: e })}
|
|
||||||
onGuard={(e) => patchVergeConfig({ enable_auto_launch: e })}
|
|
||||||
>
|
|
||||||
<Switch edge="end" />
|
|
||||||
</GuardState>
|
|
||||||
</SettingItem>
|
|
||||||
|
|
||||||
<SettingItem>
|
|
||||||
<ListItemText
|
|
||||||
primary={
|
|
||||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
|
||||||
System Proxy
|
|
||||||
<SysproxyTooltip />
|
|
||||||
</Box>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<GuardState
|
|
||||||
value={proxy}
|
|
||||||
valueProps="checked"
|
|
||||||
onCatch={onError}
|
|
||||||
onFormat={onSwitchFormat}
|
|
||||||
onChange={(e) => onChangeData({ enable_system_proxy: e })}
|
|
||||||
onGuard={(e) => patchVergeConfig({ enable_system_proxy: e })}
|
|
||||||
>
|
|
||||||
<Switch edge="end" />
|
|
||||||
</GuardState>
|
|
||||||
</SettingItem>
|
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Version" />
|
<ListItemText primary="Version" />
|
||||||
<Typography sx={{ py: "6px" }}>v{version}</Typography>
|
<Typography sx={{ py: "6px" }}>v{version}</Typography>
|
||||||
|
@ -6,9 +6,7 @@ export const SettingItem = styled(ListItem)(() => ({
|
|||||||
paddingBottom: 5,
|
paddingBottom: 5,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const SettingList: React.FC<{
|
export const SettingList: React.FC<{ title: string }> = (props) => (
|
||||||
title: string;
|
|
||||||
}> = (props) => (
|
|
||||||
<List>
|
<List>
|
||||||
<ListSubheader sx={{ background: "transparent" }} disableSticky>
|
<ListSubheader sx={{ background: "transparent" }} disableSticky>
|
||||||
{props.title}
|
{props.title}
|
||||||
|
@ -2,16 +2,26 @@ import { Paper } from "@mui/material";
|
|||||||
import BasePage from "../components/base-page";
|
import BasePage from "../components/base-page";
|
||||||
import SettingVerge from "../components/setting/setting-verge";
|
import SettingVerge from "../components/setting/setting-verge";
|
||||||
import SettingClash from "../components/setting/setting-clash";
|
import SettingClash from "../components/setting/setting-clash";
|
||||||
|
import SettingSystem from "../components/setting/setting-system";
|
||||||
|
import Notice from "../components/notice";
|
||||||
|
|
||||||
const SettingPage = () => {
|
const SettingPage = () => {
|
||||||
|
const onError = (error: any) => {
|
||||||
|
error && Notice.error(error.toString());
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage title="Settings">
|
<BasePage title="Settings">
|
||||||
<Paper sx={{ borderRadius: 1, boxShadow: 2 }}>
|
<Paper sx={{ borderRadius: 1, boxShadow: 2, mb: 3 }}>
|
||||||
<SettingVerge />
|
<SettingClash onError={onError} />
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
<Paper sx={{ borderRadius: 1, boxShadow: 2, mt: 3 }}>
|
<Paper sx={{ borderRadius: 1, boxShadow: 2, mb: 3 }}>
|
||||||
<SettingClash />
|
<SettingSystem onError={onError} />
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Paper sx={{ borderRadius: 1, boxShadow: 2 }}>
|
||||||
|
<SettingVerge onError={onError} />
|
||||||
</Paper>
|
</Paper>
|
||||||
</BasePage>
|
</BasePage>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user