ConnectContainer.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import { useEffect, useState, useContext } from 'react';
  2. import Typography from '@mui/material/Typography';
  3. import { useTranslation } from 'react-i18next';
  4. import Icons from '@/components/icons/Icons';
  5. import { AuthForm } from './AuthForm';
  6. import CustomButton from '@/components/customButton/CustomButton';
  7. import { MilvusService } from '@/http';
  8. import Box from '@mui/material/Box';
  9. import type { Theme } from '@mui/material/styles';
  10. import { ColorModeContext } from '@/context';
  11. import { IconButton } from '@mui/material';
  12. import {
  13. ATTU_SOURCE_CODE,
  14. ATTU_ISSUES,
  15. ATTU_DISCORD,
  16. ATTU_OFFICE_HOURS,
  17. } from '@/consts/link';
  18. const ConnectContainer = () => {
  19. const [version, setVersion] = useState('loading');
  20. const { t: commonTrans } = useTranslation();
  21. const { t: btnTrans } = useTranslation('btn');
  22. const { mode, toggleColorMode } = useContext(ColorModeContext);
  23. useEffect(() => {
  24. MilvusService.getVersion().then((res: any) => {
  25. setVersion(res.attu);
  26. });
  27. }, []);
  28. return (
  29. <Box
  30. className="flex-center"
  31. sx={{
  32. width: '100%',
  33. height: '100vh',
  34. color: 'text.primary',
  35. backgroundColor: 'background.default',
  36. }}
  37. >
  38. <Box
  39. sx={{
  40. display: 'flex',
  41. flexDirection: 'row',
  42. backgroundColor: 'background.default',
  43. border: (theme: Theme) => `1px solid ${theme.palette.divider}`,
  44. borderRadius: 2,
  45. minHeight: 680,
  46. }}
  47. >
  48. <Box
  49. className="flex-center"
  50. sx={{
  51. width: 320,
  52. display: 'flex',
  53. flexDirection: 'column',
  54. padding: (theme: Theme) => theme.spacing(4, 3),
  55. backgroundColor: (theme: Theme) =>
  56. theme.palette.mode === 'dark'
  57. ? theme.palette.background.default
  58. : theme.palette.neutral[50],
  59. borderRadius: '12px 0 0 12px',
  60. position: 'relative',
  61. }}
  62. >
  63. <IconButton
  64. onClick={toggleColorMode}
  65. color="inherit"
  66. size="small"
  67. sx={{
  68. position: 'absolute',
  69. top: 16,
  70. right: 16,
  71. '& svg': { fontSize: 14 },
  72. }}
  73. >
  74. {mode === 'dark' ? <Icons.night /> : <Icons.day />}
  75. </IconButton>
  76. <Icons.attu
  77. sx={{
  78. width: 72,
  79. height: 'auto',
  80. marginBottom: (theme: Theme) => theme.spacing(2),
  81. display: 'block',
  82. color: 'primary.main',
  83. }}
  84. />
  85. <Typography
  86. variant="h5"
  87. sx={{
  88. fontWeight: 600,
  89. color: (theme: Theme) =>
  90. theme.palette.mode === 'dark'
  91. ? theme.palette.common.white
  92. : 'primary.contrastText',
  93. marginTop: (theme: Theme) => theme.spacing(2),
  94. height: 32,
  95. }}
  96. >
  97. {commonTrans('attu.admin')}
  98. </Typography>
  99. {version && (
  100. <Typography
  101. component="sub"
  102. sx={{
  103. marginTop: (theme: Theme) => theme.spacing(1),
  104. fontSize: 13,
  105. color: (theme: Theme) =>
  106. theme.palette.mode === 'dark'
  107. ? theme.palette.common.white
  108. : 'primary.contrastText',
  109. opacity: 0.8,
  110. height: 16,
  111. }}
  112. >
  113. {commonTrans('attu.version')}: {version}
  114. </Typography>
  115. )}
  116. <Box
  117. sx={{
  118. marginTop: (theme: Theme) => theme.spacing(6),
  119. display: 'flex',
  120. flexDirection: 'column',
  121. alignItems: 'center',
  122. justifyContent: 'center',
  123. width: '100%',
  124. gap: (theme: Theme) => theme.spacing(2),
  125. '& button': {
  126. borderColor: (theme: Theme) =>
  127. theme.palette.mode === 'dark'
  128. ? theme.palette.common.white
  129. : 'primary.contrastText',
  130. color: (theme: Theme) =>
  131. theme.palette.mode === 'dark'
  132. ? theme.palette.common.white
  133. : 'primary.contrastText',
  134. height: 40,
  135. fontSize: 14,
  136. '&:hover': {
  137. backgroundColor: 'primary.main',
  138. borderColor: 'primary.main',
  139. },
  140. },
  141. }}
  142. >
  143. <CustomButton
  144. startIcon={<Icons.star />}
  145. fullWidth={true}
  146. variant="outlined"
  147. onClick={() => window.open(ATTU_SOURCE_CODE, '_blank')}
  148. >
  149. {btnTrans('star')}
  150. </CustomButton>
  151. <CustomButton
  152. startIcon={<Icons.github />}
  153. fullWidth={true}
  154. variant="outlined"
  155. onClick={() => window.open(ATTU_ISSUES, '_blank')}
  156. >
  157. {commonTrans('attu.fileIssue')}
  158. </CustomButton>
  159. <CustomButton
  160. startIcon={<Icons.discord />}
  161. variant="outlined"
  162. onClick={() => window.open(ATTU_DISCORD, '_blank')}
  163. fullWidth={true}
  164. >
  165. {commonTrans('attu.discord')}
  166. </CustomButton>
  167. <CustomButton
  168. startIcon={<Icons.calendar />}
  169. variant="outlined"
  170. onClick={() => window.open(ATTU_OFFICE_HOURS, '_blank')}
  171. fullWidth={true}
  172. >
  173. {commonTrans('attu.officeHours')}
  174. </CustomButton>
  175. </Box>
  176. </Box>
  177. <Box
  178. sx={{
  179. width: 500,
  180. borderRadius: '0 8px 8px 0',
  181. padding: (theme: Theme) => theme.spacing(6, 0),
  182. backgroundColor: 'background.paper',
  183. }}
  184. >
  185. <AuthForm />
  186. </Box>
  187. </Box>
  188. </Box>
  189. );
  190. };
  191. export default ConnectContainer;