yapi/client/reducer/modules/follow.js
System Administrator 362172ef52 fix: bug修复
2017-09-14 18:19:13 +08:00

51 lines
934 B
JavaScript
Executable File

import axios from 'axios';
// Actions
const GET_FOLLOW_LIST = 'yapi/follow/GET_FOLLOW_LIST';
const DEL_FOLLOW = 'yapi/follow/DEL_FOLLOW';
const ADD_FOLLOW = 'yapi/follow/ADD_FOLLOW';
// Reducer
const initialState = {
data: []
};
export default (state = initialState, action) => {
switch (action.type) {
case GET_FOLLOW_LIST: {
return {
...state,
data: action.payload.data.data
};
}
default:
return state;
}
};
// 获取关注列表
export function getFollowList(uid) {
return {
type: GET_FOLLOW_LIST,
payload: axios.get('/api/follow/list', {
params: { uid }
})
}
}
// 添加关注
export function addFollow(param) {
return {
type: ADD_FOLLOW,
payload: axios.post('/api/follow/add', param)
}
}
// 删除关注
export function delFollow(id) {
return {
type: DEL_FOLLOW,
payload: axios.post('/api/follow/del', { projectid: id })
}
}