2017-08-07 19:34:34 +08:00
|
|
|
// Actions
|
|
|
|
const FETCH_ADD_INTERFACE_INPUT = 'yapi/addInterface/FETCH_ADD_INTERFACE_INPUT';
|
|
|
|
const FETCH_ADD_INTERFACE_TAG_VALUE = 'yapi/addInterface/FETCH_ADD_INTERFACE_TAG_VALUE';
|
|
|
|
const FETCH_ADD_INTERFACE_HEADER_VALUE = 'yapi/addInterface/FETCH_ADD_INTERFACE_HEADER_VALUE';
|
|
|
|
const ADD_INTERFACE_SEQ_HEADER = 'yapi/addInterface/ADD_INTERFACE_SEQ_HEADER';
|
|
|
|
const DELETE_INTERFACE_SEQ_HEADER = 'yapi/addInterface/DELETE_INTERFACE_SEQ_HEADER';
|
|
|
|
const GET_INTERFACE_REQ_PARAMS = 'yapi/addInterface/GET_INTERFACE_REQ_PARAMS';
|
|
|
|
const GET_INTERFACE_RES_PARAMS = 'yapi/addInterface/GET_INTERFACE_RES_PARAMS';
|
|
|
|
const PUSH_INTERFACE_NAME = 'yapi/addInterface/PUSH_INTERFACE_NAME';
|
|
|
|
const PUSH_INTERFACE_METHOD = 'yapi/addInterface/PUSH_INTERFACE_METHOD';
|
|
|
|
const FETCH_INTERFACE_PROJECT = 'yapi/addInterface/FETCH_INTERFACE_PROJECT';
|
|
|
|
const ADD_INTERFACE_CLIPBOARD = 'yapi/addInterface/ADD_INTERFACE_CLIPBOARD';
|
2017-07-18 12:53:53 +08:00
|
|
|
|
2017-08-07 19:34:34 +08:00
|
|
|
// Reducer
|
2017-07-18 12:53:53 +08:00
|
|
|
const initialState = {
|
2017-07-20 19:26:04 +08:00
|
|
|
interfaceName: '',
|
|
|
|
url: '',
|
2017-07-31 21:41:49 +08:00
|
|
|
method: 'GET',
|
2017-07-19 15:12:10 +08:00
|
|
|
// 默认请求头部有一条数据
|
|
|
|
seqGroup: [
|
|
|
|
{
|
|
|
|
id: 0,
|
2017-07-24 10:59:17 +08:00
|
|
|
name: '',
|
|
|
|
value: ''
|
2017-07-19 15:12:10 +08:00
|
|
|
}
|
|
|
|
],
|
2017-07-20 14:48:29 +08:00
|
|
|
reqParams: '',
|
2017-07-25 21:24:12 +08:00
|
|
|
resParams: '',
|
2017-07-31 19:43:08 +08:00
|
|
|
project: {},
|
|
|
|
clipboard: () => {}
|
2017-07-18 12:53:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default (state = initialState, action) => {
|
|
|
|
switch (action.type) {
|
2017-07-19 15:12:10 +08:00
|
|
|
case FETCH_ADD_INTERFACE_INPUT:
|
2017-07-18 12:53:53 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-20 19:26:04 +08:00
|
|
|
url: action.payload
|
2017-07-18 12:53:53 +08:00
|
|
|
}
|
2017-07-19 15:12:10 +08:00
|
|
|
case FETCH_ADD_INTERFACE_TAG_VALUE:
|
2017-07-18 12:53:53 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-19 15:12:10 +08:00
|
|
|
tagValue: action.payload
|
2017-07-18 12:53:53 +08:00
|
|
|
}
|
2017-07-19 15:12:10 +08:00
|
|
|
case FETCH_ADD_INTERFACE_HEADER_VALUE:
|
2017-07-18 12:53:53 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-19 15:12:10 +08:00
|
|
|
headerValue: action.payload
|
|
|
|
}
|
|
|
|
case ADD_INTERFACE_SEQ_HEADER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
seqGroup: action.payload
|
|
|
|
}
|
|
|
|
case DELETE_INTERFACE_SEQ_HEADER:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
seqGroup: action.payload
|
|
|
|
}
|
2017-07-20 14:48:29 +08:00
|
|
|
case GET_INTERFACE_REQ_PARAMS:
|
2017-07-19 15:12:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-19 19:29:18 +08:00
|
|
|
reqParams: action.payload
|
|
|
|
}
|
2017-07-20 14:48:29 +08:00
|
|
|
case GET_INTERFACE_RES_PARAMS:
|
2017-07-19 19:29:18 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2017-07-20 14:48:29 +08:00
|
|
|
resParams: action.payload
|
2017-07-19 19:29:18 +08:00
|
|
|
}
|
2017-07-20 16:34:46 +08:00
|
|
|
case PUSH_INTERFACE_NAME:
|
|
|
|
return {
|
|
|
|
...state,
|
2017-07-20 19:26:04 +08:00
|
|
|
interfaceName: action.payload
|
2017-07-20 16:34:46 +08:00
|
|
|
}
|
2017-07-20 16:57:21 +08:00
|
|
|
case PUSH_INTERFACE_METHOD:
|
|
|
|
return {
|
|
|
|
...state,
|
2017-07-20 17:20:30 +08:00
|
|
|
method: action.payload
|
2017-07-20 16:57:21 +08:00
|
|
|
}
|
2017-07-25 21:24:12 +08:00
|
|
|
case FETCH_INTERFACE_PROJECT:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
project: action.payload.data.data
|
|
|
|
}
|
2017-07-31 19:43:08 +08:00
|
|
|
case ADD_INTERFACE_CLIPBOARD:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
clipboard: action.payload
|
|
|
|
}
|
2017-07-18 12:53:53 +08:00
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
2017-08-07 19:34:34 +08:00
|
|
|
|
|
|
|
// Action Creators
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export function pushInputValue (value) {
|
|
|
|
return {
|
|
|
|
type: FETCH_ADD_INTERFACE_INPUT,
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reqTagValue (value) {
|
|
|
|
return {
|
|
|
|
type: FETCH_ADD_INTERFACE_TAG_VALUE,
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reqHeaderValue (value) {
|
|
|
|
return {
|
|
|
|
type: FETCH_ADD_INTERFACE_HEADER_VALUE,
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addReqHeader (value) {
|
|
|
|
return {
|
|
|
|
type: ADD_INTERFACE_SEQ_HEADER,
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteReqHeader (value) {
|
|
|
|
return {
|
|
|
|
type: DELETE_INTERFACE_SEQ_HEADER,
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getReqParams (value) {
|
|
|
|
return {
|
|
|
|
type: GET_INTERFACE_REQ_PARAMS,
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getResParams (value) {
|
|
|
|
return {
|
|
|
|
type: GET_INTERFACE_RES_PARAMS,
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function pushInterfaceName (value) {
|
|
|
|
return {
|
|
|
|
type: PUSH_INTERFACE_NAME,
|
|
|
|
payload: value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function pushInterfaceMethod (value) {
|
|
|
|
return {
|
|
|
|
type: PUSH_INTERFACE_METHOD,
|
|
|
|
payload: value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function fetchInterfaceProject(id) {
|
|
|
|
return {
|
|
|
|
type: FETCH_INTERFACE_PROJECT,
|
2017-08-11 10:25:19 +08:00
|
|
|
payload: axios.get('/api/project/get', { params: {id}})
|
2017-08-07 19:34:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addInterfaceClipboard (func) {
|
|
|
|
return {
|
|
|
|
type: ADD_INTERFACE_CLIPBOARD,
|
|
|
|
payload: func
|
|
|
|
}
|
|
|
|
}
|