eslint apply all

This commit is contained in:
zuiidea
2017-03-14 20:03:21 +08:00
parent 23540e4394
commit 47e7d580bb
52 changed files with 692 additions and 601 deletions
+16 -15
View File
@@ -10,14 +10,14 @@ import { Spin } from 'antd'
import { classnames } from '../utils'
import '../components/layout/common.less'
function App ({children, location, dispatch, app, loading}) {
const {login, loginButtonLoading, user, siderFold, darkTheme, isNavbar, menuPopoverVisible, navOpenKeys} = app
function App ({ children, location, dispatch, app, loading }) {
const { login, loginButtonLoading, user, siderFold, darkTheme, isNavbar, menuPopoverVisible, navOpenKeys } = app
const loginProps = {
loading,
loginButtonLoading,
onOk (data) {
dispatch({type: 'app/login', payload: data})
}
dispatch({ type: 'app/login', payload: data })
},
}
const headerProps = {
@@ -28,18 +28,18 @@ function App ({children, location, dispatch, app, loading}) {
menuPopoverVisible,
navOpenKeys,
switchMenuPopover () {
dispatch({type: 'app/switchMenuPopver'})
dispatch({ type: 'app/switchMenuPopver' })
},
logout () {
dispatch({type: 'app/logout'})
dispatch({ type: 'app/logout' })
},
switchSider () {
dispatch({type: 'app/switchSider'})
dispatch({ type: 'app/switchSider' })
},
changeOpenKeys (openKeys) {
localStorage.setItem('navOpenKeys', JSON.stringify(openKeys))
dispatch({ type: 'app/handleNavOpenKeys', payload: { navOpenKeys: openKeys } })
}
},
}
const siderProps = {
@@ -48,18 +48,18 @@ function App ({children, location, dispatch, app, loading}) {
location,
navOpenKeys,
changeTheme () {
dispatch({type: 'app/changeTheme'})
dispatch({ type: 'app/changeTheme' })
},
changeOpenKeys (openKeys) {
localStorage.setItem('navOpenKeys', JSON.stringify(openKeys))
dispatch({ type: 'app/handleNavOpenKeys', payload: { navOpenKeys: openKeys } })
}
},
}
return (
<div>{login
? <div className={classnames(styles.layout, {[styles.fold]: isNavbar ? false : siderFold}, {[styles.withnavbar]: isNavbar})}>
{!isNavbar ? <aside className={classnames(styles.sider, {[styles.light]: !darkTheme})}>
? <div className={classnames(styles.layout, { [styles.fold]: isNavbar ? false : siderFold }, { [styles.withnavbar]: isNavbar })}>
{!isNavbar ? <aside className={classnames(styles.sider, { [styles.light]: !darkTheme })}>
<Sider {...siderProps} />
</aside> : ''}
<div className={styles.main}>
@@ -73,7 +73,7 @@ function App ({children, location, dispatch, app, loading}) {
<Footer />
</div>
</div>
: <div className={styles.spin}><Spin tip='加载用户信息...' spinning={loading} size='large'><Login {...loginProps} /></Spin></div>}</div>
: <div className={styles.spin}><Spin tip="加载用户信息..." spinning={loading} size="large"><Login {...loginProps} /></Spin></div>}</div>
)
}
@@ -81,7 +81,8 @@ App.propTypes = {
children: PropTypes.element.isRequired,
location: PropTypes.object,
dispatch: PropTypes.func,
app: PropTypes.object
app: PropTypes.object,
loading: PropTypes.bool,
}
export default connect(({app, loading}) => ({app, loading: loading.models.app}))(App)
export default connect(({ app, loading }) => ({ app, loading: loading.models.app }))(App)
+15 -15
View File
@@ -1,6 +1,6 @@
import React, {PropTypes} from 'react'
import {connect} from 'dva'
import {Row, Col, Card} from 'antd'
import React, { PropTypes } from 'react'
import { connect } from 'dva'
import { Row, Col, Card } from 'antd'
import NumberCard from '../components/dashboard/numberCard'
import Quote from '../components/dashboard/quote'
import Sales from '../components/dashboard/sales'
@@ -12,17 +12,17 @@ import Browser from '../components/dashboard/browser'
import Cpu from '../components/dashboard/cpu'
import User from '../components/dashboard/user'
import styles from './dashboard.less'
import {color} from '../utils'
import { color } from '../utils'
const bodyStyle = {
bodyStyle: {
height: 432,
background: '#fff'
}
background: '#fff',
},
}
function Dashboard ({dashboard}) {
const {weather, sales, quote, numbers, recentSales, comments, completed, browser, cpu, user} = dashboard
function Dashboard ({ dashboard }) {
const { weather, sales, quote, numbers, recentSales, comments, completed, browser, cpu, user } = dashboard
const numberCards = numbers.map((item, key) => <Col key={key} lg={6} md={12}>
<NumberCard {...item} />
</Col>)
@@ -32,7 +32,7 @@ function Dashboard ({dashboard}) {
{numberCards}
<Col lg={18} md={24}>
<Card bordered={false} bodyStyle={{
padding: '24px 36px 24px 0'
padding: '24px 36px 24px 0',
}}>
<Sales data={sales} />
</Card>
@@ -43,7 +43,7 @@ function Dashboard ({dashboard}) {
<Card bordered={false} className={styles.weather} bodyStyle={{
padding: 0,
height: 204,
background: color.blue
background: color.blue,
}}>
<Weather {...weather} />
</Card>
@@ -52,7 +52,7 @@ function Dashboard ({dashboard}) {
<Card bordered={false} className={styles.quote} bodyStyle={{
padding: 0,
height: 204,
background: color.peach
background: color.peach,
}}>
<Quote {...quote} />
</Card>
@@ -71,7 +71,7 @@ function Dashboard ({dashboard}) {
</Col>
<Col lg={24} md={24}>
<Card bordered={false} bodyStyle={{
padding: '24px 36px 24px 0'
padding: '24px 36px 24px 0',
}}>
<Completed data={completed} />
</Card>
@@ -87,7 +87,7 @@ function Dashboard ({dashboard}) {
</Card>
</Col>
<Col lg={8} md={24}>
<Card bordered={false} bodyStyle={{...bodyStyle.bodyStyle, padding: 0}}>
<Card bordered={false} bodyStyle={{ ...bodyStyle.bodyStyle, padding: 0 }}>
<User {...user} />
</Card>
</Col>
@@ -96,7 +96,7 @@ function Dashboard ({dashboard}) {
}
Dashboard.propTypes = {
dashboard: PropTypes.object
dashboard: PropTypes.object,
}
export default connect(({dashboard}) => ({dashboard}))(Dashboard)
export default connect(({ dashboard }) => ({ dashboard }))(Dashboard)
+3 -3
View File
@@ -1,10 +1,10 @@
import React from 'react'
import {Icon} from 'antd'
import { Icon } from 'antd'
import styles from './error.less'
const Error = () => <div className='content-inner'>
const Error = () => <div className="content-inner">
<div className={styles.error}>
<Icon type='frown-o' />
<Icon type="frown-o" />
<h1>404 Not Found</h1>
</div>
</div>
+14 -14
View File
@@ -1,4 +1,4 @@
import React, {PropTypes} from 'react'
import React, { PropTypes } from 'react'
import { Button, Row, Form, Input } from 'antd'
import { config } from '../utils'
import styles from './login.less'
@@ -10,8 +10,8 @@ const login = ({
onOk,
form: {
getFieldDecorator,
validateFieldsAndScroll
}
validateFieldsAndScroll,
},
}) => {
function handleOk () {
validateFieldsAndScroll((errors, values) => {
@@ -25,7 +25,7 @@ const login = ({
return (
<div className={styles.form}>
<div className={styles.logo}>
<img src={config.logoSrc} />
<img alt={'logo'} src={config.logoSrc} />
<span>Ant Design</span>
</div>
<form>
@@ -34,23 +34,23 @@ const login = ({
rules: [
{
required: true,
message: '请填写用户名'
}
]
})(<Input size='large' onPressEnter={handleOk} placeholder='用户名' />)}
message: '请填写用户名',
},
],
})(<Input size="large" onPressEnter={handleOk} placeholder="用户名" />)}
</FormItem>
<FormItem hasFeedback>
{getFieldDecorator('password', {
rules: [
{
required: true,
message: '请填写密码'
}
]
})(<Input size='large' type='password' onPressEnter={handleOk} placeholder='密码' />)}
message: '请填写密码',
},
],
})(<Input size="large" type="password" onPressEnter={handleOk} placeholder="密码" />)}
</FormItem>
<Row>
<Button type='primary' size='large' onClick={handleOk} loading={loginButtonLoading}>
<Button type="primary" size="large" onClick={handleOk} loading={loginButtonLoading}>
登录
</Button>
</Row>
@@ -66,7 +66,7 @@ const login = ({
login.propTypes = {
form: PropTypes.object,
loginButtonLoading: PropTypes.bool,
onOk: PropTypes.func
onOk: PropTypes.func,
}
export default Form.create()(login)
+27 -23
View File
@@ -2,24 +2,24 @@ import React from 'react'
import { DropOption } from '../../components/ui'
import { Table, Row, Col, Card, message } from 'antd'
const DropOptionPage = () => <div className='content-inner'>
const DropOptionPage = () => <div className="content-inner">
<Row gutter={32}>
<Col lg={8} md={12}>
<Card title='默认'>
<DropOption menuOptions={[{key: '1', name: '编辑'}, {key: '2', name: '删除'}]} />
<Card title="默认">
<DropOption menuOptions={[{ key: '1', name: '编辑' }, { key: '2', name: '删除' }]} />
</Card>
</Col>
<Col lg={8} md={12}>
<Card title='样式'>
<DropOption menuOptions={[{key: '1', name: '编辑'}, {key: '2', name: '删除'}]} buttonStyle={{border: 'solid 1px #eee', width: 60}} />
<Card title="样式">
<DropOption menuOptions={[{ key: '1', name: '编辑' }, { key: '2', name: '删除' }]} buttonStyle={{ border: 'solid 1px #eee', width: 60 }} />
</Card>
</Col>
<Col lg={8} md={12}>
<Card title='事件'>
<Card title="事件">
<DropOption
menuOptions={[{key: '1', name: '编辑'}, {key: '2', name: '删除'}]}
buttonStyle={{border: 'solid 1px #eee', width: 60}}
onMenuClick={({key}) => {
menuOptions={[{ key: '1', name: '编辑' }, { key: '2', name: '删除' }]}
buttonStyle={{ border: 'solid 1px #eee', width: 60 }}
onMenuClick={({ key }) => {
switch (key) {
case '1':
message.success('点击了编辑')
@@ -27,63 +27,67 @@ const DropOptionPage = () => <div className='content-inner'>
case '2':
message.success('点击了删除')
break
default:
break
}
}}
/>
/>
</Card>
</Col>
</Row>
<h2 style={{margin: '16px 0'}}>Props</h2>
<h2 style={{ margin: '16px 0' }}>Props</h2>
<Row>
<Col lg={18} md={24}>
<Table rowKey={(record, key) => key}
<Table
rowKey={(record, key) => key}
pagination={false}
bordered
scroll={{ x: 800 }}
columns={[
{
title: '参数',
dataIndex: 'props'
dataIndex: 'props',
},
{
title: '说明',
dataIndex: 'desciption'
dataIndex: 'desciption',
},
{
title: '类型',
dataIndex: 'type'
dataIndex: 'type',
},
{
title: '默认值',
dataIndex: 'default'
}
dataIndex: 'default',
},
]}
dataSource={[
{
props: 'menuOptions',
desciption: '下拉操作的选项,格式为[{name:string,key:string}]',
type: 'Array',
default: '必选'
default: '必选',
},
{
props: 'onMenuClick',
desciption: '点击 menuitem 调用此函数,参数为 {item, key, keyPath}',
type: 'Function',
default: '-'
default: '-',
},
{
props: 'buttonStyle',
desciption: '按钮的样式',
type: 'Object',
default: '-'
default: '-',
},
{
props: 'dropdownProps',
desciption: '下拉菜单的参数,可参考antd的【Dropdown】组件',
type: 'Object',
default: '-'
}
]} />
default: '-',
},
]}
/>
</Col>
</Row>
</div>
+12 -10
View File
@@ -5,42 +5,44 @@ import styles from './ico.less'
const iconlist = ['Cherry', 'Cheese', 'Bread', 'Beer', 'Beet', 'Bacon', 'Banana', 'Asparagus', 'Apple']
const IcoPage = () => <div className='content-inner'>
const IcoPage = () => <div className="content-inner">
<ul className={styles.list}>
{iconlist.map(item => <li key={item}><Ico className={styles.icon} type={item} /><span className={styles.name}>{item}</span></li>)}
</ul>
<h2 style={{margin: '16px 0'}}>Props</h2>
<h2 style={{ margin: '16px 0' }}>Props</h2>
<Row>
<Col lg={18} md={24}>
<Table rowKey={(record, key) => key}
<Table
rowKey={(record, key) => key}
pagination={false}
bordered
scroll={{ x: 800 }}
columns={[
{
title: '参数',
dataIndex: 'props'
dataIndex: 'props',
},
{
title: '说明',
dataIndex: 'desciption'
dataIndex: 'desciption',
},
{
title: '类型',
dataIndex: 'type'
dataIndex: 'type',
},
{
title: '默认值',
dataIndex: 'default'
}
dataIndex: 'default',
},
]}
dataSource={[
{
props: 'type',
desciption: '图标类型',
type: 'String',
default: '-'
}]} />
default: '-',
}]}
/>
</Col>
</Row>
</div>
+17 -14
View File
@@ -1,48 +1,51 @@
import React from 'react'
import { Layer } from '../../components/ui'
// import { Layer } from '../../components/ui'
import { Table, Row, Col, Button, Card } from 'antd'
import styles from './ico.less'
import './ico.less'
const IcoPage = () => <div className='content-inner'>
const IcoPage = () => <div className="content-inner">
<Row gutter={32}>
<Col lg={8} md={12}>
<Card title='默认'>
<Button type='primary'>打开Layer</Button>
<Card title="默认">
<Button type="primary">打开Layer</Button>
</Card>
</Col>
</Row>
<h2 style={{margin: '16px 0'}}>Props</h2>
<h2 style={{ margin: '16px 0' }}>Props</h2>
<Row>
<Col lg={18} md={24}>
<Table rowKey={(record, key) => key}
<Table
rowKey={(record, key) => key}
pagination={false}
bordered
scroll={{ x: 800 }}
columns={[
{
title: '参数',
dataIndex: 'props'
dataIndex: 'props',
},
{
title: '说明',
dataIndex: 'desciption'
dataIndex: 'desciption',
},
{
title: '类型',
dataIndex: 'type'
dataIndex: 'type',
},
{
title: '默认值',
dataIndex: 'default'
}
dataIndex: 'default',
},
]}
dataSource={[
{
props: 'type',
desciption: '图标类型',
type: 'String',
default: '-'
}]} />
default: '-',
},
]}
/>
</Col>
</Row>
</div>
+34 -26
View File
@@ -2,87 +2,95 @@ import React from 'react'
import { Search } from '../../components/ui'
import { Table, Row, Col, Card } from 'antd'
const SearchPage = () => <div className='content-inner'>
const SearchPage = () => <div className="content-inner">
<Row gutter={32}>
<Col lg={8} md={12}>
<Card title='默认'>
<Card title="默认">
<Search />
</Card>
</Col>
<Col lg={8} md={12}>
<Card title='附带选择'>
<Search {...{
select: true,
selectOptions: [{ value: 'components', name: '组件' }, { value: 'page', name: '页面' }],
selectProps: {
defaultValue: 'components'
}
}} />
<Card title="附带选择">
<Search
{...{
select: true,
selectOptions: [
{ value: 'components', name: '组件' },
{ value: 'page', name: '页面' },
],
selectProps: {
defaultValue: 'components',
},
}}
/>
</Card>
</Col>
<Col lg={8} md={12}>
<Card title='大小'>
<Search size='large' style={{marginBottom: 16}} />
<Search size='small' />
<Card title="大小">
<Search size="large" style={{ marginBottom: 16 }} />
<Search size="small" />
</Card>
</Col>
</Row>
<h2 style={{margin: '16px 0'}}>Props</h2>
<h2 style={{ margin: '16px 0' }}>Props</h2>
<Row>
<Col lg={18} md={24}>
<Table rowKey={(record, key) => key}
<Table
rowKey={(record, key) => key}
pagination={false}
bordered
scroll={{ x: 800 }}
columns={[
{
title: '参数',
dataIndex: 'props'
dataIndex: 'props',
},
{
title: '说明',
dataIndex: 'desciption'
dataIndex: 'desciption',
},
{
title: '类型',
dataIndex: 'type'
dataIndex: 'type',
},
{
title: '默认值',
dataIndex: 'default'
}
dataIndex: 'default',
},
]}
dataSource={[
{
props: 'size',
desciption: '设置Search大小,可选值为 【small】 【large】 或者不设',
type: 'String',
default: '-'
default: '-',
},
{
props: 'select',
desciption: '设置是否有选择器',
type: 'Boolean',
default: 'false'
default: 'false',
},
{
props: 'selectOptions',
desciption: '选择器的选项,格式为[{name:"",value:""}]或者[{value:""}]',
type: 'Array',
default: '-'
default: '-',
},
{
props: 'selectProps',
desciption: '选择器的属性,可参考antd的【Select】组件',
type: 'Object',
default: '-'
default: '-',
},
{
props: 'onSearch',
desciption: '点击搜索按钮, 按Enter键或者点击清除时的回调',
type: 'Function({keyword:string,field:string})',
default: '-'
}]} />
default: '-',
},
]}
/>
</Col>
</Row>
</div>
+22 -21
View File
@@ -16,37 +16,37 @@ function Users ({ location, dispatch, users, loading }) {
onOk (data) {
dispatch({
type: `users/${modalType}`,
payload: data
payload: data,
})
},
onCancel () {
dispatch({
type: 'users/hideModal'
type: 'users/hideModal',
})
}
},
}
const userListProps = {
dataSource: list,
loading,
pagination: pagination,
pagination,
location,
isMotion,
onPageChange (page) {
const { query, pathname } = location
dispatch(routerRedux.push({
pathname: pathname,
pathname,
query: {
...query,
page: page.current,
pageSize: page.pageSize
}
pageSize: page.pageSize,
},
}))
},
onDeleteItem (id) {
dispatch({
type: 'users/delete',
payload: id
payload: id,
})
},
onEditItem (item) {
@@ -54,10 +54,10 @@ function Users ({ location, dispatch, users, loading }) {
type: 'users/showModal',
payload: {
modalType: 'update',
currentItem: item
}
currentItem: item,
},
})
}
},
}
const userSearchProps = {
@@ -69,30 +69,30 @@ function Users ({ location, dispatch, users, loading }) {
pathname: '/users',
query: {
field: fieldsValue.field,
keyword: fieldsValue.keyword
}
keyword: fieldsValue.keyword,
},
})) : dispatch(routerRedux.push({
pathname: '/users'
pathname: '/users',
}))
},
onAdd () {
dispatch({
type: 'users/showModal',
payload: {
modalType: 'create'
}
modalType: 'create',
},
})
},
switchIsMotion () {
dispatch({type: 'users/switchIsMotion'})
}
dispatch({ type: 'users/switchIsMotion' })
},
}
const UserModalGen = () =>
<UserModal {...userModalProps} />
return (
<div className='content-inner'>
<div className="content-inner">
<UserSearch {...userSearchProps} />
<UserList {...userListProps} />
<UserModalGen />
@@ -103,7 +103,8 @@ function Users ({ location, dispatch, users, loading }) {
Users.propTypes = {
users: PropTypes.object,
location: PropTypes.object,
dispatch: PropTypes.func
dispatch: PropTypes.func,
loading: PropTypes.bool,
}
export default connect(({users, loading}) => ({users, loading: loading.models.user}))(Users)
export default connect(({ users, loading }) => ({ users, loading: loading.models.user }))(Users)