mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-20 14:33:49 +00:00
eslint view
This commit is contained in:
+1
-1
@@ -52,7 +52,7 @@
|
||||
"prod": "NODE_ENV=production webpack --progress --colors --config webpack.config.prod.js -p --display-error-details",
|
||||
"clean": "rm dist/bundle*",
|
||||
"dev": "webpack-dev-server --devtool eval --progress --colors --content-base dist --hot --inline --display-error-details",
|
||||
"eslint": "eslint --ext .js,.jsx src",
|
||||
"eslint": "eslint --ext .js,.jsx src/view",
|
||||
"stylelint": "stylelint \"src/**/*.css\"",
|
||||
"lesshint": "lesshint src/"
|
||||
}
|
||||
|
||||
+28
-23
@@ -4,13 +4,12 @@ import Header from '../components/Header'
|
||||
import Footer from '../components/Footer'
|
||||
import Sidebar from '../components/Sidebar'
|
||||
import SignIn from './user/SignIn'
|
||||
// import SignIn from '../components/Login'
|
||||
import Breadcrumb from '../components/Breadcrumb'
|
||||
import {ajax,config,logger} from '../utils/lib.js'
|
||||
import {Spin, message} from 'antd'
|
||||
import { ajax, config, logger } from '../utils/lib.js'
|
||||
import { Spin, message } from 'antd'
|
||||
|
||||
const App = React.createClass({
|
||||
getInitialState: function () {
|
||||
getInitialState() {
|
||||
return {
|
||||
// loading: true,
|
||||
// login: false,
|
||||
@@ -19,10 +18,7 @@ const App = React.createClass({
|
||||
userName: '未登录',
|
||||
}
|
||||
},
|
||||
componentWillMount() {
|
||||
|
||||
},
|
||||
componentDidMount(){
|
||||
componentDidMount() {
|
||||
if (!this.state.login) {
|
||||
const hide = message.loading('正在获取用户信息...', 0)
|
||||
ajax.get(`${config.getAPIPath()}${config.login.getCurrentUser}`).end((err, res) => {
|
||||
@@ -39,43 +35,52 @@ const App = React.createClass({
|
||||
hide()
|
||||
message.error('获取用户信息失败, 请重新登录')
|
||||
logger.debug('not login, redirect to Login component')
|
||||
this.setState({loading: false, login: false})
|
||||
this.setState({
|
||||
loading: false,
|
||||
login: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
loginSuccess (name, showMsg){
|
||||
loginSuccess(name, showMsg) {
|
||||
logger.debug('callback logingSuccess, name = %s', name)
|
||||
if (showMsg)
|
||||
if (showMsg) {
|
||||
message.success('登录成功')
|
||||
this.setState({loading: false, login: true, userName: name})
|
||||
},
|
||||
render(){
|
||||
if (this.state.loading) {
|
||||
return <Spin spinning={this.state.loading} size="large"><SignIn loginSuccess={this.loginSuccess}/></Spin>
|
||||
} else if (!this.state.login) {
|
||||
return <SignIn loginSuccess={this.loginSuccess}/>
|
||||
}
|
||||
|
||||
this.setState({
|
||||
loading: false,
|
||||
login: true,
|
||||
userName: name,
|
||||
})
|
||||
},
|
||||
render() {
|
||||
if (this.state.loading) {
|
||||
return (<Spin spinning={this.state.loading} size="large">
|
||||
<SignIn loginSuccess= {this.loginSuccess} />
|
||||
</Spin>)
|
||||
} else if (!this.state.login) {
|
||||
return <SignIn loginSuccess={this.loginSuccess} />
|
||||
}
|
||||
return (
|
||||
<div className="ant-layout-aside">
|
||||
<Sidebar/>
|
||||
<Sidebar />
|
||||
<div id="main-content-div" className="ant-layout-main">
|
||||
<Spin spinning={this.state.loading} size="large">
|
||||
<Header userName={this.state.userName}/>
|
||||
<Header userName={this.state.userName} />
|
||||
<Breadcrumb {...this.props} />
|
||||
<div className="ant-layout-container">
|
||||
<div className="ant-layout-content">
|
||||
{this.state.loading ? '' : this.props.children}
|
||||
</div>
|
||||
</div>
|
||||
<Footer/>
|
||||
<Footer />
|
||||
</Spin>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
module.exports = App
|
||||
|
||||
+31
-30
@@ -1,77 +1,78 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import { ajax, config, logger } from '../../utils/lib'
|
||||
import { Icon, message, Button, Row, Col, Form, Input, Select} from 'antd'
|
||||
import { Icon, message, Button, Row, Col, Form, Input, Select } from 'antd'
|
||||
import './signIn.less'
|
||||
|
||||
const FormItem = Form.Item
|
||||
|
||||
let SignIn = React.createClass({
|
||||
getInitialState(){
|
||||
getInitialState() {
|
||||
return {
|
||||
loading: false
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
handleSubmit(e){
|
||||
var _this = this
|
||||
handleSubmit(e) {
|
||||
const _this = this
|
||||
e.preventDefault()
|
||||
this.props.form.validateFieldsAndScroll((errors, values) => {
|
||||
if (!!errors) {
|
||||
return
|
||||
}
|
||||
ajax.post(`${config.getAPIPath()}${config.login.validate}`).type('form').send(values).end((err, res) => {
|
||||
ajax.post(`${config.getAPIPath()}${config.login.validate}`)
|
||||
.type('form').send(values).end((err, res) => {
|
||||
if (ajax.isSuccess(res)) {
|
||||
if (this.props.loginSuccess)
|
||||
if (this.props.loginSuccess) {
|
||||
this.props.loginSuccess(res.body.data, true)
|
||||
else
|
||||
} else {
|
||||
message.info(`登录成功, 用户名: ${res.body.data}`)
|
||||
}
|
||||
} else {
|
||||
message.error(`登录失败: ${res.body.message}, 请联系管理员`)
|
||||
message.error(`登录失败: ${res.body.message}, 请联系管理员`)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
render(){
|
||||
render() {
|
||||
const { getFieldProps } = this.props.form
|
||||
const username = getFieldProps('username', {
|
||||
rules: [
|
||||
{required: true, message: '不能为空'}
|
||||
]
|
||||
{
|
||||
required: true,
|
||||
message: '不能为空',
|
||||
},
|
||||
],
|
||||
})
|
||||
const password = getFieldProps('password', {
|
||||
rules: [
|
||||
{required: true, message: '不能为空'}
|
||||
]
|
||||
{
|
||||
required: true,
|
||||
message: '不能为空',
|
||||
},
|
||||
],
|
||||
})
|
||||
return (
|
||||
<div className="signIn-from">
|
||||
<div className="logo mb">
|
||||
<img src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg"/>
|
||||
<img src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg" />
|
||||
<span>Ant Design</span>
|
||||
</div>
|
||||
<form horizontal onSubmit={this.handleSubmit} form={this.props.form}>
|
||||
<FormItem
|
||||
hasFeedback>
|
||||
<Input
|
||||
{...username}
|
||||
size="large"
|
||||
placeholder="账户"/>
|
||||
<FormItem hasFeedback>
|
||||
<Input {...username} size="large" placeholder="账户" />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
hasFeedback>
|
||||
<Input
|
||||
{...password}
|
||||
size="large"
|
||||
type="password"
|
||||
placeholder="密码"/>
|
||||
<FormItem hasFeedback>
|
||||
<Input {...password} size="large" type="password" placeholder="密码" />
|
||||
</FormItem>
|
||||
<Row className="self-modal-footer">
|
||||
<Button type="primary" size="large" onClick={this.handleSubmit} loading={this.state.loading}>登录</Button>
|
||||
<Button type="primary" size="large" onClick={this.handleSubmit} loading={this.state.loading}>
|
||||
登录
|
||||
</Button>
|
||||
</Row>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
SignIn = Form.create()(SignIn)
|
||||
|
||||
Reference in New Issue
Block a user