From 3cf719074503596e8c4e769822513387f8ea7abf Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 11:39:06 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AD=E9=97=B4?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/index.js | 12 ++++++++++-- package.json | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/index.js b/client/index.js index 5ab5a319..95d19a3c 100644 --- a/client/index.js +++ b/client/index.js @@ -1,13 +1,21 @@ import React from 'react' import 'babel-polyfill' +import thunkMiddleware from 'redux-thunk' +import promiseMiddleware from 'redux-promise'; import ReactDOM from 'react-dom' import App from './App' -import { createStore, combineReducers } from 'redux' +import { createStore, combineReducers, applyMiddleware } from 'redux' import { Provider } from 'react-redux' import ReduxContainer from './ReduxContainer.js' +console.log('thunkMiddleware', thunkMiddleware) +console.log('promiseMiddleware', promiseMiddleware) + // 合并 redux 创建stroe -const store = createStore(combineReducers( ReduxContainer )) +const store = createStore(combineReducers( ReduxContainer ), applyMiddleware( + thunkMiddleware.default, + promiseMiddleware +)) ReactDOM.render( diff --git a/package.json b/package.json index 11bd3ebb..3c94b991 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,9 @@ "mongoose-auto-increment": "^5.0.1", "node-sass-china": "^4.5.0", "prop-types": "^15.5.10", - "sha1": "^1.1.1", "redux": "^3.7.1", + "redux-promise": "^0.5.3", + "redux-thunk": "^2.2.0", "sha1": "^1.1.1", "ykit-config-antd": "^0.1.3", "ykit-config-react": "^0.4.4" From c774df54d28de581ea3611e2fd4cf94612fe9f53 Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 11:43:04 +0800 Subject: [PATCH 02/14] none --- client/components/GroupList/GroupList.js | 47 ------------------- client/components/GroupList/GroupList.scss | 0 .../containers/ProjectGroups/ProjectGroups.js | 2 +- 3 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 client/components/GroupList/GroupList.js delete mode 100644 client/components/GroupList/GroupList.scss diff --git a/client/components/GroupList/GroupList.js b/client/components/GroupList/GroupList.js deleted file mode 100644 index 64256b3f..00000000 --- a/client/components/GroupList/GroupList.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' -import { connect } from 'react-redux' -import { Card } from 'antd' - -import { - fetchGroupList, - fetchCurrGroup -} from '../../actions/group.js' - -import './GroupList.scss' - -@connect( - state => ({ - groupList: state.group.groupList, - currGroup: state.group.currGroup, - }), - { - fetchGroupList, - fetchCurrGroup - } -) -export default class GroupList extends Component { - constructor(props) { - super(props) - } - - static propTypes = { - groupList: PropTypes.array, - currGroup: PropTypes.string - } - - render () { - const { groupList, currGroup } = this.props; - - return ( - -
{currGroup}
- { - groupList.map((group, index) => ( -
{group}
- )) - } -
- ) - } -} diff --git a/client/components/GroupList/GroupList.scss b/client/components/GroupList/GroupList.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/client/containers/ProjectGroups/ProjectGroups.js b/client/containers/ProjectGroups/ProjectGroups.js index 3bfcd857..196d408c 100644 --- a/client/containers/ProjectGroups/ProjectGroups.js +++ b/client/containers/ProjectGroups/ProjectGroups.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import GroupList from '../../components/GroupList/GroupList.js'; +import GroupList from './GroupList/GroupList.js'; import ProjectList from './ProjectList'; import { Row, Col } from 'antd'; From 403d6eb552a83ab4aa8e8902eb1a590a1e5a34fa Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 11:43:10 +0800 Subject: [PATCH 03/14] none --- .../ProjectGroups/GroupList/GroupList.js | 47 +++++++++++++++++++ .../ProjectGroups/GroupList/GroupList.scss | 0 2 files changed, 47 insertions(+) create mode 100644 client/containers/ProjectGroups/GroupList/GroupList.js create mode 100644 client/containers/ProjectGroups/GroupList/GroupList.scss diff --git a/client/containers/ProjectGroups/GroupList/GroupList.js b/client/containers/ProjectGroups/GroupList/GroupList.js new file mode 100644 index 00000000..3a99273c --- /dev/null +++ b/client/containers/ProjectGroups/GroupList/GroupList.js @@ -0,0 +1,47 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import { connect } from 'react-redux' +import { Card } from 'antd' + +import { + fetchGroupList, + fetchCurrGroup +} from '../../../actions/group.js' + +import './GroupList.scss' + +@connect( + state => ({ + groupList: state.group.groupList, + currGroup: state.group.currGroup, + }), + { + fetchGroupList, + fetchCurrGroup + } +) +export default class GroupList extends Component { + constructor(props) { + super(props) + } + + static propTypes = { + groupList: PropTypes.array, + currGroup: PropTypes.string + } + + render () { + const { groupList, currGroup } = this.props; + + return ( + +
{currGroup}
+ { + groupList.map((group, index) => ( +
{group}
+ )) + } +
+ ) + } +} diff --git a/client/containers/ProjectGroups/GroupList/GroupList.scss b/client/containers/ProjectGroups/GroupList/GroupList.scss new file mode 100644 index 00000000..e69de29b From 9b1c7b55f133388372a54061a2234445d713bdfb Mon Sep 17 00:00:00 2001 From: "waliang.wang" Date: Wed, 12 Jul 2017 11:48:11 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=95=B4=E7=90=86=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/actionTypes.js | 6 ------ client/constants/action-types.js | 3 +++ client/reducer/interface/interface.js | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 client/actionTypes.js diff --git a/client/actionTypes.js b/client/actionTypes.js deleted file mode 100644 index fb51f5b1..00000000 --- a/client/actionTypes.js +++ /dev/null @@ -1,6 +0,0 @@ -// Interface -export const FETCH_INTERFACE_DATA = 'FETCH_INTERFACE_DATA'; - -// Home -export const FETCH_HOME_DATA = 'FETCH_INTERFACE_DATA'; - diff --git a/client/constants/action-types.js b/client/constants/action-types.js index 80686d1f..82b5022f 100644 --- a/client/constants/action-types.js +++ b/client/constants/action-types.js @@ -1,3 +1,6 @@ +// Interface +export const FETCH_INTERFACE_DATA = 'FETCH_INTERFACE_DATA'; + // group export const FETCH_GROUP_LIST = 'FETCH_GROUP_LIST' export const FETCH_CURR_GROUP = 'FETCH_CURR_GROUP' diff --git a/client/reducer/interface/interface.js b/client/reducer/interface/interface.js index 699736ca..89b3aed7 100644 --- a/client/reducer/interface/interface.js +++ b/client/reducer/interface/interface.js @@ -1,6 +1,6 @@ import { FETCH_INTERFACE_DATA, -} from '../../actionTypes.js' +} from '../../constants/action-types.js' export default (state = 3333, action) => { switch (action.type) { From a1452485591036dd26875f43d8967d909517913d Mon Sep 17 00:00:00 2001 From: "waliang.wang" Date: Wed, 12 Jul 2017 11:57:28 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BC=98=E5=8C=96reduce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/ReduxContainer.js | 2 +- client/actions/interface.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ReduxContainer.js b/client/ReduxContainer.js index 6b1347ef..afdd53f2 100644 --- a/client/ReduxContainer.js +++ b/client/ReduxContainer.js @@ -1,6 +1,6 @@ import LoginRedux from './reducer/Login/Login_redux.js' import group from './reducer/group/group.js' -import Interface from './reducer/interface/interface.js' +import Interface from './reducer/Interface/Interface.js' export default { group, diff --git a/client/actions/interface.js b/client/actions/interface.js index 91feefd3..def0a95f 100644 --- a/client/actions/interface.js +++ b/client/actions/interface.js @@ -1,6 +1,6 @@ import { FETCH_INTERFACE_DATA, -} from '../actionTypes.js'; +} from '../constants/action-types.js'; export function fetchAuditIcons () { const data = [{ From 1328738e58317fcabc85f42de3ab449c4e91face Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 12:00:49 +0800 Subject: [PATCH 06/14] add axios --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ddf2e6ba..e4c1c3ca 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "license": "ISC", "dependencies": { "@qnpm/ykit-config-qunar": "^0.8.1", + "axios": "^0.16.2", "babel-plugin-transform-decorators-legacy": "^1.3.4", "fs-extra": "^3.0.1", "jsonwebtoken": "^7.4.1", From 81bbbc22e62608f307c7a7c1ea6668a29b946b08 Mon Sep 17 00:00:00 2001 From: "waliang.wang" Date: Wed, 12 Jul 2017 12:17:27 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/containers/Interface/Interface.scss | 1 + client/containers/Interface/InterfaceTable/InterfaceTable.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/containers/Interface/Interface.scss b/client/containers/Interface/Interface.scss index 9df8129c..765e24b4 100644 --- a/client/containers/Interface/Interface.scss +++ b/client/containers/Interface/Interface.scss @@ -5,6 +5,7 @@ -webkit-box-flex: 1; margin: 15px auto 0 auto; font-size: 0.14rem; + background: #FFF; .interface-list { width: 216px; diff --git a/client/containers/Interface/InterfaceTable/InterfaceTable.js b/client/containers/Interface/InterfaceTable/InterfaceTable.js index 887b8f58..3664bdbe 100644 --- a/client/containers/Interface/InterfaceTable/InterfaceTable.js +++ b/client/containers/Interface/InterfaceTable/InterfaceTable.js @@ -34,8 +34,8 @@ class InterfaceTable extends Component { render: () => { return ( - - + + ) } From 53cfb4d606c5170e8eb50ac8deaf7abb3799a02c Mon Sep 17 00:00:00 2001 From: "waliang.wang" Date: Wed, 12 Jul 2017 12:20:01 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/containers/Interface/Interface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/containers/Interface/Interface.js b/client/containers/Interface/Interface.js index e7ac78d6..dc32b1d3 100644 --- a/client/containers/Interface/Interface.js +++ b/client/containers/Interface/Interface.js @@ -16,7 +16,7 @@ import { fetchAuditIcons } from '../../actions/interface.js' fetchAuditIcons, } ) - +// class Interface extends Component { static propTypes = { fetchAuditIcons: PropTypes.func, From 52a930108777d1255d502dd8a437a4df3804680a Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Wed, 12 Jul 2017 12:22:10 +0800 Subject: [PATCH 09/14] yapi add help info --- server/controllers/user.js | 6 +++--- server/router.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/controllers/user.js b/server/controllers/user.js index 165b295f..dfbf2ce3 100644 --- a/server/controllers/user.js +++ b/server/controllers/user.js @@ -158,8 +158,8 @@ class userController extends baseController{ } /** - * 获取用户列表 - * @interface /user/list + * 根据用户个人信息 + * @interface /user/find * @method GET * @param id 用户uid * @category user @@ -183,7 +183,7 @@ class userController extends baseController{ } /** - * 获取用户列表,只有admin用户才有此权限 + * 删除用户,只有admin用户才有此权限 * @interface /user/del * @method POST * @param id 用户uid diff --git a/server/router.js b/server/router.js index 7f9a58e8..c2330bb1 100644 --- a/server/router.js +++ b/server/router.js @@ -38,7 +38,7 @@ createAction('group', 'del', 'post', 'del') createAction('user', 'login', 'post', 'login') createAction('user', 'reg', 'post', 'reg') createAction('user', 'list', 'get', 'list') -createAction('user', 'findById', 'post', 'findById') +createAction('user', 'find', 'post', 'findById') createAction('user', 'update', 'post', 'update') createAction('user', 'del', 'post', 'del') createAction('user', 'status', 'get', 'getLoginStatus') From e16d5a4dc928ef001bd908be8e776a6ab0598b0f Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Wed, 12 Jul 2017 12:23:40 +0800 Subject: [PATCH 10/14] add some example code --- exampleCode/api/interface/del.json | 8 ++++++++ exampleCode/api/interface/up.json | 9 +++++++++ exampleCode/api/user/del.json | 8 ++++++++ exampleCode/api/user/logout.json | 5 +++++ exampleCode/api/user/reg.json | 11 +++++++++++ exampleCode/api/user/up.json | 9 +++++++++ 6 files changed, 50 insertions(+) create mode 100644 exampleCode/api/interface/del.json create mode 100644 exampleCode/api/interface/up.json create mode 100644 exampleCode/api/user/del.json create mode 100644 exampleCode/api/user/logout.json create mode 100644 exampleCode/api/user/reg.json create mode 100644 exampleCode/api/user/up.json diff --git a/exampleCode/api/interface/del.json b/exampleCode/api/interface/del.json new file mode 100644 index 00000000..de81d507 --- /dev/null +++ b/exampleCode/api/interface/del.json @@ -0,0 +1,8 @@ +{ + "errcode": 0, + "errmsg": "success", + "data": { + "n": 1, + "ok": 1 + } +} \ No newline at end of file diff --git a/exampleCode/api/interface/up.json b/exampleCode/api/interface/up.json new file mode 100644 index 00000000..7d107e7e --- /dev/null +++ b/exampleCode/api/interface/up.json @@ -0,0 +1,9 @@ +{ + "errcode": 0, + "errmsg": "success", + "data": { + "n": 1, + "nModified": 1, + "ok": 1 + } +} \ No newline at end of file diff --git a/exampleCode/api/user/del.json b/exampleCode/api/user/del.json new file mode 100644 index 00000000..de81d507 --- /dev/null +++ b/exampleCode/api/user/del.json @@ -0,0 +1,8 @@ +{ + "errcode": 0, + "errmsg": "success", + "data": { + "n": 1, + "ok": 1 + } +} \ No newline at end of file diff --git a/exampleCode/api/user/logout.json b/exampleCode/api/user/logout.json new file mode 100644 index 00000000..8071380a --- /dev/null +++ b/exampleCode/api/user/logout.json @@ -0,0 +1,5 @@ +{ + "errcode": 0, + "errmsg": "success", + "data": "ok" +} \ No newline at end of file diff --git a/exampleCode/api/user/reg.json b/exampleCode/api/user/reg.json new file mode 100644 index 00000000..2644a390 --- /dev/null +++ b/exampleCode/api/user/reg.json @@ -0,0 +1,11 @@ +{ + "errcode": 0, + "errmsg": "success", + "data": { + "uid": 139, + "email": "18500803805@163.com", + "add_time": 1499768413, + "up_time": 1499768413, + "role": "member" + } +} \ No newline at end of file diff --git a/exampleCode/api/user/up.json b/exampleCode/api/user/up.json new file mode 100644 index 00000000..7d107e7e --- /dev/null +++ b/exampleCode/api/user/up.json @@ -0,0 +1,9 @@ +{ + "errcode": 0, + "errmsg": "success", + "data": { + "n": 1, + "nModified": 1, + "ok": 1 + } +} \ No newline at end of file From 38795ee1bd42402e0df48e64d323b8128ade76a1 Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 14:04:06 +0800 Subject: [PATCH 11/14] import eslint --- client/.eslintrc.js | 6 ++++-- client/ReduxContainer.js | 2 +- package.json | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/.eslintrc.js b/client/.eslintrc.js index 59086263..916ce412 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -11,13 +11,15 @@ module.exports = { } }, plugins: [ - "react" + "react", + "import" ], rules: { "indent": ["error", 2, { "SwitchCase": 1 }], "react/display-name": ["off"], "react/jsx-indent": ["error", 2], "comma-dangle": ["error", "only-multiline"], - "no-console": ["off"] + "no-console": ["off"], + "import/no-unresolved": ["error"] } } diff --git a/client/ReduxContainer.js b/client/ReduxContainer.js index afdd53f2..041671b1 100644 --- a/client/ReduxContainer.js +++ b/client/ReduxContainer.js @@ -5,5 +5,5 @@ import Interface from './reducer/Interface/Interface.js' export default { group, LoginRedux, - Interface, + Interface } diff --git a/package.json b/package.json index e4c1c3ca..b470e5a6 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "buffer-shims": "^1.0.0", "css-loader": "^0.28.4", "eslint": "^3.19.0", + "eslint-plugin-import": "^2.2.0", "eslint-plugin-react": "^7.1.0", "express": "^4.15.3", "extract-text-webpack-plugin": "^1.0.1", From 8a29916edb01842e897bd1d861385071fcdbce32 Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 14:06:29 +0800 Subject: [PATCH 12/14] name --- client/ReduxContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ReduxContainer.js b/client/ReduxContainer.js index 041671b1..b4aa33f9 100644 --- a/client/ReduxContainer.js +++ b/client/ReduxContainer.js @@ -1,6 +1,6 @@ import LoginRedux from './reducer/Login/Login_redux.js' import group from './reducer/group/group.js' -import Interface from './reducer/Interface/Interface.js' +import Interface from './reducer/interface/interface.js' export default { group, From 61b493a82096d2090cf12ac716618fb552462178 Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 14:18:17 +0800 Subject: [PATCH 13/14] sonar --- client/.eslintrc.js | 2 +- client/actions/interface.js | 12 ++++++------ client/base.js | 5 ++--- client/containers/Interface/Interface.js | 8 ++++---- .../Interface/InterfaceTable/InterfaceTable.js | 12 ++++++------ client/containers/Login/Login.js | 4 ++-- .../containers/ProjectGroups/GroupList/GroupList.js | 2 +- client/containers/ProjectGroups/ProjectList/index.js | 6 +++--- client/containers/index.js | 2 +- client/reducer/group/group.js | 4 ++-- client/reducer/interface/interface.js | 4 ++-- 11 files changed, 30 insertions(+), 31 deletions(-) diff --git a/client/.eslintrc.js b/client/.eslintrc.js index 916ce412..54981c66 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -18,7 +18,7 @@ module.exports = { "indent": ["error", 2, { "SwitchCase": 1 }], "react/display-name": ["off"], "react/jsx-indent": ["error", 2], - "comma-dangle": ["error", "only-multiline"], + "comma-dangle": ["error", "never"], "no-console": ["off"], "import/no-unresolved": ["error"] } diff --git a/client/actions/interface.js b/client/actions/interface.js index def0a95f..a251066b 100644 --- a/client/actions/interface.js +++ b/client/actions/interface.js @@ -1,5 +1,5 @@ import { - FETCH_INTERFACE_DATA, + FETCH_INTERFACE_DATA } from '../constants/action-types.js'; export function fetchAuditIcons () { @@ -9,25 +9,25 @@ export function fetchAuditIcons () { age: 32, address: 'New York No. 1 Lake Park', date: '2015-11-11 13:00:15', - features: '3', + features: '3' }, { key: '2', name: 'Jim Green', age: 42, address: 'London No. 1 Lake Park', date: '2015-11-11 13:00:15', - features: '3', + features: '3' }, { key: '3', name: 'Joe Black', age: 32, address: 'Sidney No. 1 Lake Park', date: '2015-11-11 13:00:15', - features: '3', + features: '3' }] return { type: FETCH_INTERFACE_DATA, - payload: data, + payload: data }; -} \ No newline at end of file +} diff --git a/client/base.js b/client/base.js index 683422d4..82be8d72 100644 --- a/client/base.js +++ b/client/base.js @@ -1,7 +1,6 @@ -import './styles/Home/home.scss' import React, { Component } from 'react' export { React, - Component, -} \ No newline at end of file + Component +} diff --git a/client/containers/Interface/Interface.js b/client/containers/Interface/Interface.js index dc32b1d3..71925bc1 100644 --- a/client/containers/Interface/Interface.js +++ b/client/containers/Interface/Interface.js @@ -9,17 +9,17 @@ import { fetchAuditIcons } from '../../actions/interface.js' @connect( state => { return { - interfaceData: state.data, + interfaceData: state.data } }, { - fetchAuditIcons, + fetchAuditIcons } ) // class Interface extends Component { static propTypes = { - fetchAuditIcons: PropTypes.func, + fetchAuditIcons: PropTypes.func } constructor(props) { @@ -42,4 +42,4 @@ class Interface extends Component { } } -export default Interface \ No newline at end of file +export default Interface diff --git a/client/containers/Interface/InterfaceTable/InterfaceTable.js b/client/containers/Interface/InterfaceTable/InterfaceTable.js index 3664bdbe..d37262d6 100644 --- a/client/containers/Interface/InterfaceTable/InterfaceTable.js +++ b/client/containers/Interface/InterfaceTable/InterfaceTable.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types' class InterfaceTable extends Component { static propTypes = { - data: PropTypes.array, + data: PropTypes.array } constructor(props) { @@ -15,19 +15,19 @@ class InterfaceTable extends Component { const columns = [{ title: '接口名称', dataIndex: 'name', - key: 'name', + key: 'name' }, { title: '接口URL', dataIndex: 'age', - key: 'age', + key: 'age' }, { title: '操作者', dataIndex: 'address', - key: 'address', + key: 'address' }, { title: '更新日期', dataIndex: 'date', - key: 'date', + key: 'date' }, { title: '功能', 'key': 'action', @@ -52,4 +52,4 @@ class InterfaceTable extends Component { } } -export default InterfaceTable \ No newline at end of file +export default InterfaceTable diff --git a/client/containers/Login/Login.js b/client/containers/Login/Login.js index a1eaa0b2..cfde71f5 100644 --- a/client/containers/Login/Login.js +++ b/client/containers/Login/Login.js @@ -7,12 +7,12 @@ const FormItem = Form.Item; @connect( () => ({ - per: '测试数据', + per: '测试数据' }) ) class Login extends Component { static propTypes = { - form: PropTypes.object, + form: PropTypes.object } handleSubmit = (e) => { diff --git a/client/containers/ProjectGroups/GroupList/GroupList.js b/client/containers/ProjectGroups/GroupList/GroupList.js index 3a99273c..72381863 100644 --- a/client/containers/ProjectGroups/GroupList/GroupList.js +++ b/client/containers/ProjectGroups/GroupList/GroupList.js @@ -13,7 +13,7 @@ import './GroupList.scss' @connect( state => ({ groupList: state.group.groupList, - currGroup: state.group.currGroup, + currGroup: state.group.currGroup }), { fetchGroupList, diff --git a/client/containers/ProjectGroups/ProjectList/index.js b/client/containers/ProjectGroups/ProjectList/index.js index 594916a6..e7446659 100644 --- a/client/containers/ProjectGroups/ProjectList/index.js +++ b/client/containers/ProjectGroups/ProjectList/index.js @@ -7,11 +7,11 @@ const columns = [{ title: 'Name', dataIndex: 'name', key: 'name', - render: text => {text}, + render: text => {text} }, { title: 'Age', dataIndex: 'age', - key: 'age', + key: 'age' }, { title: 'Action', key: 'action', @@ -21,7 +21,7 @@ const columns = [{ 删除 - ), + ) }]; const data = [{ diff --git a/client/containers/index.js b/client/containers/index.js index f02ebae6..01e7b008 100644 --- a/client/containers/index.js +++ b/client/containers/index.js @@ -7,5 +7,5 @@ export { Home, Login, ProjectGroups, - Interface, + Interface } diff --git a/client/reducer/group/group.js b/client/reducer/group/group.js index aec7d2a9..6bc5f76c 100644 --- a/client/reducer/group/group.js +++ b/client/reducer/group/group.js @@ -14,7 +14,7 @@ export default (state = initialState, action) => { if (action.payload.res) { return { ...state, - groupList: action.payload.data, + groupList: action.payload.data }; } return state; @@ -23,7 +23,7 @@ export default (state = initialState, action) => { if (action.payload.res) { return { ...state, - currGroup: action.payload.data, + currGroup: action.payload.data }; } return state; diff --git a/client/reducer/interface/interface.js b/client/reducer/interface/interface.js index 89b3aed7..30ea3c96 100644 --- a/client/reducer/interface/interface.js +++ b/client/reducer/interface/interface.js @@ -1,5 +1,5 @@ import { - FETCH_INTERFACE_DATA, + FETCH_INTERFACE_DATA } from '../../constants/action-types.js' export default (state = 3333, action) => { @@ -7,7 +7,7 @@ export default (state = 3333, action) => { case FETCH_INTERFACE_DATA: { return { ...state, - icons: action.payload.data, + icons: action.payload.data }; } default: From c2b317442cc5df44802dd432625fb6fde39a01cb Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Wed, 12 Jul 2017 15:41:11 +0800 Subject: [PATCH 14/14] addGroup --- client/actions/group.js | 15 +++++++++++++++ .../ProjectGroups/GroupList/GroupList.js | 18 ++++++++++++++---- client/index.js | 3 --- package.json | 1 + 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/client/actions/group.js b/client/actions/group.js index 9cd7ab9b..34bf4121 100644 --- a/client/actions/group.js +++ b/client/actions/group.js @@ -20,3 +20,18 @@ export function fetchCurrGroup() { } } } + +export function addGroup(groupName) { + return function(dispatch, getState) { + const group = getState().group; + const groupList = group.groupList || []; + const newGroupList = groupList.concat([groupName + groupList.length]); + dispatch({ + type: FETCH_GROUP_LIST, + payload: { + data: newGroupList, + res: true + } + }); + } +} diff --git a/client/containers/ProjectGroups/GroupList/GroupList.js b/client/containers/ProjectGroups/GroupList/GroupList.js index 72381863..804842a3 100644 --- a/client/containers/ProjectGroups/GroupList/GroupList.js +++ b/client/containers/ProjectGroups/GroupList/GroupList.js @@ -1,11 +1,13 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' -import { Card } from 'antd' +import { Card, Button } from 'antd' +import { autobind } from 'core-decorators'; import { fetchGroupList, - fetchCurrGroup + fetchCurrGroup, + addGroup } from '../../../actions/group.js' import './GroupList.scss' @@ -17,7 +19,8 @@ import './GroupList.scss' }), { fetchGroupList, - fetchCurrGroup + fetchCurrGroup, + addGroup } ) export default class GroupList extends Component { @@ -27,7 +30,13 @@ export default class GroupList extends Component { static propTypes = { groupList: PropTypes.array, - currGroup: PropTypes.string + currGroup: PropTypes.string, + addGroup: PropTypes.func + } + + @autobind + addGroup() { + this.props.addGroup('group'); } render () { @@ -35,6 +44,7 @@ export default class GroupList extends Component { return ( +
{currGroup}
{ groupList.map((group, index) => ( diff --git a/client/index.js b/client/index.js index 95d19a3c..577cb6e7 100644 --- a/client/index.js +++ b/client/index.js @@ -8,9 +8,6 @@ import { createStore, combineReducers, applyMiddleware } from 'redux' import { Provider } from 'react-redux' import ReduxContainer from './ReduxContainer.js' -console.log('thunkMiddleware', thunkMiddleware) -console.log('promiseMiddleware', promiseMiddleware) - // 合并 redux 创建stroe const store = createStore(combineReducers( ReduxContainer ), applyMiddleware( thunkMiddleware.default, diff --git a/package.json b/package.json index b470e5a6..a4e18e8e 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@qnpm/ykit-config-qunar": "^0.8.1", "axios": "^0.16.2", "babel-plugin-transform-decorators-legacy": "^1.3.4", + "core-decorators": "^0.17.0", "fs-extra": "^3.0.1", "jsonwebtoken": "^7.4.1", "koa": "^2.0.0",