mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
addGroup
This commit is contained in:
parent
61b493a820
commit
c2b317442c
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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 (
|
||||
<Card title="Groups">
|
||||
<Button type="primary" onClick={this.addGroup}>添加分组</Button>
|
||||
<div>{currGroup}</div>
|
||||
{
|
||||
groupList.map((group, index) => (
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user