From 87af30c4b6e47148eb2cee18bb44e0a70a44a955 Mon Sep 17 00:00:00 2001 From: zuiidea Date: Tue, 3 Jan 2017 16:15:38 +0800 Subject: [PATCH] :sleepy: js-standard --- .eslintrc | 24 -- mock/app.js | 31 +-- mock/dashboard.js | 92 ++++--- mock/users.js | 19 +- npm-debug.log.884992468 | 0 package.json | 6 +- proxy.config.js | 9 +- src/components/dashboard/browser.js | 36 +-- src/components/dashboard/comments.js | 43 ++- src/components/dashboard/completed.js | 47 ++-- src/components/dashboard/cpu.js | 46 ++-- src/components/dashboard/numberCard.js | 14 +- src/components/dashboard/quote.js | 8 +- src/components/dashboard/recentSales.js | 43 ++- src/components/dashboard/sales.js | 49 ++-- src/components/dashboard/user.js | 50 ++-- src/components/dashboard/weather.js | 7 +- src/components/layout/{bread.jsx => bread.js} | 18 +- .../layout/{footer.jsx => footer.js} | 2 +- .../layout/{header.jsx => header.js} | 23 +- src/components/layout/menu.js | 34 ++- src/components/layout/sider.js | 28 ++ src/components/layout/sider.jsx | 29 --- src/components/ui/ico.js | 5 +- src/components/users/{list.jsx => list.js} | 34 +-- src/components/users/{modal.jsx => modal.js} | 74 +++--- .../users/{search.jsx => search.js} | 22 +- src/models/app.js | 78 +++--- src/models/dashboard.js | 246 +++++++++--------- src/models/users.js | 58 ++--- src/router.js | 13 +- src/routes/app.js | 48 ++-- src/routes/dashboard.js | 34 ++- src/routes/error.js | 4 +- src/routes/login.js | 28 +- src/routes/ui/ico.js | 70 ++--- src/routes/users.js | 58 ++--- src/services/app.js | 13 +- src/services/dashboard.js | 17 +- src/services/users.js | 17 +- src/tests/models/example-test.js | 10 - src/theme.js | 10 +- src/utils/config.js | 10 +- src/utils/index.js | 29 ++- src/utils/menu.js | 28 +- src/utils/mock.js | 18 +- src/utils/mockStorge.js | 5 +- src/utils/request.js | 14 +- src/utils/theme.js | 24 +- webpack.config.js | 16 +- 50 files changed, 783 insertions(+), 858 deletions(-) delete mode 100644 .eslintrc delete mode 100644 npm-debug.log.884992468 rename src/components/layout/{bread.jsx => bread.js} (73%) rename src/components/layout/{footer.jsx => footer.js} (81%) rename src/components/layout/{header.jsx => header.js} (52%) create mode 100644 src/components/layout/sider.js delete mode 100644 src/components/layout/sider.jsx rename src/components/users/{list.jsx => list.js} (77%) rename src/components/users/{modal.jsx => modal.js} (68%) rename src/components/users/{search.jsx => search.js} (70%) diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 4ff259b..0000000 --- a/.eslintrc +++ /dev/null @@ -1,24 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": "eslint-config-airbnb", - "rules": { - "spaced-comment": [0], - "no-unused-vars": [0], - "no-empty": [0], - "react/wrap-multilines": [0], - "react/no-multi-comp": [0], - "no-constant-condition": [0], - "react/jsx-no-bind": [0], - "react/prop-types": [0], - "arrow-body-style": [0], - "react/prefer-stateless-function": [0], - "semi": [0], - "global-require": [0], - "no-shadow": [0], - "no-useless-computed-key": [0], - "no-underscore-dangle": [0] - }, - "ecmaFeatures": { - "experimentalObjectRestSpread": true - } -} diff --git a/mock/app.js b/mock/app.js index 3f16805..90d27cf 100644 --- a/mock/app.js +++ b/mock/app.js @@ -1,11 +1,7 @@ -const qs = require('qs') -const Mock = require('mockjs') -const Watch = require("watchjs") -const Cookie = require("js-cookie") +const Cookie = require('js-cookie') import mockStorge from '../src/utils/mockStorge' - -let dataKey = mockStorge('AdminUsers',[ +let dataKey = mockStorge('AdminUsers', [ { username: 'guest', password: 'guest' @@ -16,39 +12,38 @@ let dataKey = mockStorge('AdminUsers',[ } ]) - module.exports = { 'POST /api/login' (req, res) { const userItem = req.body const response = { success: false, - message: "" + message: '' } const d = global[dataKey].filter(function (item) { - return item.username == userItem.username + return item.username === userItem.username }) - if (!!d.length) { - if (d[0].password == userItem.password) { + if (d.length) { + if (d[0].password === userItem.password) { const now = new Date() now.setDate(now.getDate() + 1) Cookie.set('user_session', now.getTime()) Cookie.set('user_name', userItem.username) - response.message = "登录成功" + response.message = '登录成功' response.success = true } else { - response.message = "密码不正确" + response.message = '密码不正确' } } else { - response.message = "用户不存在" + response.message = '用户不存在' } res.json(response) }, 'GET /api/userInfo' (req, res) { const response = { - success: Cookie.get('user_session')&&Cookie.get('user_session') > new Date().getTime() ? true :false, - username: Cookie.get('user_name')||'', - message: "" + success: Cookie.get('user_session') && Cookie.get('user_session') > new Date().getTime(), + username: Cookie.get('user_name') || '', + message: '' } res.json(response) }, @@ -58,7 +53,7 @@ module.exports = { Cookie.remove('user_name', { path: '' }) res.json({ success: true, - message: "退出成功" + message: '退出成功' }) } } diff --git a/mock/dashboard.js b/mock/dashboard.js index f6c5d3a..2d04c5f 100644 --- a/mock/dashboard.js +++ b/mock/dashboard.js @@ -1,8 +1,6 @@ -const qs = require('qs') -const Mock = require('mockjs') -const Watch = require("watchjs") -import mockStorge from '../src/utils/mockStorge' import {color} from '../src/utils/theme' +const Mock = require('mockjs') +import mockStorge from '../src/utils/mockStorge' let dataKey = mockStorge('Dashboard', Mock.mock({ 'sales|8': [ @@ -13,54 +11,54 @@ let dataKey = mockStorge('Dashboard', Mock.mock({ 'Electronics|300-550': 1 } ], - 'cpu':{ - 'usage|50-600':1, - space:825, - 'cpu|40-90':1, - 'data|20':[ + 'cpu': { + 'usage|50-600': 1, + space: 825, + 'cpu|40-90': 1, + 'data|20': [ { - 'cpu|20-80':1 + 'cpu|20-80': 1 } - ], + ] }, - 'browser':[ + 'browser': [ { - name:'Google Chrome', - percent:43.3, - status:1 + name: 'Google Chrome', + percent: 43.3, + status: 1 }, { - name:'Mozilla Firefox', - percent:33.4, - status:2 + name: 'Mozilla Firefox', + percent: 33.4, + status: 2 }, { - name:'Apple Safari', - percent:34.6, - status:3 + name: 'Apple Safari', + percent: 34.6, + status: 3 }, { - name:'Internet Explorer', - percent:12.3, - status:4 + name: 'Internet Explorer', + percent: 12.3, + status: 4 }, { - name:'Opera Mini', - percent:3.3, - status:1 + name: 'Opera Mini', + percent: 3.3, + status: 1 }, { - name:'Chromium', - percent:2.53, - status:1 - }, + name: 'Chromium', + percent: 2.53, + status: 1 + } ], - user:{ - name:'zuiidea', - email:'zuiiidea@.gmail.com', - sales:3241, - sold:3556, - avatar:'http://tva4.sinaimg.cn/crop.0.0.996.996.180/6ee6a3a3jw8f0ks5pk7btj20ro0rodi0.jpg' + user: { + name: 'zuiidea', + email: 'zuiiidea@.gmail.com', + sales: 3241, + sold: 3556, + avatar: 'http://tva4.sinaimg.cn/crop.0.0.996.996.180/6ee6a3a3jw8f0ks5pk7btj20ro0rodi0.jpg' }, 'completed|12': [ { @@ -73,24 +71,24 @@ let dataKey = mockStorge('Dashboard', Mock.mock({ { name: '@last', 'status|1-3': 1, - content:'@sentence', - avatar: function(){ - return Mock.Random.image('48x48', Mock.Random.color(),"#757575",'png',this.name.substr(0,1)) - }, - date:function(){ - return '2016-'+Mock.Random.date('MM-dd')+' '+Mock.Random.time('HH:mm:ss') + content: '@sentence', + avatar: function () { + return Mock.Random.image('48x48', Mock.Random.color(), '#757575', 'png', this.name.substr(0, 1)) }, + date: function () { + return '2016-' + Mock.Random.date('MM-dd') + ' ' + Mock.Random.time('HH:mm:ss') + } } ], - 'recentSales|36':[ + 'recentSales|36': [ { 'id|+1': 1, name: '@last', 'status|1-4': 1, - date:function(){ - return Mock.Random.integer(2015, 2016)+'-'+Mock.Random.date('MM-dd')+' '+Mock.Random.time('HH:mm:ss') + date: function () { + return Mock.Random.integer(2015, 2016) + '-' + Mock.Random.date('MM-dd') + ' ' + Mock.Random.time('HH:mm:ss') }, - 'price|10-200.1-2':1 + 'price|10-200.1-2': 1 } ], quote: { diff --git a/mock/users.js b/mock/users.js index 718afaf..7e748b5 100644 --- a/mock/users.js +++ b/mock/users.js @@ -1,9 +1,8 @@ const qs = require('qs') const Mock = require('mockjs') -const Watch = require("watchjs") import mockStorge from '../src/utils/mockStorge' -let dataKey = mockStorge('UsersList',Mock.mock({ +let dataKey = mockStorge('UsersList', Mock.mock({ 'data|100': [ { 'id|+1': 1, @@ -15,8 +14,8 @@ let dataKey = mockStorge('UsersList',Mock.mock({ isMale: '@boolean', email: '@email', createTime: '@datetime', - avatar: function(){ - return Mock.Random.image('100x100', Mock.Random.color(),"#757575",'png',this.nickName.substr(0,1)) + avatar: function () { + return Mock.Random.image('100x100', Mock.Random.color(), '#757575', 'png', this.nickName.substr(0, 1)) } } ], @@ -64,8 +63,8 @@ module.exports = { 'POST /api/users' (req, res) { const newData = req.body - newData.createTime=Mock.mock('@now') - newData.avatar=Mock.Random.image('100x100', Mock.Random.color(),"#757575",'png',newData.nickName.substr(0,1)) + newData.createTime = Mock.mock('@now') + newData.avatar = Mock.Random.image('100x100', Mock.Random.color(), '#757575', 'png', newData.nickName.substr(0, 1)) newData.id = usersListData.data.length + 1 usersListData.data.unshift(newData) @@ -83,7 +82,7 @@ module.exports = { const deleteItem = req.body usersListData.data = usersListData.data.filter(function (item) { - if (item.id == deleteItem.id) { + if (item.id === deleteItem.id) { return false } return true @@ -100,11 +99,11 @@ module.exports = { 'PUT /api/users' (req, res) { const editItem = req.body - editItem.createTime=Mock.mock('@now') - editItem.avatar=Mock.Random.image('100x100', Mock.Random.color(),"#757575",'png',editItem.nickName.substr(0,1)) + editItem.createTime = Mock.mock('@now') + editItem.avatar = Mock.Random.image('100x100', Mock.Random.color(), '#757575', 'png', editItem.nickName.substr(0, 1)) usersListData.data = usersListData.data.map(function (item) { - if (item.id == editItem.id) { + if (item.id === editItem.id) { return editItem } return item diff --git a/npm-debug.log.884992468 b/npm-debug.log.884992468 deleted file mode 100644 index e69de29..0000000 diff --git a/package.json b/package.json index 64b666e..fd815fc 100644 --- a/package.json +++ b/package.json @@ -44,5 +44,9 @@ "lint": "eslint --fix --ext .js,.jsx src/components/layout", "build": "atool-build" }, - "theme": "./src/theme.js" + "theme": "./src/theme.js", + "standard": { + "parser": "babel-eslint", + "globals":["location","localStorage"] + } } diff --git a/proxy.config.js b/proxy.config.js index d3c83e0..3665129 100644 --- a/proxy.config.js +++ b/proxy.config.js @@ -1,10 +1,7 @@ -'use strict' - const mock = {} -require('fs').readdirSync(require('path').join(__dirname + '/mock')) - .forEach(function (file) { - Object.assign(mock, require('./mock/' + file)) - }) +require('fs').readdirSync(require('path').join(`${__dirname}/mock`)).forEach((file) => { + Object.assign(mock, require('./mock/' + file)) +}) module.exports = mock diff --git a/src/components/dashboard/browser.js b/src/components/dashboard/browser.js index 2f6ff90..43fae42 100644 --- a/src/components/dashboard/browser.js +++ b/src/components/dashboard/browser.js @@ -1,37 +1,37 @@ -import React, {PropTypes} from 'react' -import {Icon,Table,Tag} from 'antd' +import React, { PropTypes } from 'react' +import { Table, Tag } from 'antd' import styles from './browser.less' -import {classnames,color} from '../../utils' +import { color } from '../../utils' const status = { - 1:{ - color:color.green + 1: { + color: color.green }, - 2:{ - color:color.red + 2: { + color: color.red }, - 3:{ - color:color.blue - }, - 4:{ - color:color.yellow + 3: { + color: color.blue }, + 4: { + color: color.yellow + } } -function Browser(props) { +function Browser (props) { const columns = [ { title: 'name', dataIndex: 'name', - className:styles.name, + className: styles.name }, { title: 'percent', dataIndex: 'percent', - className:styles.percent, - render:(text,it) => {text}%, - }, + className: styles.percent, + render: (text, it) => {text}% + } ] - return key} dataSource={props.data}/> + return
key} dataSource={props.data} /> } Browser.propTypes = { diff --git a/src/components/dashboard/comments.js b/src/components/dashboard/comments.js index 7722dc5..8dbe27c 100644 --- a/src/components/dashboard/comments.js +++ b/src/components/dashboard/comments.js @@ -1,48 +1,47 @@ -import React, {PropTypes} from 'react' -import {Icon,Table,Tag} from 'antd' +import React from 'react' +import { Table, Tag } from 'antd' import styles from './comments.less' -import {classnames,color} from '../../utils' - +import { color } from '../../utils' const status = { - 1:{ - color:color.green, - text:'APPROVED' + 1: { + color: color.green, + text: 'APPROVED' }, - 2:{ - color:color.yellow, - text:'PENDING' - }, - 3:{ - color:color.red, - text:'REJECTED' + 2: { + color: color.yellow, + text: 'PENDING' }, + 3: { + color: color.red, + text: 'REJECTED' + } } -function Comments(props) { +function Comments (props) { const columns = [ { title: 'avatar', dataIndex: 'avatar', - width:48, - className:styles.avatarcolumn, - render: text => , + width: 48, + className: styles.avatarcolumn, + render: text => }, { title: 'content', dataIndex: 'content', - render:(text,it) =>
+ render: (text, it) =>
{it.name}

{it.content}

{status[it.status].text} {it.date}
-
, - }, +
+ } ] return (
-
key} dataSource={props.data.filter((item,key) => key<3)}/> +
key} dataSource={props.data.filter((item, key) => key < 3)} /> ) } diff --git a/src/components/dashboard/completed.js b/src/components/dashboard/completed.js index 26ad531..ddfa330 100644 --- a/src/components/dashboard/completed.js +++ b/src/components/dashboard/completed.js @@ -1,35 +1,34 @@ -import React, { PropTypes } from 'react' -import { Icon } from 'antd' +import React from 'react' import styles from './completed.less' import {color} from '../../utils' import {AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts' -function Completed(props) { +function Completed (props) { return (
TEAM TOTAL COMPLETED
- - { - const { payload } = props - return
    - {payload.map((item,key) =>
  • {item.value}
  • ) } -
- }}/> - - - - { - const list = content.payload.map((item,key) =>
  • {item.name+':'+item.value}
  • ) - return

    {content.label}

      {list}
    - }}/> - - -
    -
    + + { + const { payload } = props + return
      + {payload.map((item, key) =>
    • {item.value}
    • ) } +
    + }} /> + + + + { + const list = content.payload.map((item, key) =>
  • {item.name + ':' + item.value}
  • ) + return

    {content.label}

      {list}
    + }} /> + + +
    +
    ) } diff --git a/src/components/dashboard/cpu.js b/src/components/dashboard/cpu.js index 815a177..b7ce6d8 100644 --- a/src/components/dashboard/cpu.js +++ b/src/components/dashboard/cpu.js @@ -1,53 +1,53 @@ -import React, {PropTypes} from 'react' +import React, { PropTypes } from 'react' import styles from './cpu.less' -import {classnames,color} from '../../utils' +import { color } from '../../utils' import CountUp from 'react-countup' -import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts' +import { LineChart, Line, XAxis, YAxis, CartesianGrid, ResponsiveContainer } from 'recharts' const countUpProps = { - start:0, - duration:2.75, - useEasing:true, - useGrouping:true, - separator:',' + start: 0, + duration: 2.75, + useEasing: true, + useGrouping: true, + separator: ',' } -function Cpu(props) { +function Cpu (props) { return

    usage

    space

    cpu

    - + - - - - + + + +
    } diff --git a/src/components/dashboard/numberCard.js b/src/components/dashboard/numberCard.js index 5a825fe..2bbca09 100644 --- a/src/components/dashboard/numberCard.js +++ b/src/components/dashboard/numberCard.js @@ -1,12 +1,12 @@ -import React, { PropTypes } from 'react' +import React from 'react' import { Icon, Card } from 'antd' import CountUp from 'react-countup' import styles from './numberCard.less' -function NumberCard(props) { +function NumberCard (props) { const { icon, color, title, number } = props return ( - +

    {title || 'No Title'}

    @@ -15,10 +15,10 @@ function NumberCard(props) { start={0} end={number} duration={2.75} - useEasing={true} - useGrouping={true} - separator="," - {...props.countUp||{}} + useEasing + useGrouping + separator=',' + {...props.countUp || {}} />

    diff --git a/src/components/dashboard/quote.js b/src/components/dashboard/quote.js index 12e96d7..e1148b6 100644 --- a/src/components/dashboard/quote.js +++ b/src/components/dashboard/quote.js @@ -1,9 +1,7 @@ -import React, { PropTypes } from 'react' -import { Icon } from 'antd' +import React from 'react' import styles from './quote.less' -import {classnames} from '../../utils' -function Quote(props) { +function Quote (props) { const { name, content, title, avatar } = props return (
    @@ -15,7 +13,7 @@ function Quote(props) {

    -{name}-

    {title}

    -
    +
    ) diff --git a/src/components/dashboard/recentSales.js b/src/components/dashboard/recentSales.js index 589b029..915af2d 100644 --- a/src/components/dashboard/recentSales.js +++ b/src/components/dashboard/recentSales.js @@ -1,50 +1,49 @@ -import React, {PropTypes} from 'react' -import {Icon,Table,Tag} from 'antd' +import React from 'react' +import { Table, Tag } from 'antd' import styles from './recentSales.less' -import {classnames,color} from '../../utils' - +import { color } from '../../utils' const status = { - 1:{ - color:color.green, - text:'SALE' + 1: { + color: color.green, + text: 'SALE' }, - 2:{ - color:color.yellow, - text:'REJECT' + 2: { + color: color.yellow, + text: 'REJECT' }, - 3:{ - color:color.red, - text:'TAX' + 3: { + color: color.red, + text: 'TAX' }, - 4:{ - color:color.blue, - text:'EXTENDED' + 4: { + color: color.blue, + text: 'EXTENDED' } } -function RecentSales(props) { +function RecentSales (props) { const columns = [ { title: 'NAME', - dataIndex: 'name', + dataIndex: 'name' }, { title: 'STATUS', dataIndex: 'status', - render:text => {status[text].text}, + render: text => {status[text].text} }, { title: 'DATE', dataIndex: 'date', - render:text => new Date(text).format('yyyy-MM-dd'), + render: text => new Date(text).format('yyyy-MM-dd') }, { title: 'PRICE', dataIndex: 'price', - render:(text,it) => ${text}, + render: (text, it) => ${text} } ] return (
    -
    key} dataSource={props.data.filter((item,key) => key<5)}/> +
    key} dataSource={props.data.filter((item, key) => key < 5)} /> ) } diff --git a/src/components/dashboard/sales.js b/src/components/dashboard/sales.js index b270339..565bf46 100644 --- a/src/components/dashboard/sales.js +++ b/src/components/dashboard/sales.js @@ -1,36 +1,35 @@ -import React, { PropTypes } from 'react' -import { Icon } from 'antd' +import React from 'react' import styles from './sales.less' import {color} from '../../utils' import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer} from 'recharts' -function Sales(props) { +function Sales (props) { return (
    Yearly Sales
    - - { - const { payload } = props - return
      - {payload.map((item,key) =>
    • {item.value}
    • ) } -
    - }}/> - - - - { - const list = content.payload.map((item,key) =>
  • {item.name+':'+item.value}
  • ) - return

    {content.label}

      {list}
    - }}/> - - - -
    -
    + + { + const { payload } = props + return
      + {payload.map((item, key) =>
    • {item.value}
    • ) } +
    + }} /> + + + + { + const list = content.payload.map((item, key) =>
  • {item.name + ':' + item.value}
  • ) + return

    {content.label}

      {list}
    + }} /> + + + +
    +
    ) } diff --git a/src/components/dashboard/user.js b/src/components/dashboard/user.js index 13a0e1c..1e7900a 100644 --- a/src/components/dashboard/user.js +++ b/src/components/dashboard/user.js @@ -1,45 +1,45 @@ -import React, {PropTypes} from 'react' -import {Button} from 'antd' +import React, { PropTypes } from 'react' +import { Button } from 'antd' import styles from './user.less' import CountUp from 'react-countup' -import {classnames,color} from '../../utils' +import { color } from '../../utils' const countUpProps = { - start:0, - duration:2.75, - useEasing:true, - useGrouping:true, - separator:',' + start: 0, + duration: 2.75, + useEasing: true, + useGrouping: true, + separator: ',' } -function User(props) { - const {avatar,name,email}=props +function User (props) { + const {avatar, name, email} = props return
    -
    +
    {name}

    {email}

    -
    -

    EARNING SALES

    -

    +

    EARNING SALES

    +

    -
    -
    -

    ITEM SOLD

    -

    +

    +

    ITEM SOLD

    +

    -
    +
    - +
    } diff --git a/src/components/dashboard/weather.js b/src/components/dashboard/weather.js index 7ea81ac..2b2788a 100644 --- a/src/components/dashboard/weather.js +++ b/src/components/dashboard/weather.js @@ -1,14 +1,13 @@ -import React, {PropTypes} from 'react' -import {Icon} from 'antd' +import React from 'react' import styles from './weather.less' -function Weather(props) { +function Weather (props) { const {city, icon, dateTime, temperature, name} = props return
    + }} />

    {name}

    diff --git a/src/components/layout/bread.jsx b/src/components/layout/bread.js similarity index 73% rename from src/components/layout/bread.jsx rename to src/components/layout/bread.js index 912930d..17d72e7 100644 --- a/src/components/layout/bread.jsx +++ b/src/components/layout/bread.js @@ -1,7 +1,7 @@ import React, { PropTypes } from 'react' import { Breadcrumb, Icon } from 'antd' import styles from './main.less' -import { config, menu } from '../../utils' +import { menu } from '../../utils' let pathSet = [] const getPathSet = function (menuArray, parentPath) { @@ -11,16 +11,16 @@ const getPathSet = function (menuArray, parentPath) { path: parentPath + item.key, name: item.name, icon: item.icon || '', - clickable:item.clickable==undefined?true:false + clickable: item.clickable === undefined } - if (!!item.child) { + if (item.child) { getPathSet(item.child, parentPath + item.key + '/') } }) } getPathSet(menu) -function Bread({ location }) { +function Bread ({ location }) { let pathNames = [] location.pathname.substr(1).split('/').map((item, key) => { if (key > 0) { @@ -30,11 +30,11 @@ function Bread({ location }) { } }) const breads = pathNames.map((item, key) => { - if(!(item in pathSet)){ - item='Dashboard' + if (!(item in pathSet)) { + item = 'Dashboard' } return ( - + {pathSet[item].icon ? : ''} @@ -46,7 +46,7 @@ function Bread({ location }) { return (
    - + 主页 {breads} @@ -56,7 +56,7 @@ function Bread({ location }) { } Bread.propTypes = { - location: PropTypes.object, + location: PropTypes.object } export default Bread diff --git a/src/components/layout/footer.jsx b/src/components/layout/footer.js similarity index 81% rename from src/components/layout/footer.jsx rename to src/components/layout/footer.js index ce9668c..5b7332e 100644 --- a/src/components/layout/footer.jsx +++ b/src/components/layout/footer.js @@ -1,4 +1,4 @@ -import React, { PropTypes } from 'react' +import React from 'react' import styles from './main.less' import { config } from '../../utils' diff --git a/src/components/layout/header.jsx b/src/components/layout/header.js similarity index 52% rename from src/components/layout/header.jsx rename to src/components/layout/header.js index 5de1821..7c1e53e 100644 --- a/src/components/layout/header.jsx +++ b/src/components/layout/header.js @@ -1,37 +1,36 @@ -import React, {PropTypes} from 'react' -import {Menu, Icon, Popover} from 'antd' -import {Link} from 'dva/router' +import React from 'react' +import { Menu, Icon, Popover } from 'antd' import styles from './main.less' import Menus from './menu' const SubMenu = Menu.SubMenu -function Header({user, logout, switchSider, siderFold, isNavbar ,location}) { +function Header ({user, logout, switchSider, siderFold, isNavbar, location}) { let handleClickMenu = e => e.key === 'logout' && logout() const menusProps = { - siderFold:false, - darkTheme:false, + siderFold: false, + darkTheme: false, isNavbar, location } return (
    {isNavbar - ? }> + ? }>
    - +
    :
    - +
    } - + + }} title={< span > {user.name} < /span>}> - + 注销 diff --git a/src/components/layout/menu.js b/src/components/layout/menu.js index 2ddcd1b..51d8855 100644 --- a/src/components/layout/menu.js +++ b/src/components/layout/menu.js @@ -1,18 +1,16 @@ -import React, { PropTypes } from 'react' +import React from 'react' import { Menu, Icon } from 'antd' import { Link } from 'dva/router' -import styles from './main.less' import { menu } from '../../utils' - -const topMenus = menu.map( item => item.key) -const getMenus = function (menuArray,siderFold,parentPath) { +const topMenus = menu.map(item => item.key) +const getMenus = function (menuArray, siderFold, parentPath) { parentPath = parentPath || '/' return menuArray.map(item => { - if (!!item.child) { + if (item.child) { return ( - {item.icon ? : ''}{siderFold&&topMenus.indexOf(item.key)>=0 ? '' : item.name}}> - {getMenus(item.child,siderFold,parentPath + item.key + '/')} + {item.icon ? : ''}{siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name}}> + {getMenus(item.child, siderFold, parentPath + item.key + '/')} ) } else { @@ -20,7 +18,7 @@ const getMenus = function (menuArray,siderFold,parentPath) { {item.icon ? : ''} - {siderFold&&topMenus.indexOf(item.key)>=0 ? '' : item.name} + {siderFold && topMenus.indexOf(item.key) >= 0 ? '' : item.name} ) @@ -28,16 +26,16 @@ const getMenus = function (menuArray,siderFold,parentPath) { }) } -function Menus({ siderFold,darkTheme,location,isNavbar }) { - const menuItems = getMenus(menu,siderFold) +function Menus ({ siderFold, darkTheme, location, isNavbar }) { + const menuItems = getMenus(menu, siderFold) return ( - item.key):[]} - defaultSelectedKeys={[location.pathname.split('/')[location.pathname.split('/').length - 1]||'dashboard']}> - {menuItems} - + item.key) : []} + defaultSelectedKeys={[location.pathname.split('/')[location.pathname.split('/').length - 1] || 'dashboard']}> + {menuItems} + ) } diff --git a/src/components/layout/sider.js b/src/components/layout/sider.js new file mode 100644 index 0000000..882fa92 --- /dev/null +++ b/src/components/layout/sider.js @@ -0,0 +1,28 @@ +import React from 'react' +import { Icon, Switch } from 'antd' +import styles from './main.less' +import { config } from '../../utils' +import Menus from './menu' + +function Sider ({ siderFold, darkTheme, location, changeTheme }) { + const menusProps = { + siderFold, + darkTheme, + location + } + return ( +
    +
    + + {siderFold ? '' : {config.logoText}} +
    + + {!siderFold ?
    + 切换主题 + +
    : ''} +
    + ) +} + +export default Sider diff --git a/src/components/layout/sider.jsx b/src/components/layout/sider.jsx deleted file mode 100644 index 4b8356e..0000000 --- a/src/components/layout/sider.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, { PropTypes } from 'react' -import { Menu, Icon, Switch } from 'antd' -import { Link } from 'dva/router' -import styles from './main.less' -import { config } from '../../utils' -import Menus from './menu' - -function Sider({ siderFold,darkTheme,location,changeTheme }) { - const menusProps={ - siderFold, - darkTheme, - location - } - return ( -
    -
    - - {siderFold?'':{config.logoText}} -
    - - {!siderFold?
    - 切换主题 - -
    :''} -
    - ) -} - -export default Sider diff --git a/src/components/ui/ico.js b/src/components/ui/ico.js index 2e48ec9..901ec71 100644 --- a/src/components/ui/ico.js +++ b/src/components/ui/ico.js @@ -1,8 +1,7 @@ -import React, {PropTypes} from 'react' -import styles from './ico.less' +import React from 'react' const Ico = ({type}) => }, { title: '电话', dataIndex: 'phone', - key: 'phone', + key: 'phone' }, { title: '邮箱', dataIndex: 'email', - key: 'email', + key: 'email' }, { title: '住址', dataIndex: 'address', - key: 'address', + key: 'address' }, { title: '创建时间', dataIndex: 'createTime', - key: 'createTime', + key: 'createTime' }, { title: '操作', key: 'operation', @@ -61,14 +61,14 @@ function list({ render: (text, record) => (

    onEditItem(record)} style={{ - marginRight: 4, + marginRight: 4 }}>编辑 - onDeleteItem(record.id)}> + onDeleteItem(record.id)}> 删除

    - ), - }, + ) + } ] return ( @@ -95,7 +95,7 @@ list.propTypes = { onEditItem: PropTypes.func, dataSource: PropTypes.array, loading: PropTypes.any, - pagination: PropTypes.any, + pagination: PropTypes.any } export default list diff --git a/src/components/users/modal.jsx b/src/components/users/modal.js similarity index 68% rename from src/components/users/modal.jsx rename to src/components/users/modal.js index 9a4f921..fb701b6 100644 --- a/src/components/users/modal.jsx +++ b/src/components/users/modal.js @@ -4,11 +4,11 @@ const FormItem = Form.Item const formItemLayout = { labelCol: { - span: 6, + span: 6 }, wrapperCol: { - span: 14, - }, + span: 14 + } } const modal = ({ @@ -19,17 +19,17 @@ const modal = ({ form: { getFieldDecorator, validateFields, - getFieldsValue, - }, + getFieldsValue + } }) => { - function handleOk() { + function handleOk () { validateFields((errors) => { if (errors) { return } const data = { ...getFieldsValue(), - key: item.key, + key: item.key } onOk(data) }) @@ -40,44 +40,44 @@ const modal = ({ visible, onOk: handleOk, onCancel, - wrapClassName: 'vertical-center-modal', + wrapClassName: 'vertical-center-modal' } return (
    - + {getFieldDecorator('name', { initialValue: item.name, rules: [ { required: true, - message: '姓名未填写', - }, - ], + message: '姓名未填写' + } + ] })()} - + {getFieldDecorator('nickName', { initialValue: item.nickName, rules: [ { required: true, - message: '昵称未填写', - }, - ], + message: '昵称未填写' + } + ] })()} - + {getFieldDecorator('isMale', { initialValue: item.isMale, rules: [ { required: true, type: 'boolean', - message: '请选择性别', - }, - ], + message: '请选择性别' + } + ] })( 男 @@ -85,49 +85,49 @@ const modal = ({ )} - + {getFieldDecorator('age', { initialValue: item.age, rules: [ { required: true, type: 'number', - message: '年龄未填写', - }, - ], + message: '年龄未填写' + } + ] })()} - + {getFieldDecorator('phone', { initialValue: item.phone, rules: [ { required: true, - message: '不能为空', - }, - ], + message: '不能为空' + } + ] })()} - + {getFieldDecorator('email', { initialValue: item.email, rules: [ { required: true, - message: '不能为空', - }, - ], + message: '不能为空' + } + ] })()} - + {getFieldDecorator('address', { initialValue: item.address, rules: [ { required: true, - message: '不能为空', - }, - ], + message: '不能为空' + } + ] })()} @@ -140,7 +140,7 @@ modal.propTypes = { form: PropTypes.object, item: PropTypes.object, onOk: PropTypes.func, - onCancel: PropTypes.func, + onCancel: PropTypes.func } export default Form.create()(modal) diff --git a/src/components/users/search.jsx b/src/components/users/search.js similarity index 70% rename from src/components/users/search.jsx rename to src/components/users/search.js index c6828cb..4b060d4 100644 --- a/src/components/users/search.jsx +++ b/src/components/users/search.js @@ -10,13 +10,13 @@ const search = ({ form: { getFieldDecorator, validateFields, - getFieldsValue, - }, + getFieldsValue + } }) => { - function handleSubmit(e) { + function handleSubmit (e) { e.preventDefault() validateFields((errors) => { - if (!!errors) { + if (errors) { return } onSearch(getFieldsValue()) @@ -29,24 +29,24 @@ const search = ({
    {getFieldDecorator('field', { - initialValue: field || 'name', + initialValue: field || 'name' })( )} {getFieldDecorator('keyword', { - initialValue: keyword || '', + initialValue: keyword || '' })()} - +
    - +
    ) @@ -57,7 +57,7 @@ search.propTypes = { onSearch: PropTypes.func, onAdd: PropTypes.func, field: PropTypes.string, - keyword: PropTypes.string, + keyword: PropTypes.string } export default Form.create()(search) diff --git a/src/models/app.js b/src/models/app.js index 91a2ac4..5f8633b 100644 --- a/src/models/app.js +++ b/src/models/app.js @@ -1,45 +1,47 @@ import {login, userInfo, logout} from '../services/app' import {parse} from 'qs' -import Cookie from 'js-cookie' export default { - namespace : 'app', - state : { + namespace: 'app', + state: { login: false, loading: false, user: { - name: "吴彦祖" + name: '吴彦祖' }, loginButtonLoading: false, - siderFold:localStorage.getItem("antdAdminSiderFold")==="true"?true:false, - darkTheme:localStorage.getItem("antdAdminDarkTheme")==="false"?false:true, - isNavbar:document.body.clientWidth<769?true:false, + siderFold: localStorage.getItem('antdAdminSiderFold') === 'true', + darkTheme: localStorage.getItem('antdAdminDarkTheme') !== 'false', + isNavbar: document.body.clientWidth < 769 }, - subscriptions : { - setup({dispatch}) { + subscriptions: { + setup ({dispatch}) { dispatch({type: 'queryUser'}) - window.onresize = function(){ + window.onresize = function () { dispatch({type: 'changeNavbar'}) } } }, - effects : { - *login({ + effects: { + *login ({ payload }, {call, put}) { yield put({type: 'showLoginButtonLoading'}) const data = yield call(login, parse(payload)) if (data.success) { - yield put({type: 'loginSuccess', payload: { + yield put({ + type: 'loginSuccess', + payload: { data }}) } else { - yield put({type: 'loginFail', payload: { - data - }}) + yield put({ + type: 'loginFail', + payload: {data} + }) } }, - *queryUser({ + *queryUser ({ payload }, {call, put}) { yield put({type: 'showLoading'}) @@ -57,42 +59,42 @@ export default { yield put({type: 'hideLoading'}) } }, - *logout({ + *logout ({ payload }, {call, put}) { const data = yield call(logout, parse(payload)) - if(data.success){ + if (data.success) { yield put({ type: 'logoutSuccess' }) } }, - *switchSider({ + *switchSider ({ payload }, {put}) { yield put({ type: 'handleSwitchSider' }) }, - *changeTheme({ + *changeTheme ({ payload }, {put}) { yield put({ type: 'handleChangeTheme' }) }, - *changeNavbar({ + *changeNavbar ({ payload }, {put}) { - if(document.body.clientWidth<769){ + if (document.body.clientWidth < 769) { yield put({type: 'showNavbar'}) - }else { + } else { yield put({type: 'hideNavbar'}) } - }, + } }, - reducers : { - loginSuccess(state, action) { + reducers: { + loginSuccess (state, action) { return { ...state, ...action.payload, @@ -100,58 +102,58 @@ export default { loginButtonLoading: false } }, - logoutSuccess(state){ + logoutSuccess (state) { return { ...state, login: false } }, - loginFail(state) { + loginFail (state) { return { ...state, login: false, loginButtonLoading: false } }, - showLoginButtonLoading(state) { + showLoginButtonLoading (state) { return { ...state, loginButtonLoading: true } }, - showLoading(state) { + showLoading (state) { return { ...state, loading: true } }, - hideLoading(state) { + hideLoading (state) { return { ...state, loading: false } }, - handleSwitchSider(state) { - localStorage.setItem("antdAdminSiderFold",!state.darkTheme) + handleSwitchSider (state) { + localStorage.setItem('antdAdminSiderFold', !state.darkTheme) return { ...state, siderFold: !state.siderFold } }, - handleChangeTheme(state) { - localStorage.setItem("antdAdminDarkTheme",!state.darkTheme) + handleChangeTheme (state) { + localStorage.setItem('antdAdminDarkTheme', !state.darkTheme) return { ...state, darkTheme: !state.darkTheme } }, - showNavbar(state) { + showNavbar (state) { return { ...state, isNavbar: true } }, - hideNavbar(state) { + hideNavbar (state) { return { ...state, isNavbar: false diff --git a/src/models/dashboard.js b/src/models/dashboard.js index d9a7325..25294ae 100644 --- a/src/models/dashboard.js +++ b/src/models/dashboard.js @@ -1,11 +1,11 @@ -import {myCity, queryWeather , query} from '../services/dashboard' +import {myCity, queryWeather, query} from '../services/dashboard' import {parse} from 'qs' // zuimei 摘自 http://www.zuimeitianqi.com/res/js/index.js let zuimei = { ParseActualData: function (actual, air) { let weather = { - icon: 'http://www.zuimeitianqi.com/res/icon/' + zuimei.GetIconName(actual.wea, "big"), + icon: 'http://www.zuimeitianqi.com/res/icon/' + zuimei.GetIconName(actual.wea, 'big'), name: zuimei.GetWeatherName(actual.wea), temperature: actual.tmp, dateTime: new Date(actual.PTm).format('MM-dd hh:mm') @@ -17,28 +17,28 @@ let zuimei = { let myDate = new Date() let hour = myDate.getHours() let num = 0 - if (wea.indexOf("/") != -1) { - let weas = wea.split("/") + if (wea.indexOf('/') !== -1) { + let weas = wea.split('/') if (hour < 12) { num = zuimei.ReplaceIcon(weas[0]) if (num < 6) { - num = num + "_" + flg + "_night.png" + num = num + '_' + flg + '_night.png' } else { - num = num + "_" + flg + ".png" + num = num + '_' + flg + '.png' } - } else if (12 <= hour) { + } else if (hour >= 12) { num = zuimei.ReplaceIcon(weas[1]) if (hour >= 18) { - num = num + "_" + flg + "_night.png" + num = num + '_' + flg + '_night.png' } else { - num = num + "_" + flg + ".png" + num = num + '_' + flg + '.png' } } } else { if ((hour >= 18 && hour <= 23) || (hour >= 0 && hour <= 6)) { - num = num + "_" + flg + "_night.png" + num = num + '_' + flg + '_night.png' } else { - num = num + "_" + flg + ".png" + num = num + '_' + flg + '.png' } } @@ -46,21 +46,21 @@ let zuimei = { }, ReplaceIcon: function (num) { - if (num == 21) { + if (num === 21) { num = 7 - } else if (num == 22) { + } else if (num === 22) { num = 8 - } else if (num == 10 || num == 11 || num == 12 || num == 23 || num == 24 || num == 25) { + } else if (num === 10 || num === 11 || num === 12 || num === 23 || num === 24 || num === 25) { num = 9 - } else if (num == 13 || num == 15 || num == 26 || num == 27 || num == 34) { + } else if (num === 13 || num === 15 || num === 26 || num === 27 || num === 34) { num = 14 - } else if (num == 17 || num == 28) { + } else if (num === 17 || num === 28) { num = 16 - } else if (num == 35) { + } else if (num === 35) { num = 18 - } else if (num == 31 || num == 32 || num == 33) { + } else if (num === 31 || num === 32 || num === 33) { num = 20 - } else if (num == 30) { + } else if (num === 30) { num = 29 } @@ -68,10 +68,10 @@ let zuimei = { }, GetWeatherName: function (wea) { - let name = "" - if (wea.indexOf("/") != -1) { - let weas = wea.split("/") - name = zuimei.GetWeatherByCode(weas[0]) + "转" + zuimei.GetWeatherByCode(weas[1]) + let name = '' + if (wea.indexOf('/') !== -1) { + let weas = wea.split('/') + name = zuimei.GetWeatherByCode(weas[0]) + '转' + zuimei.GetWeatherByCode(weas[1]) } else { name = zuimei.GetWeatherByCode(wea) } @@ -80,83 +80,83 @@ let zuimei = { }, GetWeatherByCode: function (num) { - let wea = "" - if (num == 0) { - wea = "晴" - } else if (num == 1) { - wea = "多云" - } else if (num == 2) { - wea = "阴" - } else if (num == 3) { - wea = "阵雨" - } else if (num == 4) { - wea = "雷阵雨" - } else if (num == 5) { - wea = "雷阵雨并伴有冰雹" - } else if (num == 6) { - wea = "雨夹雪" - } else if (num == 7) { - wea = "小雨" - } else if (num == 8) { - wea = "中雨" - } else if (num == 9) { - wea = "大雨" - } else if (num == 10) { - wea = "暴雨" - } else if (num == 11) { - wea = "大暴雨" - } else if (num == 12) { - wea = "特大暴雨" - } else if (num == 13) { - wea = "阵雪" - } else if (num == 14) { - wea = "小雪" - } else if (num == 15) { - wea = "中雪" - } else if (num == 16) { - wea = "大雪" - } else if (num == 17) { - wea = "暴雪" - } else if (num == 18) { - wea = "雾" - } else if (num == 19) { - wea = "冻雨" - } else if (num == 20) { - wea = "沙尘暴" - } else if (num == 21) { - wea = "小雨-中雨" - } else if (num == 22) { - wea = "中雨-大雨" - } else if (num == 23) { - wea = "大雨-暴雨" - } else if (num == 24) { - wea = "暴雨-大暴雨" - } else if (num == 25) { - wea = "大暴雨-特大暴雨" - } else if (num == 26) { - wea = "小雪-中雪" - } else if (num == 27) { - wea = "中雪-大雪" - } else if (num == 28) { - wea = "大雪-暴雪" - } else if (num == 29) { - wea = "浮沉" - } else if (num == 30) { - wea = "扬沙" - } else if (num == 31) { - wea = "强沙尘暴" - } else if (num == 32) { - wea = "飑" - } else if (num == 33) { - wea = "龙卷风" - } else if (num == 34) { - wea = "若高吹雪" - } else if (num == 35) { - wea = "轻雾" - } else if (num == 53) { - wea = "霾" - } else if (num == 99) { - wea = "未知" + let wea = '' + if (num === 0) { + wea = '晴' + } else if (num === 1) { + wea = '多云' + } else if (num === 2) { + wea = '阴' + } else if (num === 3) { + wea = '阵雨' + } else if (num === 4) { + wea = '雷阵雨' + } else if (num === 5) { + wea = '雷阵雨并伴有冰雹' + } else if (num === 6) { + wea = '雨夹雪' + } else if (num === 7) { + wea = '小雨' + } else if (num === 8) { + wea = '中雨' + } else if (num === 9) { + wea = '大雨' + } else if (num === 10) { + wea = '暴雨' + } else if (num === 11) { + wea = '大暴雨' + } else if (num === 12) { + wea = '特大暴雨' + } else if (num === 13) { + wea = '阵雪' + } else if (num === 14) { + wea = '小雪' + } else if (num === 15) { + wea = '中雪' + } else if (num === 16) { + wea = '大雪' + } else if (num === 17) { + wea = '暴雪' + } else if (num === 18) { + wea = '雾' + } else if (num === 19) { + wea = '冻雨' + } else if (num === 20) { + wea = '沙尘暴' + } else if (num === 21) { + wea = '小雨-中雨' + } else if (num === 22) { + wea = '中雨-大雨' + } else if (num === 23) { + wea = '大雨-暴雨' + } else if (num === 24) { + wea = '暴雨-大暴雨' + } else if (num === 25) { + wea = '大暴雨-特大暴雨' + } else if (num === 26) { + wea = '小雪-中雪' + } else if (num === 27) { + wea = '中雪-大雪' + } else if (num === 28) { + wea = '大雪-暴雪' + } else if (num === 29) { + wea = '浮沉' + } else if (num === 30) { + wea = '扬沙' + } else if (num === 31) { + wea = '强沙尘暴' + } else if (num === 32) { + wea = '飑' + } else if (num === 33) { + wea = '龙卷风' + } else if (num === 34) { + wea = '若高吹雪' + } else if (num === 35) { + wea = '轻雾' + } else if (num === 53) { + wea = '霾' + } else if (num === 99) { + wea = '未知' } return wea @@ -164,8 +164,8 @@ let zuimei = { } export default { - namespace : 'dashboard', - state : { + namespace: 'dashboard', + state: { weather: { city: '成都', temperature: '5', @@ -173,34 +173,34 @@ export default { icon: 'http://www.zuimeitianqi.com/res/icon/0_big.png', dateTime: new Date().format('MM-dd hh:mm') }, - sales:[], - quote:{ + sales: [], + quote: { avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236' }, - numbers:[], - recentSales:[], - comments:[], - completed:[], - browser:[], - cpu:{}, - user:{ + numbers: [], + recentSales: [], + comments: [], + completed: [], + browser: [], + cpu: {}, + user: { avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236' - }, + } }, - subscriptions : { - setup({dispatch}) { + subscriptions: { + setup ({dispatch}) { dispatch({type: 'queryWeather'}) dispatch({type: 'query'}) } }, - effects : { - *query({ + effects: { + *query ({ payload }, {call, put}) { const data = yield call(query, parse(payload)) yield put({type: 'queryWeather', payload: {...data}}) }, - *queryWeather({ + *queryWeather ({ payload }, {call, put}) { const myCityResult = yield call(myCity, {flg: 0}) @@ -211,22 +211,22 @@ export default { weather.city = myCityData.selectCityName yield put({type: 'queryWeatherSuccess', payload: { - weather - }}) + weather + }}) } }, - reducers : { - queryWeatherSuccess(state, action) { + reducers: { + queryWeatherSuccess (state, action) { return { ...state, ...action.payload } }, - queryWeather(state, action) { + queryWeather (state, action) { return { ...state, ...action.payload } - }, + } } } diff --git a/src/models/users.js b/src/models/users.js index 93d3390..ba7215a 100644 --- a/src/models/users.js +++ b/src/models/users.js @@ -11,30 +11,30 @@ export default { currentItem: {}, modalVisible: false, modalType: 'create', - pagination:{ + pagination: { showSizeChanger: true, showQuickJumper: true, showTotal: total => `共 ${total} 条`, - current:1, - total:null, + current: 1, + total: null } }, subscriptions: { - setup({ dispatch, history }) { + setup ({ dispatch, history }) { history.listen(location => { if (location.pathname === '/users') { dispatch({ type: 'query', - payload: location.query, + payload: location.query }) } }) - }, + } }, effects: { - *query({ payload }, { call, put }) { + *query ({ payload }, { call, put }) { yield put({ type: 'showLoading' }) const data = yield call(query, parse(payload)) if (data) { @@ -42,15 +42,15 @@ export default { type: 'querySuccess', payload: { list: data.data, - pagination:{ + pagination: { total: data.page.total, - current: data.page.current, + current: data.page.current } - }, + } }) } }, - *'delete'({ payload }, { call, put }) { + *'delete' ({ payload }, { call, put }) { yield put({ type: 'showLoading' }) const data = yield call(remove, { id: payload }) if (data && data.success) { @@ -58,15 +58,15 @@ export default { type: 'querySuccess', payload: { list: data.data, - pagination:{ + pagination: { total: data.page.total, - current: data.page.current, + current: data.page.current } - }, + } }) } }, - *create({ payload }, { call, put }) { + *create ({ payload }, { call, put }) { yield put({ type: 'hideModal' }) yield put({ type: 'showLoading' }) const data = yield call(create, payload) @@ -75,15 +75,15 @@ export default { type: 'querySuccess', payload: { list: data.data, - pagination:{ + pagination: { total: data.page.total, - current: data.page.current, + current: data.page.current } - }, + } }) } }, - *update({ payload }, { select, call, put }) { + *update ({ payload }, { select, call, put }) { yield put({ type: 'hideModal' }) yield put({ type: 'showLoading' }) const id = yield select(({ users }) => users.currentItem.id) @@ -94,29 +94,29 @@ export default { type: 'querySuccess', payload: { list: data.data, - pagination:{ + pagination: { total: data.page.total, - current: data.page.current, + current: data.page.current } - }, + } }) } - }, + } }, reducers: { - showLoading(state) { + showLoading (state) { return { ...state, loading: true } }, - querySuccess(state, action) { + querySuccess (state, action) { return { ...state, ...action.payload, loading: false } }, - showModal(state, action) { + showModal (state, action) { return { ...state, ...action.payload, modalVisible: true } }, - hideModal(state) { + hideModal (state) { return { ...state, modalVisible: false } - }, - }, + } + } } diff --git a/src/router.js b/src/router.js index 0f0f6e7..4f5a6ae 100644 --- a/src/router.js +++ b/src/router.js @@ -3,12 +3,11 @@ import {Router} from 'dva/router' import App from './routes/app' export default function ({history, app}) { - const routes = [ { path: '/', component: App, - getIndexRoute(nextState, cb) { + getIndexRoute (nextState, cb) { require.ensure([], require => { app.model(require('./models/dashboard')) cb(null, {component: require('./routes/dashboard')}) @@ -18,7 +17,7 @@ export default function ({history, app}) { { path: 'dashboard', name: 'dashboard', - getComponent(nextState, cb) { + getComponent (nextState, cb) { require.ensure([], require => { app.model(require('./models/dashboard')) cb(null, require('./routes/dashboard')) @@ -27,7 +26,7 @@ export default function ({history, app}) { }, { path: 'users', name: 'users', - getComponent(nextState, cb) { + getComponent (nextState, cb) { require.ensure([], require => { app.model(require('./models/users')) cb(null, require('./routes/users')) @@ -36,7 +35,7 @@ export default function ({history, app}) { }, { path: 'ui/ico', name: 'ui/ico', - getComponent(nextState, cb) { + getComponent (nextState, cb) { require.ensure([], require => { cb(null, require('./routes/ui/ico')) }) @@ -44,7 +43,7 @@ export default function ({history, app}) { }, { path: '*', name: 'error', - getComponent(nextState, cb) { + getComponent (nextState, cb) { require.ensure([], require => { cb(null, require('./routes/error')) }) @@ -54,5 +53,5 @@ export default function ({history, app}) { } ] - return + return } diff --git a/src/routes/app.js b/src/routes/app.js index 3188d28..c66778c 100644 --- a/src/routes/app.js +++ b/src/routes/app.js @@ -1,21 +1,21 @@ -import React, {PropTypes} from 'react' -import {connect} from 'dva' +import React, { PropTypes } from 'react' +import { connect } from 'dva' import Login from './login' import Header from '../components/layout/header' import Bread from '../components/layout/bread' import Footer from '../components/layout/footer' import Sider from '../components/layout/sider' import styles from '../components/layout/main.less' -import {Spin,message} from 'antd' -import {classnames} from '../utils' +import { Spin } from 'antd' +import { classnames } from '../utils' import '../components/layout/common.less' -function App({children, location, dispatch, app}) { +function App ({children, location, dispatch, app}) { const {login, loading, loginButtonLoading, user, siderFold, darkTheme, isNavbar} = app const loginProps = { loading, loginButtonLoading, - onOk(data) { + onOk (data) { dispatch({type: 'app/login', payload: data}) } } @@ -25,10 +25,10 @@ function App({children, location, dispatch, app}) { siderFold, location, isNavbar, - logout() { + logout () { dispatch({type: 'app/logout'}) }, - switchSider() { + switchSider () { dispatch({type: 'app/switchSider'}) } } @@ -37,29 +37,29 @@ function App({children, location, dispatch, app}) { siderFold, darkTheme, location, - changeTheme(){ + changeTheme () { dispatch({type: 'app/changeTheme'}) } } return (
    {login - ?
    - {!isNavbar?:''} -
    -
    - -
    -
    - {children} -
    + ?
    + {!isNavbar ? : ''} +
    +
    + +
    +
    + {children}
    -
    +
    - :
    }
    +
    + :
    }
    ) } @@ -71,8 +71,8 @@ App.propTypes = { loginButtonLoading: PropTypes.bool, login: PropTypes.bool, user: PropTypes.object, - siderFold:PropTypes.bool, - darkTheme:PropTypes.bool, + siderFold: PropTypes.bool, + darkTheme: PropTypes.bool } export default connect(({app}) => ({app}))(App) diff --git a/src/routes/dashboard.js b/src/routes/dashboard.js index 9b47ca1..dd2f596 100644 --- a/src/routes/dashboard.js +++ b/src/routes/dashboard.js @@ -1,7 +1,6 @@ import React, {PropTypes} from 'react' import {connect} from 'dva' -import {Link} from 'dva/router' -import {Row, Col, Icon, Card} from 'antd' +import {Row, Col, Card} from 'antd' import NumberCard from '../components/dashboard/numberCard' import Quote from '../components/dashboard/quote' import Sales from '../components/dashboard/sales' @@ -16,17 +15,16 @@ import styles from './dashboard.less' import {color} from '../utils' const bodyStyle = { - bodyStyle:{ + bodyStyle: { height: 432, - background: '#fff', + background: '#fff' } } -function Dashboard({dashboard,dispatch}) { - +function Dashboard ({dashboard, dispatch}) { const {weather, sales, quote, numbers, recentSales, comments, completed, browser, cpu, user} = dashboard const numberCards = numbers.map((item, key) =>
    - + ) return ( @@ -36,7 +34,7 @@ function Dashboard({dashboard,dispatch}) { - + @@ -47,7 +45,7 @@ function Dashboard({dashboard,dispatch}) { height: 204, background: color.blue }}> - + @@ -56,41 +54,41 @@ function Dashboard({dashboard,dispatch}) { height: 204, background: color.peach }}> - + - + - + - + - + - + - - + + @@ -107,7 +105,7 @@ Dashboard.propTypes = { completed: PropTypes.array, browser: PropTypes.array, cpu: PropTypes.object, - user: PropTypes.object, + user: PropTypes.object } export default connect(({dashboard}) => ({dashboard}))(Dashboard) diff --git a/src/routes/error.js b/src/routes/error.js index 80be194..5285478 100644 --- a/src/routes/error.js +++ b/src/routes/error.js @@ -2,9 +2,9 @@ import React from 'react' import {Icon} from 'antd' import styles from './error.less' -const Error = () =>
    +const Error = () =>
    - +

    404 Not Found

    diff --git a/src/routes/login.js b/src/routes/login.js index 9df2a7a..b8d6285 100644 --- a/src/routes/login.js +++ b/src/routes/login.js @@ -1,15 +1,6 @@ import React, {PropTypes} from 'react' -import { - Icon, - message, - Button, - Row, - Col, - Form, - Input, - Select -} from 'antd' -import {config} from '../utils' +import { Button, Row, Form, Input } from 'antd' +import { config } from '../utils' import styles from './login.less' const FormItem = Form.Item @@ -22,8 +13,7 @@ const login = ({ validateFieldsAndScroll } }) => { - - function handleOk() { + function handleOk () { validateFieldsAndScroll((errors, values) => { if (errors) { return @@ -32,12 +22,12 @@ const login = ({ }) } - document.onkeyup = e => e.keyCode===13 && handleOk() + document.onkeyup = e => e.keyCode === 13 && handleOk() return (
    - + Ant Design
    @@ -49,7 +39,7 @@ const login = ({ message: '请填写用户名' } ] - })()} + })()} {getFieldDecorator('password', { @@ -59,10 +49,10 @@ const login = ({ message: '请填写密码' } ] - })()} + })()} - @@ -77,7 +67,7 @@ const login = ({ login.propTypes = { form: PropTypes.object, - loginButtonLoading:PropTypes.bool, + loginButtonLoading: PropTypes.bool, onOk: PropTypes.func } diff --git a/src/routes/ui/ico.js b/src/routes/ui/ico.js index 844e1cd..4d6eaa0 100644 --- a/src/routes/ui/ico.js +++ b/src/routes/ui/ico.js @@ -1,43 +1,43 @@ -import React, { PropTypes } from 'react' -import {Ico} from '../../components/ui' -import {Table} from 'antd' +import React from 'react' +import { Ico } from '../../components/ui' +import { Table } from 'antd' import styles from './ico.less' -const iconlist = ['Cherry','Cheese','Bread','Beer','Beet','Bacon','Banana','Asparagus','Apple'] +const iconlist = ['Cherry', 'Cheese', 'Bread', 'Beer', 'Beet', 'Bacon', 'Banana', 'Asparagus', 'Apple'] -const IcoPage = () =>
    +const IcoPage = () =>
      - {iconlist.map ( item =>
    • {item}
    • )} + {iconlist.map(item =>
    • {item}
    • )}
    -

    Props

    -
    key} - pagination={false} - bordered - columns={[ - { - title: '参数', - dataIndex: 'props', - }, - { - title: '说明', - dataIndex: 'desciption', - }, - { - title: '类型', - dataIndex: 'type', - }, - { - title: '默认值', - dataIndex: 'default', - } - ]} - dataSource={[ - { - props:'type', - desciption:'图标类型', - type:'string', - default:'-' - }]} /> +

    Props

    +
    key} + pagination={false} + bordered + columns={[ + { + title: '参数', + dataIndex: 'props' + }, + { + title: '说明', + dataIndex: 'desciption' + }, + { + title: '类型', + dataIndex: 'type' + }, + { + title: '默认值', + dataIndex: 'default' + } + ]} + dataSource={[ + { + props: 'type', + desciption: '图标类型', + type: 'string', + default: '-' + }]} /> export default IcoPage diff --git a/src/routes/users.js b/src/routes/users.js index 84e29a1..b4be09b 100644 --- a/src/routes/users.js +++ b/src/routes/users.js @@ -5,85 +5,81 @@ import UserList from '../components/users/list' import UserSearch from '../components/users/search' import UserModal from '../components/users/modal' -function Users({ location, dispatch, users }) { - const { - loading, list, total, current, pagination, - currentItem, modalVisible, modalType, - } = users - +function Users ({ location, dispatch, users }) { + const { loading, list, pagination, currentItem, modalVisible, modalType } = users const { field, keyword } = location.query const userModalProps = { item: modalType === 'create' ? {} : currentItem, type: modalType, visible: modalVisible, - onOk(data) { + onOk (data) { dispatch({ type: `users/${modalType}`, - payload: data, + payload: data }) }, - onCancel() { + onCancel () { dispatch({ - type: 'users/hideModal', + type: 'users/hideModal' }) - }, + } } const userListProps = { dataSource: list, loading, - pagination:pagination, - onPageChange(page) { + pagination: pagination, + onPageChange (page) { dispatch(routerRedux.push({ pathname: '/users', query: { - page:page.current, - pageSize:page.pageSize - }, + page: page.current, + pageSize: page.pageSize + } })) }, - onDeleteItem(id) { + onDeleteItem (id) { dispatch({ type: 'users/delete', - payload: id, + payload: id }) }, - onEditItem(item) { + onEditItem (item) { dispatch({ type: 'users/showModal', payload: { modalType: 'update', - currentItem: item, - }, + currentItem: item + } }) - }, + } } const userSearchProps = { field, keyword, - onSearch(fieldsValue) { + onSearch (fieldsValue) { dispatch({ type: 'users/query', - payload: fieldsValue, + payload: fieldsValue }) }, - onAdd() { + onAdd () { dispatch({ type: 'users/showModal', payload: { - modalType: 'create', - }, + modalType: 'create' + } }) - }, + } } const UserModalGen = () => return ( -
    +
    @@ -94,10 +90,10 @@ function Users({ location, dispatch, users }) { Users.propTypes = { users: PropTypes.object, location: PropTypes.object, - dispatch: PropTypes.func, + dispatch: PropTypes.func } -function mapStateToProps({ users }) { +function mapStateToProps ({ users }) { return { users } } diff --git a/src/services/app.js b/src/services/app.js index 71b562e..e062075 100644 --- a/src/services/app.js +++ b/src/services/app.js @@ -1,23 +1,22 @@ import { request } from '../utils' -import qs from 'qs' -export async function login(params) { +export async function login (params) { return request('/api/login', { method: 'post', - data:params, + data: params }) } -export async function logout(params) { +export async function logout (params) { return request('/api/logout', { method: 'post', - data:params, + data: params }) } -export async function userInfo(params) { +export async function userInfo (params) { return request('/api/userInfo', { method: 'get', - data:params, + data: params }) } diff --git a/src/services/dashboard.js b/src/services/dashboard.js index ccec99d..ac549be 100644 --- a/src/services/dashboard.js +++ b/src/services/dashboard.js @@ -1,25 +1,24 @@ import { request } from '../utils' -import qs from 'qs' -export async function myCity(params) { +export async function myCity (params) { return request('http://www.zuimeitianqi.com/zuimei/myCity', { method: 'get', - cross:true, - data:params, + cross: true, + data: params }) } -export async function queryWeather(params) { +export async function queryWeather (params) { return request('http://www.zuimeitianqi.com/zuimei/queryWeather', { method: 'get', - cross:true, - data:params, + cross: true, + data: params }) } -export async function query(params) { +export async function query (params) { return request('/api/dashboard', { method: 'get', - data:params, + data: params }) } diff --git a/src/services/users.js b/src/services/users.js index 0710ed4..e10e1ba 100644 --- a/src/services/users.js +++ b/src/services/users.js @@ -1,30 +1,29 @@ import { request } from '../utils' -import qs from 'qs' -export async function query(params) { +export async function query (params) { return request('/api/users', { method: 'get', - data:params, + data: params }) } -export async function create(params) { +export async function create (params) { return request('/api/users', { method: 'post', - data:params, + data: params }) } -export async function remove(params) { +export async function remove (params) { return request('/api/users', { method: 'delete', - data:params, + data: params }) } -export async function update(params) { +export async function update (params) { return request('/api/users', { method: 'put', - data: params, + data: params }) } diff --git a/src/tests/models/example-test.js b/src/tests/models/example-test.js index 3b8bd44..8b13789 100644 --- a/src/tests/models/example-test.js +++ b/src/tests/models/example-test.js @@ -1,11 +1 @@ -import expect from 'expect'; -import example from '../../models/example'; -describe('example', () => { - - describe('reducer', () => { - it('it should save', () => { - expect(example.reducers['example/save']({}, { payload: { a: 1 }})).toEqual({ a: 1 }); - }); - }) -}); diff --git a/src/theme.js b/src/theme.js index db598f0..d0666d7 100644 --- a/src/theme.js +++ b/src/theme.js @@ -4,8 +4,8 @@ module.exports = () => { '@border-radius-sm': '2px', '@shadow-color': 'rgba(0,0,0,0.05)', '@shadow-1-down': '4px 4px 40px @shadow-color', - '@border-color-split':'#f4f4f4', - '@border-color-base':'#e5e5e5', - '@font-family':'monospace,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif' - }; -}; + '@border-color-split': '#f4f4f4', + '@border-color-base': '#e5e5e5', + '@font-family': 'monospace,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif' + } +} diff --git a/src/utils/config.js b/src/utils/config.js index 9e4ae52..6a71518 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -1,8 +1,8 @@ module.exports = { name: 'Ant Design Admin', - prefix:'antdAdmin', + prefix: 'antdAdmin', footerText: 'Ant Design Admin 版权所有 © 2016 由 zuiidea 支持', - logoSrc:'https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg', - logoText:'Antd Admin', - needLogin:true, -}; + logoSrc: 'https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg', + logoText: 'Antd Admin', + needLogin: true +} diff --git a/src/utils/index.js b/src/utils/index.js index a1713a4..ef1ec8c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -15,28 +15,29 @@ String.prototype.hyphenToHump = function () { // 驼峰转连字符 String.prototype.humpToHyphen = function () { - return this.replace(/([A-Z])/g, "-$1").toLowerCase() + return this.replace(/([A-Z])/g, '-$1').toLowerCase() } // 日期格式化 Date.prototype.format = function (format) { var o = { - "M+": this.getMonth() + 1, - "d+": this.getDate(), - "h+": this.getHours(), + 'M+': this.getMonth() + 1, + 'd+': this.getDate(), + 'h+': this.getHours(), 'H+': this.getHours(), - "m+": this.getMinutes(), - "s+": this.getSeconds(), - "q+": Math.floor((this.getMonth() + 3) / 3), - "S": this.getMilliseconds() + 'm+': this.getMinutes(), + 's+': this.getSeconds(), + 'q+': Math.floor((this.getMonth() + 3) / 3), + 'S': this.getMilliseconds() } - if (/(y+)/.test(format)) - format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)) - for (var k in o) - if (new RegExp("(" + k + ")").test(format)) - format = format.replace(RegExp.$1, RegExp.$1.length == 1 + if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) } + for (var k in o) { + if (new RegExp('(' + k + ')').test(format)) { + format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] - : ("00" + o[k]).substr(("" + o[k]).length)) + : ('00' + o[k]).substr(('' + o[k]).length)) + } + } return format } diff --git a/src/utils/menu.js b/src/utils/menu.js index b15fef5..28b5787 100644 --- a/src/utils/menu.js +++ b/src/utils/menu.js @@ -7,18 +7,18 @@ module.exports = [ { key: 'users', name: '用户管理', - icon: 'user', + icon: 'user' }, { key: 'ui', name: 'UI组件', icon: 'camera-o', - clickable:false, - child:[ + clickable: false, + child: [ { key: 'ico', - name: '业务图标', - }, + name: '业务图标' + } ] }, { @@ -28,7 +28,7 @@ module.exports = [ child: [ { key: 'navigation1', - name: '二级导航1', + name: '二级导航1' }, { key: 'navigation2', @@ -36,14 +36,14 @@ module.exports = [ child: [ { key: 'navigation21', - name: '三级导航1', + name: '三级导航1' }, { key: 'navigation22', - name: '三级导航2', - }, - ], - }, - ], - }, -]; + name: '三级导航2' + } + ] + } + ] + } +] diff --git a/src/utils/mock.js b/src/utils/mock.js index abfddd1..621ce71 100644 --- a/src/utils/mock.js +++ b/src/utils/mock.js @@ -1,22 +1,22 @@ const Mock = require('mockjs') -const mockData = [require("../../mock/users"), require("../../mock/app"), require("../../mock/dashboard")] +const mockData = [require('../../mock/users'), require('../../mock/app'), require('../../mock/dashboard')] -function serialize(str) { - let paramArray = str.split("&") +function serialize (str) { + let paramArray = str.split('&') let query = {} for (let i in paramArray) { - query[paramArray[i].split("=")[0]] = paramArray[i].split("=")[1] + query[paramArray[i].split('=')[0]] = paramArray[i].split('=')[1] } return query } for (let i in mockData) { for (let key in mockData[i]) { - Mock.mock(eval("/" + key.split(" ")[1].replace(/\//g, "\\\/") + "/"), key.split(" ")[0].toLowerCase(), function (options) { - if (key.split(" ")[0].toLowerCase() == 'get') { - options.query = !!options.url.split("?")[1] - ? serialize(options.url.split("?")[1]) - : (!!options.body + Mock.mock(eval('/' + key.split(' ')[1].replace(/\//g, '\\\/') + '/'), key.split(' ')[0].toLowerCase(), function (options) { + if (key.split(' ')[0].toLowerCase() == 'get') { + options.query = options.url.split('?')[1] + ? serialize(options.url.split('?')[1]) + : (options.body ? serialize(options.body) : {}) } diff --git a/src/utils/mockStorge.js b/src/utils/mockStorge.js index edd7d5a..c4a8487 100644 --- a/src/utils/mockStorge.js +++ b/src/utils/mockStorge.js @@ -1,8 +1,7 @@ -const Mock = require('mockjs') -const Watch = require("watchjs") +const Watch = require('watchjs') import config from './config' -export default function mockStorge(name, defaultValue) { +export default function mockStorge (name, defaultValue) { let key = config.prefix + name global[key] = localStorage.getItem(key) ? JSON.parse(localStorage.getItem(key)) diff --git a/src/utils/request.js b/src/utils/request.js index b44dec9..279b9f7 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,4 +1,4 @@ -const Ajax = require("robe-ajax") +const Ajax = require('robe-ajax') /** * Requests a URL, returning a promise. @@ -7,20 +7,18 @@ const Ajax = require("robe-ajax") * @param {object} [options] The options we want to pass to "fetch" * @return {object} An object containing either "data" or "err" */ -export default function request(url, options) { +export default function request (url, options) { if (options.cross) { - return Ajax.getJSON("http://query.yahooapis.com/v1/public/yql", { - q: "select * from json where url=\'"+url+"?"+Ajax.param(options.data)+"\'", - format: "json" + return Ajax.getJSON('http://query.yahooapis.com/v1/public/yql', { + q: "select * from json where url='" + url + '?' + Ajax.param(options.data) + "'", + format: 'json' }) } else { return Ajax.ajax({ url: url, method: options.method || 'get', data: options.data || {}, - processData: options.method == 'get' - ? true - : false, + processData: options.method === 'get', dataType: 'JSON' }).done((data) => { return data diff --git a/src/utils/theme.js b/src/utils/theme.js index 06d2035..85ed8b4 100644 --- a/src/utils/theme.js +++ b/src/utils/theme.js @@ -1,14 +1,14 @@ module.exports = { - color:{ - green:'#64ea91', - blue:'#8fc9fb', - purple:'#d897eb', - red:'#f69899', - yellow:'#f8c82e', - peach:'#f797d6', - borderBase:'#e5e5e5', - borderSplit:'#f4f4f4', - grass:"#d6fbb5", - sky:'#c1e0fc' + color: { + green: '#64ea91', + blue: '#8fc9fb', + purple: '#d897eb', + red: '#f69899', + yellow: '#f8c82e', + peach: '#f797d6', + borderBase: '#e5e5e5', + borderSplit: '#f4f4f4', + grass: '#d6fbb5', + sky: '#c1e0fc' } -}; +} diff --git a/webpack.config.js b/webpack.config.js index 9c6031b..8538f38 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,12 +1,10 @@ -const fs = require('fs') -const path = require('path') const webpack = require('atool-build/lib/webpack') -module.exports = function(webpackConfig, env) { +module.exports = function (webpackConfig, env) { webpackConfig.babel.plugins.push('transform-runtime') webpackConfig.babel.plugins.push(['import', { libraryName: 'antd', - style: true, + style: true }]) // Support hmr @@ -14,21 +12,21 @@ module.exports = function(webpackConfig, env) { webpackConfig.devtool = '#eval' webpackConfig.babel.plugins.push(['dva-hmr', { entries: [ - './src/index.js', - ], + './src/index.js' + ] }]) } else { webpackConfig.babel.plugins.push('dev-expression') } // Don't extract common.js and common.css - webpackConfig.plugins = webpackConfig.plugins.filter(function(plugin) { - return !(plugin instanceof webpack.optimize.CommonsChunkPlugin); + webpackConfig.plugins = webpackConfig.plugins.filter(function (plugin) { + return !(plugin instanceof webpack.optimize.CommonsChunkPlugin) }) // Support CSS Modules // Parse all less files as css module. - webpackConfig.module.loaders.forEach(function(loader, index) { + webpackConfig.module.loaders.forEach(function (loader, index) { if (typeof loader.test === 'function' && loader.test.toString().indexOf('\\.less$') > -1) { loader.include = /node_modules/ loader.test = /\.less$/