mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-24 13:14:16 +08:00
fix: js path
This commit is contained in:
commit
74eaf2c308
@ -2,17 +2,19 @@ import {
|
||||
FETCH_GROUP_LIST,
|
||||
FETCH_CURR_GROUP
|
||||
} from '../constants/action-types';
|
||||
import axios from 'axios';
|
||||
|
||||
export function fetchGroupList() {
|
||||
return {
|
||||
type: FETCH_GROUP_LIST,
|
||||
// payload 可以返回 Promise,异步请求使用 axios 即可
|
||||
payload: new Promise((resolve) => {
|
||||
resolve({
|
||||
data: ['Hotel', 'Vacation', 'Flight', 'Pay'],
|
||||
res: true
|
||||
})
|
||||
})
|
||||
payload: axios.get('/group/list')
|
||||
// payload: new Promise((resolve) => {
|
||||
// resolve({
|
||||
// data: ['Hotel', 'Vacation', 'Flight', 'Pay'],
|
||||
// res: true
|
||||
// })
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,13 +31,13 @@ export function addGroup(groupName) {
|
||||
return function(dispatch, getState) {
|
||||
const group = getState().group;
|
||||
const groupList = group.groupList || [];
|
||||
const newGroupList = groupList.concat([groupName + groupList.length]);
|
||||
const newGroupList = groupList.concat([{ group_name: groupName + groupList.length }]);
|
||||
dispatch({
|
||||
type: FETCH_GROUP_LIST,
|
||||
payload: {
|
||||
payload: { data: {
|
||||
data: newGroupList,
|
||||
res: true
|
||||
}
|
||||
errcode: 0
|
||||
}}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ export default class GroupList extends Component {
|
||||
<div>{currGroup}</div>
|
||||
{
|
||||
groupList.map((group, index) => (
|
||||
<div key={index}>{group}</div>
|
||||
<div key={index}>{group.group_name}</div>
|
||||
))
|
||||
}
|
||||
</Card>
|
||||
|
@ -11,10 +11,10 @@ const initialState = {
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case FETCH_GROUP_LIST: {
|
||||
if (action.payload.res) {
|
||||
if (!action.payload.data.errcode) {
|
||||
return {
|
||||
...state,
|
||||
groupList: action.payload.data
|
||||
groupList: action.payload.data.data
|
||||
};
|
||||
}
|
||||
return state;
|
||||
|
Loading…
Reference in New Issue
Block a user