|
@@ -6,11 +6,14 @@ import {
|
|
|
Button,
|
|
Button,
|
|
|
FormControl,
|
|
FormControl,
|
|
|
Note,
|
|
Note,
|
|
|
|
|
+ IconButton,
|
|
|
} from "@contentful/f36-components";
|
|
} from "@contentful/f36-components";
|
|
|
|
|
+import { EyeIcon, EyeClosedIcon } from "@contentful/f36-icons";
|
|
|
import { useNavigate } from "react-router-dom";
|
|
import { useNavigate } from "react-router-dom";
|
|
|
import { authApi } from "@/services/modules/system";
|
|
import { authApi } from "@/services/modules/system";
|
|
|
import { useAuth } from "@/contexts/AuthContext";
|
|
import { useAuth } from "@/contexts/AuthContext";
|
|
|
import { useLoginAuth } from "./hooks/useAuth";
|
|
import { useLoginAuth } from "./hooks/useAuth";
|
|
|
|
|
+import { debounce } from "@/utils/lodash";
|
|
|
import styles from "./index.module.css";
|
|
import styles from "./index.module.css";
|
|
|
|
|
|
|
|
export default function LoginPage() {
|
|
export default function LoginPage() {
|
|
@@ -20,6 +23,7 @@ export default function LoginPage() {
|
|
|
const [captchaKey, setCaptchaKey] = useState("");
|
|
const [captchaKey, setCaptchaKey] = useState("");
|
|
|
const [captchaImage, setCaptchaImage] = useState("");
|
|
const [captchaImage, setCaptchaImage] = useState("");
|
|
|
const [errorMessage, setErrorMessage] = useState("");
|
|
const [errorMessage, setErrorMessage] = useState("");
|
|
|
|
|
+ const [showPassword, setShowPassword] = useState(false);
|
|
|
|
|
|
|
|
const navigate = useNavigate();
|
|
const navigate = useNavigate();
|
|
|
const { refreshAuth } = useAuth();
|
|
const { refreshAuth } = useAuth();
|
|
@@ -120,18 +124,32 @@ export default function LoginPage() {
|
|
|
{/* Password */}
|
|
{/* Password */}
|
|
|
<FormControl className={styles.form_control}>
|
|
<FormControl className={styles.form_control}>
|
|
|
<FormControl.Label>密码</FormControl.Label>
|
|
<FormControl.Label>密码</FormControl.Label>
|
|
|
- <TextInput
|
|
|
|
|
- type="password"
|
|
|
|
|
- value={password}
|
|
|
|
|
- onChange={(e) => {
|
|
|
|
|
- setPassword(e.target.value);
|
|
|
|
|
- // 清除错误提示
|
|
|
|
|
- if (errorMessage) {
|
|
|
|
|
- setErrorMessage("");
|
|
|
|
|
- }
|
|
|
|
|
- }}
|
|
|
|
|
- placeholder="请输入你的密码"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <Box className={styles.passwordInputWrapper}>
|
|
|
|
|
+ <TextInput
|
|
|
|
|
+ type={showPassword ? "text" : "password"}
|
|
|
|
|
+ value={password}
|
|
|
|
|
+ onChange={(e) => {
|
|
|
|
|
+ setPassword(e.target.value);
|
|
|
|
|
+ // 清除错误提示
|
|
|
|
|
+ if (errorMessage) {
|
|
|
|
|
+ setErrorMessage("");
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ placeholder="请输入你的密码"
|
|
|
|
|
+ />
|
|
|
|
|
+ <IconButton
|
|
|
|
|
+ aria-label={showPassword ? "隐藏密码" : "显示密码"}
|
|
|
|
|
+ icon={showPassword ? <EyeClosedIcon/> : <EyeIcon />}
|
|
|
|
|
+ variant="transparent"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ onClick={() => setShowPassword(!showPassword)}
|
|
|
|
|
+ className={styles.passwordToggle}
|
|
|
|
|
+ style={{
|
|
|
|
|
+ opacity: showPassword ? 0.5 : 1,
|
|
|
|
|
+ transform: showPassword ? 'scale(0.9)' : 'scale(1)'
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
|
|
+ </Box>
|
|
|
</FormControl>
|
|
</FormControl>
|
|
|
|
|
|
|
|
{/* Captcha */}
|
|
{/* Captcha */}
|
|
@@ -152,7 +170,7 @@ export default function LoginPage() {
|
|
|
/>
|
|
/>
|
|
|
</Box>
|
|
</Box>
|
|
|
<Box
|
|
<Box
|
|
|
- onClick={fetchCaptcha}
|
|
|
|
|
|
|
+ onClick={debounce(fetchCaptcha, 500)}
|
|
|
className={styles.captchaImage}
|
|
className={styles.captchaImage}
|
|
|
>
|
|
>
|
|
|
{captchaImage ? (
|
|
{captchaImage ? (
|