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 React, { Component } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { Card } from 'antd'
|
import { Card, Button } from 'antd'
|
||||||
|
import { autobind } from 'core-decorators';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
fetchGroupList,
|
fetchGroupList,
|
||||||
fetchCurrGroup
|
fetchCurrGroup,
|
||||||
|
addGroup
|
||||||
} from '../../../actions/group.js'
|
} from '../../../actions/group.js'
|
||||||
|
|
||||||
import './GroupList.scss'
|
import './GroupList.scss'
|
||||||
@ -17,7 +19,8 @@ import './GroupList.scss'
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
fetchGroupList,
|
fetchGroupList,
|
||||||
fetchCurrGroup
|
fetchCurrGroup,
|
||||||
|
addGroup
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
export default class GroupList extends Component {
|
export default class GroupList extends Component {
|
||||||
@ -27,7 +30,13 @@ export default class GroupList extends Component {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
groupList: PropTypes.array,
|
groupList: PropTypes.array,
|
||||||
currGroup: PropTypes.string
|
currGroup: PropTypes.string,
|
||||||
|
addGroup: PropTypes.func
|
||||||
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
addGroup() {
|
||||||
|
this.props.addGroup('group');
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@ -35,6 +44,7 @@ export default class GroupList extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card title="Groups">
|
<Card title="Groups">
|
||||||
|
<Button type="primary" onClick={this.addGroup}>添加分组</Button>
|
||||||
<div>{currGroup}</div>
|
<div>{currGroup}</div>
|
||||||
{
|
{
|
||||||
groupList.map((group, index) => (
|
groupList.map((group, index) => (
|
||||||
|
@ -8,9 +8,6 @@ import { createStore, combineReducers, applyMiddleware } from 'redux'
|
|||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import ReduxContainer from './ReduxContainer.js'
|
import ReduxContainer from './ReduxContainer.js'
|
||||||
|
|
||||||
console.log('thunkMiddleware', thunkMiddleware)
|
|
||||||
console.log('promiseMiddleware', promiseMiddleware)
|
|
||||||
|
|
||||||
// 合并 redux 创建stroe
|
// 合并 redux 创建stroe
|
||||||
const store = createStore(combineReducers( ReduxContainer ), applyMiddleware(
|
const store = createStore(combineReducers( ReduxContainer ), applyMiddleware(
|
||||||
thunkMiddleware.default,
|
thunkMiddleware.default,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
"@qnpm/ykit-config-qunar": "^0.8.1",
|
"@qnpm/ykit-config-qunar": "^0.8.1",
|
||||||
"axios": "^0.16.2",
|
"axios": "^0.16.2",
|
||||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||||
|
"core-decorators": "^0.17.0",
|
||||||
"fs-extra": "^3.0.1",
|
"fs-extra": "^3.0.1",
|
||||||
"jsonwebtoken": "^7.4.1",
|
"jsonwebtoken": "^7.4.1",
|
||||||
"koa": "^2.0.0",
|
"koa": "^2.0.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user