mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-24 13:14:16 +08:00
add user login and reg
This commit is contained in:
commit
2b3ce248b2
@ -1,41 +1,54 @@
|
||||
// import { React, Component } from '../../base.js'
|
||||
import './Login.scss'
|
||||
import React, { Component } from 'react'
|
||||
import { Button, Input, Icon, Checkbox } from 'antd'
|
||||
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
|
||||
import './Login.scss';
|
||||
import React, { Component } from 'react';
|
||||
import { Form, Button, Input, Icon, Checkbox } from 'antd';
|
||||
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
|
||||
const FormItem = Form.Item;
|
||||
|
||||
class Login extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
const form = this.props.form;
|
||||
|
||||
// 获取全部组件的值
|
||||
// console.log(form.getFieldsValue());
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
console.log('Received values of form: ', values);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props)
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
return (
|
||||
<acticle className="login-main">
|
||||
<span>{this.props.value}{this.props.per}</span>
|
||||
<section className="login-box">
|
||||
<div className="content">
|
||||
<Input
|
||||
size="large"
|
||||
placeholder="Username"
|
||||
prefix={<Icon type="user" style={{ fontSize: 16 }} />} />
|
||||
|
||||
<Input
|
||||
size="large"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
prefix={<Icon type="lock" style={{ fontSize: 16 }} />} />
|
||||
|
||||
<div className="login">
|
||||
<Checkbox>记住密码</Checkbox>
|
||||
<Button type="primary">登录</Button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</acticle>
|
||||
)
|
||||
<Form onSubmit={this.handleSubmit} className="login-form">
|
||||
<FormItem>
|
||||
{getFieldDecorator('userName', {
|
||||
rules: [{ required: true, message: '请输入用户名!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Username" />
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
{getFieldDecorator('password', {
|
||||
rules: [{ required: true, message: '请输入密码!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Password" />
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
{getFieldDecorator('remember', {
|
||||
valuePropName: 'checked',
|
||||
initialValue: true
|
||||
})(
|
||||
<Checkbox>记住密码</Checkbox>
|
||||
)}
|
||||
<Button type="primary" htmlType="submit" className="login-form-button">登录</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Login
|
||||
const LoginWrap = Form.create()(Login);
|
||||
|
||||
export default LoginWrap;
|
||||
|
@ -1,45 +1,7 @@
|
||||
@import '../../styles/common.scss';
|
||||
|
||||
/* .login-main.css */
|
||||
.login-main {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
height: 100%;
|
||||
-webkit-box-flex: 1;
|
||||
.login-form {
|
||||
width: 4rem;
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
/* .login-box.css */
|
||||
.login-box {
|
||||
font-size: 0.14rem;
|
||||
display: -webkit-box;
|
||||
-webkit-box-align: center;
|
||||
-webkit-box-pack: center;
|
||||
-webkit-box-flex: 1;
|
||||
|
||||
.content {
|
||||
max-width: 5rem;
|
||||
min-width: 3rem;
|
||||
zoom: 1;
|
||||
overflow: hidden;
|
||||
margin: -70px 0 0 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 0.2rem;
|
||||
}
|
||||
|
||||
a {
|
||||
font-size: 0.14rem;
|
||||
}
|
||||
|
||||
// ant 元素样式
|
||||
.ant-input-affix-wrapper {
|
||||
margin: 0 0 20px 0;
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
.login {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ const increaseAction = { type: 'increase' }
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
per: '测试数据',
|
||||
per: '测试数据'
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,4 +24,3 @@ const App = connect(
|
||||
)(Login)
|
||||
|
||||
export default App
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
"mongoose": "4.10.8",
|
||||
"mongoose-auto-increment": "^5.0.1",
|
||||
"node-sass-china": "^4.5.0",
|
||||
"sha1": "^1.1.1",
|
||||
"redux": "^3.7.1",
|
||||
"sha1": "^1.1.1",
|
||||
"ykit-config-antd": "^0.1.3",
|
||||
|
@ -46,12 +46,12 @@ class userModel extends baseModel{
|
||||
}
|
||||
del (id) {
|
||||
return this.model.deleteOne({
|
||||
_id: id
|
||||
_id: id
|
||||
})
|
||||
}
|
||||
update(id,data){
|
||||
return this.model.update({
|
||||
_id: id,
|
||||
_id: id
|
||||
},{
|
||||
username: data.username,
|
||||
password: data.password,
|
||||
|
Loading…
Reference in New Issue
Block a user