settings.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { Box, ButtonGroup, Grid, IconButton } from "@mui/material";
  2. import { useLockFn } from "ahooks";
  3. import { useTranslation } from "react-i18next";
  4. import { BasePage, Notice } from "@/components/base";
  5. import { GitHub, HelpOutlineSharp } from "@mui/icons-material";
  6. import { openWebUrl } from "@/services/cmds";
  7. import SettingVerge from "@/components/setting/setting-verge";
  8. import SettingClash from "@/components/setting/setting-clash";
  9. import SettingSystem from "@/components/setting/setting-system";
  10. import { useThemeMode } from "@/services/states";
  11. const SettingPage = () => {
  12. const { t } = useTranslation();
  13. const onError = (err: any) => {
  14. Notice.error(err?.message || err.toString());
  15. };
  16. const toGithubRepo = useLockFn(() => {
  17. return openWebUrl("https://github.com/clash-verge-rev/clash-verge-rev");
  18. });
  19. const toGithubDoc = useLockFn(() => {
  20. return openWebUrl("https://clash-verge-rev.github.io/guide/log.html");
  21. });
  22. const mode = useThemeMode();
  23. const isDark = mode === "light" ? false : true;
  24. return (
  25. <BasePage
  26. title={t("Settings")}
  27. header={
  28. <ButtonGroup variant="contained" aria-label="Basic button group">
  29. <IconButton
  30. size="medium"
  31. color="inherit"
  32. title="@clash-verge-rev/clash-verge-rev.github.io"
  33. onClick={toGithubDoc}
  34. >
  35. <HelpOutlineSharp fontSize="inherit" />
  36. </IconButton>
  37. <IconButton
  38. size="medium"
  39. color="inherit"
  40. title="@clash-verge-rev/clash-verge-rev"
  41. onClick={toGithubRepo}
  42. >
  43. <GitHub fontSize="inherit" />
  44. </IconButton>
  45. </ButtonGroup>
  46. }
  47. >
  48. <Grid container spacing={{ xs: 1.5, lg: 1.5 }}>
  49. <Grid item xs={12} md={6}>
  50. <Box
  51. sx={{
  52. borderRadius: 2,
  53. marginBottom: 1.5,
  54. backgroundColor: isDark ? "#282a36" : "#ffffff",
  55. }}
  56. >
  57. <SettingSystem onError={onError} />
  58. </Box>
  59. <Box
  60. sx={{
  61. borderRadius: 2,
  62. backgroundColor: isDark ? "#282a36" : "#ffffff",
  63. }}
  64. >
  65. <SettingClash onError={onError} />
  66. </Box>
  67. </Grid>
  68. <Grid item xs={12} md={6}>
  69. <Box
  70. sx={{
  71. borderRadius: 2,
  72. backgroundColor: isDark ? "#282a36" : "#ffffff",
  73. }}
  74. >
  75. <SettingVerge onError={onError} />
  76. </Box>
  77. </Grid>
  78. </Grid>
  79. </BasePage>
  80. );
  81. };
  82. export default SettingPage;