| | |
| | | import { useState } from 'react'; |
| | | import { |
| | | ApartmentOutlined, |
| | | CheckCircleFilled, |
| | | LockOutlined, |
| | | SafetyCertificateOutlined, |
| | | UserOutlined, |
| | | MobileOutlined, |
| | | } from '@ant-design/icons'; |
| | | import { App as AntdApp, Button, Form, Input, Tag } from 'antd'; |
| | | import { Navigate, useLocation, useNavigate } from 'react-router-dom'; |
| | |
| | | } finally { |
| | | setLoading(false); |
| | | } |
| | | }; |
| | | |
| | | const fillAccount = (username: string, password: string) => { |
| | | form.setFieldsValue({ username, password }); |
| | | }; |
| | | |
| | | return ( |
| | |
| | | layout="vertical" |
| | | size="large" |
| | | requiredMark={false} |
| | | initialValues={{ username: 'admin', password: 'admin123' }} |
| | | onFinish={handleFinish} |
| | | > |
| | | <Form.Item |
| | | name="username" |
| | | label="用户名" |
| | | rules={[{ required: true, message: '请输入用户名' }]} |
| | | name="tenant" |
| | | label="租户" |
| | | rules={[ |
| | | { required: true, whitespace: true, message: '请输入租户标识' }, |
| | | ]} |
| | | > |
| | | <Input |
| | | prefix={<UserOutlined />} |
| | | placeholder="请输入用户名" |
| | | autoComplete="username" |
| | | prefix={<ApartmentOutlined />} |
| | | placeholder="请输入租户标识" |
| | | autoComplete="organization" |
| | | /> |
| | | </Form.Item> |
| | | |
| | | <Form.Item |
| | | name="phone" |
| | | label="手机号" |
| | | rules={[ |
| | | { required: true, message: '请输入手机号' }, |
| | | { pattern: /^1\d{10}$/, message: '请输入正确的手机号' }, |
| | | ]} |
| | | > |
| | | <Input |
| | | prefix={<MobileOutlined />} |
| | | placeholder="请输入手机号" |
| | | autoComplete="tel" |
| | | maxLength={11} |
| | | /> |
| | | </Form.Item> |
| | | |
| | |
| | | 登 录 |
| | | </Button> |
| | | </Form> |
| | | |
| | | <div className="login-demo"> |
| | | <div className="login-demo__title"> |
| | | <SafetyCertificateOutlined /> 演示账号 |
| | | </div> |
| | | <div className="login-demo__accounts"> |
| | | <button type="button" onClick={() => fillAccount('admin', 'admin123')}> |
| | | <span>管理员</span> |
| | | <code>admin / admin123</code> |
| | | </button> |
| | | <button type="button" onClick={() => fillAccount('user', 'user123')}> |
| | | <span>普通用户</span> |
| | | <code>user / user123</code> |
| | | </button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </section> |
| | | </div> |