@antdp/user-login

登录界面
Installation
npm i @antdp/user-login --save
Basic Usage
import React, { useRef } from 'react';
import UserLogin from '@antdp/user-login';
import logo from './logo.svg';
export default (props) => {
const baseRef = useRef();
const TYPE = 'both';
return (
<UserLogin
logo={logo}
projectName="Ant Design"
loading={props.loading}
onFinish={(values) => {
let params;
if (TYPE === 'both') {
params =
baseRef?.current?.state?.key === '1'
? { username: values?.username, password: values?.password }
: { phone: values?.phone, code: values?.code };
} else {
params = values;
}
props.dispatch({
type: 'global/login',
payload: params,
});
}}
type={TYPE}
onSend={() => console.log('短信验证回调')}
formBtns={[
{
label: '登录',
attr: {
type: 'primary',
htmlType: 'submit',
style: {
marginRight: 20,
},
},
},
{
label: '重置',
attr: {
type: 'primary',
},
},
]}
/>
)
};
Props
import React from 'react';
import { FormProps, FormItemProps } from 'antd/lib/form';
import { InputProps } from 'antd/lib/input';
export interface formItem extends FormItemProps {
inputProps?: InputProps;
}
export interface UserLoginProps extends FormProps{
logo?: JSX.Element;
projectName?: string;
className?: string;
loading?: boolean;
formItems?: formItem[];
phoneFormItems?:formItem[];
phoneCodeProps?:formItemProps
onSend ?: () => void
type?:'phone' | 'account' | 'both',
children?:JSX.Element;
formChildren?:JSX.Element;
}