Files
clash-proxy/src/pages/settings.tsx

79 lines
2.2 KiB
TypeScript
Raw Normal View History

import { Box, Grid, IconButton, Paper } from "@mui/material";
2023-08-05 19:54:59 +08:00
import { useLockFn } from "ahooks";
2022-03-12 23:07:45 +08:00
import { useTranslation } from "react-i18next";
import { BasePage, Notice } from "@/components/base";
2023-08-05 19:54:59 +08:00
import { GitHub } from "@mui/icons-material";
import { openWebUrl } from "@/services/cmds";
2022-08-06 02:35:11 +08:00
import SettingVerge from "@/components/setting/setting-verge";
import SettingClash from "@/components/setting/setting-clash";
import SettingSystem from "@/components/setting/setting-system";
import { atomThemeMode } from "@/services/states";
import { useRecoilState } from "recoil";
import { useCustomTheme } from "@/components/layout/use-custom-theme";
2021-12-12 01:13:08 +08:00
2021-12-08 23:36:34 +08:00
const SettingPage = () => {
2022-03-12 23:07:45 +08:00
const { t } = useTranslation();
const onError = (err: any) => {
Notice.error(err?.message || err.toString());
2022-01-17 02:42:52 +08:00
};
2023-08-05 19:54:59 +08:00
const toGithubRepo = useLockFn(() => {
2023-12-02 23:04:04 +08:00
return openWebUrl("https://github.com/clash-verge-rev/clash-verge-rev");
2023-08-05 19:54:59 +08:00
});
const [mode] = useRecoilState(atomThemeMode);
const isDark = mode === "light" ? false : true;
const { theme } = useCustomTheme();
2021-12-09 23:28:57 +08:00
return (
2023-08-05 19:54:59 +08:00
<BasePage
title={t("Settings")}
header={
<IconButton
size="medium"
2023-08-05 19:54:59 +08:00
color="inherit"
2023-12-02 23:04:04 +08:00
title="@clash-verge-rev/clash-verge-rev"
2023-08-05 19:54:59 +08:00
onClick={toGithubRepo}
>
<GitHub fontSize="inherit" />
</IconButton>
}
>
<Grid container spacing={{ xs: 1.5, lg: 1.5 }}>
2023-10-20 10:05:03 +08:00
<Grid item xs={12} md={6}>
<Box
sx={{
borderRadius: 2,
marginBottom: 1.5,
backgroundColor: isDark ? "#282a36" : "#ffffff",
}}
>
<SettingSystem onError={onError} />
</Box>
<Box
sx={{
borderRadius: 2,
backgroundColor: isDark ? "#282a36" : "#ffffff",
}}
>
<SettingClash onError={onError} />
</Box>
2023-10-20 10:05:03 +08:00
</Grid>
<Grid item xs={12} md={6}>
<Box
sx={{
borderRadius: 2,
backgroundColor: isDark ? "#282a36" : "#ffffff",
}}
>
2023-10-20 10:05:03 +08:00
<SettingVerge onError={onError} />
</Box>
2023-10-20 10:05:03 +08:00
</Grid>
</Grid>
2022-01-16 03:11:07 +08:00
</BasePage>
2021-12-09 23:28:57 +08:00
);
2021-12-08 23:36:34 +08:00
};
export default SettingPage;