Merge branch 'bug575' of https://github.com/yangbin1994/antd-admin into yangbin1994-bug575

This commit is contained in:
zuiidea
2017-09-11 09:26:36 +08:00
20 changed files with 191 additions and 161 deletions
+1
View File
@@ -32,6 +32,7 @@
"react/forbid-prop-types": 0,
"react/no-string-refs": 0,
"react/no-find-dom-node": 0,
"react/prefer-stateless-function": 0,
"import/no-extraneous-dependencies": 0,
"import/prefer-default-export": 0,
"react/no-danger": 0,
+9 -28
View File
@@ -2,7 +2,7 @@
[![React](https://img.shields.io/badge/react-^15.6.1-brightgreen.svg?style=flat-square)](https://github.com/facebook/react)
[![Ant Design](https://img.shields.io/badge/ant--design-^2.11.2-yellowgreen.svg?style=flat-square)](https://github.com/ant-design/ant-design)
[![dva](https://img.shields.io/badge/dva-^1.2.0-orange.svg?style=flat-square)](https://github.com/dvajs/dva)
[![dva](https://img.shields.io/badge/dva-^2.0.1-orange.svg?style=flat-square)](https://github.com/dvajs/dva)
[![GitHub issues](https://img.shields.io/github/issues/zuiidea/antd-admin.svg?style=flat-square)](https://github.com/zuiidea/antd-admin)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/zuiidea/antd-admin/pulls)
@@ -21,6 +21,13 @@
## 更新日志
### 4.3.5
`2017-09-04`
-   更新[dva](https://github.com/dvajs/dva)至`2.0.1`,感谢[@yangbin1994](https://github.com/yangbin1994)的[PR](https://github.com/zuiidea/antd-admin/pull/567)。
### 4.3.4
`2017-09-04`
@@ -38,34 +45,8 @@
-   新增打包时按项目版本号生成文件目录。[#449](https://github.com/zuiidea/antd-admin/issues/449)
-   更新`eslint`,并适当修改了`.eslintrc`。
### 4.2.3
`2017-07-07`
-   新增用户按权限访问。[#384](https://github.com/zuiidea/antd-admin/issues/384)
### 4.2.2
`2017-06-01`
-   新增用户管理批量删除。[#320](https://github.com/zuiidea/antd-admin/issues/320)
### 4.2.1
`2017-05-12`
-   新增IconFont扩展方案,本地使用方案。[#270](https://github.com/zuiidea/antd-admin/issues/270) [Live](http://47.92.30.98:666/UIElement/iconfont)
-   新增常见场景使用loading。 [dva-loading](https://github.com/dvajs/dva-loading)
### 4.2
`2017-04-28`
- 修改user相关API使用`Restful`风格。
- 增加user页面多条件查询。[#266](https://github.com/zuiidea/antd-admin/issues/226)
- 修复菜单默认高亮。[#201](https://github.com/zuiidea/antd-admin/issues/201)
[More Change Log](https://github.com/zuiidea/antd-admin/wiki/Change-Log)
[More Change Log](https://github.com/zuiidea/antd-admin/wiki/Change-Log)
## 开发构建
+3 -5
View File
@@ -1,7 +1,7 @@
{
"private": true,
"name": "antd-admin",
"version": "4.3.4",
"version": "4.3.5",
"dependencies": {
"antd": "^2.11.2",
"axios": "^0.16.2",
@@ -53,9 +53,7 @@
"redbox-react": "^1.2.10",
"roadhog": "^1.2.2"
},
"pre-commit": [
"lint"
],
"pre-commit": ["lint"],
"scripts": {
"dev": "cross-env BROWSER=none HOST=0.0.0.0 roadhog server",
"lint": "eslint --fix --ext .js src",
@@ -63,4 +61,4 @@
"build:dll": "roadhog buildDll",
"build:new": "node version && roadhog build"
}
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Breadcrumb, Icon } from 'antd'
import { LinkWrapper } from 'components'
import { Link } from 'react-router-dom'
import pathToRegexp from 'path-to-regexp'
import { queryArray } from 'utils'
import styles from './Bread.less'
@@ -48,9 +48,9 @@ const Bread = ({ menu, location }) => {
return (
<Breadcrumb.Item key={key}>
{((pathArray.length - 1) !== key)
? <LinkWrapper to={item.route}>
? <Link to={item.route || '#'}>
{content}
</LinkWrapper>
</Link>
: content}
</Breadcrumb.Item>
)
+4 -4
View File
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Menu, Icon } from 'antd'
import { LinkWrapper } from 'components'
import { Link } from 'react-router-dom'
import { arrayToTree, queryArray } from 'utils'
import pathToRegexp from 'path-to-regexp'
@@ -31,10 +31,10 @@ const Menus = ({ siderFold, darkTheme, handleClickNavMenu, navOpenKeys, changeOp
}
return (
<Menu.Item key={item.id}>
<LinkWrapper to={item.route}>
<Link to={item.route || '#'}>
{item.icon && <Icon type={item.icon} />}
{(!siderFoldN || !menuTree.includes(item)) && item.name}
</LinkWrapper>
</Link>
</Menu.Item>
)
})
@@ -112,7 +112,7 @@ const Menus = ({ siderFold, darkTheme, handleClickNavMenu, navOpenKeys, changeOp
mode={siderFold ? 'vertical' : 'inline'}
theme={darkTheme ? 'dark' : 'light'}
onClick={handleClickNavMenu}
defaultSelectedKeys={defaultSelectedKeys}
selectedKeys={defaultSelectedKeys}
>
{menuItems}
</Menu>
-10
View File
@@ -1,10 +0,0 @@
import { Link } from 'react-router-dom'
export default (props) => {
const Component = props.to ? Link : 'a'
return (
<Component {...props}>
{props.children}
</Component>
)
}
+3 -2
View File
@@ -6,8 +6,9 @@ import styles from './Loader.less'
const Loader = ({ spinning, fullScreen }) => {
return (<div className={classNames(styles.loader, {
[styles.hidden]: !spinning,
[styles.loader_fullScreen]: fullScreen,
})}>
[styles.fullScreen]: fullScreen,
})}
>
<div className={styles.warpper}>
<div className={styles.inner} />
<div className={styles.text} >LOADING</div>
+68 -68
View File
@@ -1,68 +1,68 @@
.loader_fullScreen {
position: fixed !important;
}
.loader {
display: block;
background-color: #fff;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
z-index: 100000;
display: flex;
justify-content: center;
align-items: center;
opacity: 1;
text-align: center;
.warpper {
width: 100px;
height: 100px;
display: inline-flex;
flex-direction: column;
justify-content: space-around;
}
.inner {
width: 48px;
height: 48px;
margin: 0 auto;
text-indent: -12345px;
border-top: 1px solid rgba(0, 0, 0, 0.08);
border-right: 1px solid rgba(0, 0, 0, 0.08);
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
border-left: 1px solid rgba(0, 0, 0, 0.7);
border-radius: 50%;
z-index: 100001;
:local {
animation: spinner 600ms infinite linear;
}
}
.text {
width: 100px;
height: 20px;
text-align: center;
font-size: 12px;
letter-spacing: 4px;
color: #000;
}
&.hidden {
z-index: -1;
opacity: 0;
transition: opacity 1s ease 0.5s, z-index 0.1s ease 1.5s;
}
}
@keyframes spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loader {
display: block;
background-color: #fff;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
z-index: 100000;
display: flex;
justify-content: center;
align-items: center;
opacity: 1;
text-align: center;
&.fullScreen {
position: fixed;
}
.warpper {
width: 100px;
height: 100px;
display: inline-flex;
flex-direction: column;
justify-content: space-around;
}
.inner {
width: 48px;
height: 48px;
margin: 0 auto;
text-indent: -12345px;
border-top: 1px solid rgba(0, 0, 0, 0.08);
border-right: 1px solid rgba(0, 0, 0, 0.08);
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
border-left: 1px solid rgba(0, 0, 0, 0.7);
border-radius: 50%;
z-index: 100001;
:local {
animation: spinner 600ms infinite linear;
}
}
.text {
width: 100px;
height: 20px;
text-align: center;
font-size: 12px;
letter-spacing: 4px;
color: #000;
}
&.hidden {
z-index: -1;
opacity: 0;
transition: opacity 1s ease 0.5s, z-index 0.1s ease 1.5s;
}
}
@keyframes spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
+34
View File
@@ -0,0 +1,34 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import Loader from '../Loader'
import styles from './Page.less'
export default class Page extends Component {
render () {
const { className, children, loading = false, inner = false } = this.props
const loadingStyle = {
height: 'calc(100vh - 184px)',
overflow: 'hidden',
}
return (
<div
className={classnames(className, {
[styles.contentInner]: inner,
})}
style={loading ? loadingStyle : null}
>
{loading ? <Loader spinning /> : ''}
{children}
</div>
)
}
}
Page.propTypes = {
className: PropTypes.string,
children: PropTypes.node,
loading: PropTypes.bool,
inner: PropTypes.bool,
}
+14
View File
@@ -0,0 +1,14 @@
@import "~themes/vars";
.contentInner{
background: #fff;
padding: 24px;
box-shadow: @shadow-1;
min-height: e("calc(100vh - 184px)");
}
@media (max-width: 767px) {
.contentInner {
padding: 12px;
min-height: e("calc(100vh - 160px)");
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"name": "Page",
"version": "0.0.0",
"private": true,
"main": "./Page.js"
}
+2 -2
View File
@@ -6,7 +6,7 @@ import Editor from './Editor'
import FilterItem from './FilterItem'
import Loader from './Loader'
import * as Layout from './Layout/index.js'
import LinkWrapper from './LinkWrapper'
import Page from './Page'
import layer from './layer'
@@ -20,5 +20,5 @@ export {
FilterItem,
Loader,
layer,
LinkWrapper,
Page,
}
+3 -3
View File
@@ -98,10 +98,10 @@ export default {
}
} else if (config.openPages && config.openPages.indexOf(locationPathname) < 0) {
yield put(routerRedux.push({
pathname: 'login',
query: {
pathname: '/login',
search: queryString.stringify({
from: locationPathname,
},
}),
}))
}
},
+1 -1
View File
@@ -3,8 +3,8 @@ import modelExtend from 'dva-model-extend'
import { config } from 'utils'
import { create, remove, update } from 'services/user'
import * as usersService from 'services/users'
import { pageModel } from './common'
import queryString from 'query-string'
import { pageModel } from './common'
const { query } = usersService
const { prefix } = config
+10 -8
View File
@@ -1,9 +1,8 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Router, Switch, Route, Redirect, routerRedux } from 'dva/router'
import { Switch, Route, Redirect, routerRedux } from 'dva/router'
import dynamic from 'dva/dynamic'
import App from 'routes/app'
import { Loader } from 'components'
const { ConnectedRouter } = routerRedux
@@ -70,14 +69,17 @@ const Routers = function ({ history, app }) {
<ConnectedRouter history={history}>
<App>
<Switch>
<Route exact path='/' render={() => (<Redirect to='/dashboard' />)} />
<Route exact path="/" render={() => (<Redirect to="/dashboard" />)} />
{
routes.map(({ path, ...dynamics }, key) => (
<Route key={key} exact path={path} component={dynamic({
app,
LoadingComponent: ({ productId }) => (<Loader spinning />),
...dynamics
})} />
<Route key={key}
exact
path={path}
component={dynamic({
app,
...dynamics,
})}
/>
))
}
<Route component={error} />
+8 -7
View File
@@ -7,10 +7,10 @@ import { connect } from 'dva'
import { Layout, Loader } from 'components'
import { classnames, config } from 'utils'
import { Helmet } from 'react-helmet'
import { withRouter } from 'dva/router'
import '../themes/index.less'
import './app.less'
import Error from './error'
import { withRouter } from 'dva/router'
const { prefix, openPages } = config
@@ -37,20 +37,21 @@ const App = ({ children, dispatch, app, loading, location }) => {
const headerProps = {
menu,
user,
location,
siderFold,
isNavbar,
menuPopoverVisible,
navOpenKeys,
switchMenuPopover() {
switchMenuPopover () {
dispatch({ type: 'app/switchMenuPopver' })
},
logout() {
logout () {
dispatch({ type: 'app/logout' })
},
switchSider() {
switchSider () {
dispatch({ type: 'app/switchSider' })
},
changeOpenKeys(openKeys) {
changeOpenKeys (openKeys) {
dispatch({ type: 'app/handleNavOpenKeys', payload: { navOpenKeys: openKeys } })
},
}
@@ -61,10 +62,10 @@ const App = ({ children, dispatch, app, loading, location }) => {
siderFold,
darkTheme,
navOpenKeys,
changeTheme() {
changeTheme () {
dispatch({ type: 'app/switchTheme' })
},
changeOpenKeys(openKeys) {
changeOpenKeys (openKeys) {
window.localStorage.setItem(`${prefix}navOpenKeys`, JSON.stringify(openKeys))
dispatch({ type: 'app/handleNavOpenKeys', payload: { navOpenKeys: openKeys } })
},
+3 -4
View File
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import { connect } from 'dva'
import { Row, Col, Card } from 'antd'
import { color } from 'utils'
import { Loader } from 'components'
import { Page } from 'components'
import { NumberCard, Quote, Sales, Weather, RecentSales, Comments, Completed, Browser, Cpu, User } from './components'
import styles from './index.less'
@@ -21,8 +21,7 @@ function Dashboard ({ dashboard, loading }) {
</Col>))
return (
<div>
<Loader spinning={loading.models.dashboard && sales.length === 0} />
<Page loading={loading.models.dashboard && sales.length === 0}>
<Row gutter={24}>
{numberCards}
<Col lg={18} md={24}>
@@ -97,7 +96,7 @@ function Dashboard ({ dashboard, loading }) {
</Card>
</Col>
</Row>
</div>
</Page>
)
}
+5 -4
View File
@@ -4,6 +4,7 @@ import { connect } from 'dva'
import { Tabs } from 'antd'
import { routerRedux } from 'dva/router'
import List from './List'
import queryString from 'query-string'
const TabPane = Tabs.TabPane
@@ -24,11 +25,11 @@ const Index = ({ post, dispatch, loading, location }) => {
onChange (page) {
dispatch(routerRedux.push({
pathname,
query: {
search: queryString.stringify({
...query,
page: page.current,
pageSize: page.pageSize,
},
}),
}))
},
}
@@ -36,9 +37,9 @@ const Index = ({ post, dispatch, loading, location }) => {
const handleTabClick = (key) => {
dispatch(routerRedux.push({
pathname,
query: {
search: queryString.stringify({
status: key,
},
}),
}))
}
+3 -3
View File
@@ -3,9 +3,9 @@ import PropTypes from 'prop-types'
import { Table, Modal } from 'antd'
import classnames from 'classnames'
import { DropOption } from 'components'
import { LinkWrapper } from 'components'
import AnimTableBody from '../../components/DataTable/AnimTableBody'
import { Link } from 'react-router-dom'
import queryString from 'query-string'
import AnimTableBody from 'components/DataTable/AnimTableBody'
import styles from './List.less'
const confirm = Modal.confirm
@@ -38,7 +38,7 @@ const List = ({ onDeleteItem, onEditItem, isMotion, location, ...tableProps }) =
title: 'Name',
dataIndex: 'name',
key: 'name',
render: (text, record) => <LinkWrapper to={`user/${record.id}`}>{text}</LinkWrapper>,
render: (text, record) => <Link to={`user/${record.id}`}>{text}</Link>,
}, {
title: 'NickName',
dataIndex: 'nickName',
+11 -9
View File
@@ -3,10 +3,12 @@ import PropTypes from 'prop-types'
import { routerRedux } from 'dva/router'
import { connect } from 'dva'
import { Row, Col, Button, Popconfirm } from 'antd'
import { Page } from 'components'
import queryString from 'query-string'
import List from './List'
import Filter from './Filter'
import Modal from './Modal'
import queryString from 'query-string'
const User = ({ location, dispatch, user, loading }) => {
location.query = queryString.parse(location.search)
@@ -43,11 +45,11 @@ const User = ({ location, dispatch, user, loading }) => {
const { query, pathname } = location
dispatch(routerRedux.push({
pathname,
query: {
search: queryString.stringify({
...query,
page: page.current,
pageSize: page.pageSize,
},
}),
}))
},
onDeleteItem (id) {
@@ -86,20 +88,20 @@ const User = ({ location, dispatch, user, loading }) => {
onFilterChange (value) {
dispatch(routerRedux.push({
pathname: location.pathname,
query: {
search: queryString.stringify({
...value,
page: 1,
pageSize,
},
}),
}))
},
onSearch (fieldsValue) {
fieldsValue.keyword.length ? dispatch(routerRedux.push({
pathname: '/user',
query: {
search: queryString.stringify({
field: fieldsValue.field,
keyword: fieldsValue.keyword,
},
}),
})) : dispatch(routerRedux.push({
pathname: '/user',
}))
@@ -127,7 +129,7 @@ const User = ({ location, dispatch, user, loading }) => {
}
return (
<div className="content-inner">
<Page inner>
<Filter {...filterProps} />
{
selectedRowKeys.length > 0 &&
@@ -142,7 +144,7 @@ const User = ({ location, dispatch, user, loading }) => {
}
<List {...listProps} />
{modalVisible && <Modal {...modalProps} />}
</div>
</Page>
)
}