login page

This commit is contained in:
lix
2025-07-08 14:59:01 +08:00
parent 1e940183cd
commit f4f1f51393
3 changed files with 45 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import React, { useEffect, useRef, useState } from 'react';
import { Form, Input, Button, Checkbox, Card, Typography } from 'antd';
import { UserOutlined, LockOutlined, EyeInvisibleOutlined, EyeTwoTone } from '@ant-design/icons';
import { history } from '@umijs/max';
import { history, Helmet } from '@umijs/max';
import cookie from 'react-cookies';
import CaptchaInput from '@/components/CaptchaInput';
import styles from './internal.less';
@ -29,13 +29,21 @@ const InternalLogin: React.FC = () => {
account: values.username,
password: values.password,
captcha: values.captcha,
remember: values.remember,
}
try {
setLoading(true);
const res = await internalUserLogin(params);
setLoading(false);
if (res?.code === 200) {
sessionStorage.setItem('Authorization', res?.data?.token || '');
if (values.remember) {
localStorage.setItem('remember_user', JSON.stringify({
username: values.username,
password: values.password,
}));
} else {
localStorage.removeItem('remember_user');
}
history.push('/redirect');
} else {
captchaRef.current?.refresh();
@ -48,8 +56,6 @@ const InternalLogin: React.FC = () => {
}
} catch (error) {
console.error('登录失败:', error);
} finally {
setLoading(false);
}
};
@ -137,6 +143,9 @@ const InternalLogin: React.FC = () => {
return (
<div className={styles.loginContainer}>
<Helmet>
<title></title>
</Helmet>
<Card className={styles.loginCard}>
<Title level={2} style={{ textAlign: 'center', lineHeight: '80px', fontSize: 32, fontWeight: 700, marginBottom: 0 }}>