mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-30 13:20:24 +08:00
feat : 调试保存接口
This commit is contained in:
parent
3516b98c96
commit
e303f5f218
@ -1,8 +1,8 @@
|
||||
import LoginRedux from './reducer/login/Login_redux.js'
|
||||
import login from './reducer/login/login.js'
|
||||
import LoginRedux from './reducer/Login/Login_redux.js'
|
||||
import login from './reducer/Login/login.js'
|
||||
import group from './reducer/group/group.js'
|
||||
import project from './reducer/group/project.js'
|
||||
import Interface from './reducer/interface/InterfaceReducer.js'
|
||||
import Interface from './reducer/Interface/InterfaceReducer.js'
|
||||
import news from './reducer/news/news.js'
|
||||
import addInterface from './reducer/addInterface/addInterface.js'
|
||||
import user from './reducer/user/user.js'
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
DELETE_INTERFACE_SEQ_HEADER,
|
||||
GET_INTERFACE_REQ_PARAMS,
|
||||
GET_INTERFACE_RES_PARAMS,
|
||||
SAVE_INTERFACE_FORMS,
|
||||
// SAVE_INTERFACE_FORMS,
|
||||
PUSH_INTERFACE_NAME,
|
||||
PUSH_INTERFACE_METHOD
|
||||
} from '../constants/action-types.js'
|
||||
@ -60,12 +60,12 @@ export function getResParams (value) {
|
||||
};
|
||||
}
|
||||
|
||||
export function saveForms (value) {
|
||||
return {
|
||||
type: SAVE_INTERFACE_FORMS,
|
||||
payload: value
|
||||
};
|
||||
}
|
||||
// export function saveForms (value) {
|
||||
// return {
|
||||
// type: SAVE_INTERFACE_FORMS,
|
||||
// payload: value
|
||||
// };
|
||||
// }
|
||||
|
||||
export function pushInterfaceName (value) {
|
||||
return {
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
DELETE_INTERFACE_SEQ_HEADER,
|
||||
GET_INTERFACE_REQ_PARAMS,
|
||||
GET_INTERFACE_RES_PARAMS,
|
||||
SAVE_INTERFACE_FORMS,
|
||||
// SAVE_INTERFACE_FORMS,
|
||||
PUSH_INTERFACE_NAME,
|
||||
PUSH_INTERFACE_METHOD
|
||||
} from '../constants/action-types.js'
|
||||
@ -60,12 +60,12 @@ export function getResParams (value) {
|
||||
};
|
||||
}
|
||||
|
||||
export function saveForms (value) {
|
||||
return {
|
||||
type: SAVE_INTERFACE_FORMS,
|
||||
payload: value
|
||||
};
|
||||
}
|
||||
// export function saveForms (value) {
|
||||
// return {
|
||||
// type: SAVE_INTERFACE_FORMS,
|
||||
// payload: value
|
||||
// };
|
||||
// }
|
||||
|
||||
export function pushInterfaceName (value) {
|
||||
return {
|
||||
|
@ -12,7 +12,7 @@ export const ADD_INTERFACE_SEQ_HEADER = 'ADD_INTERFACE_SEQ_HEADER'
|
||||
export const DELETE_INTERFACE_SEQ_HEADER = 'DELETE_INTERFACE_SEQ_HEADER'
|
||||
export const GET_INTERFACE_REQ_PARAMS = 'GET_INTERFACE_REQ_PARAMS'
|
||||
export const GET_INTERFACE_RES_PARAMS = 'GET_INTERFACE_RES_PARAMS'
|
||||
export const SAVE_INTERFACE_FORMS = 'SAVE_INTERFACE_FORMS'
|
||||
// export const SAVE_INTERFACE_FORMS = 'SAVE_INTERFACE_FORMS'
|
||||
export const PUSH_INTERFACE_METHOD = 'PUSH_INTERFACE_METHOD'
|
||||
|
||||
// group
|
||||
|
@ -16,7 +16,10 @@ import { saveForms } from '../../actions/addInterface.js'
|
||||
state => {
|
||||
return {
|
||||
reqParams: state.addInterface.reqParams,
|
||||
methode: state.addInterface.method
|
||||
resParams: state.addInterface.resParams,
|
||||
method: state.addInterface.method,
|
||||
url: state.addInterface.url,
|
||||
interfaceName: state.addInterface.interfaceName
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -27,7 +30,10 @@ import { saveForms } from '../../actions/addInterface.js'
|
||||
class AddInterface extends Component {
|
||||
static propTypes = {
|
||||
reqParams: PropTypes.string,
|
||||
methode: PropTypes.string,
|
||||
resParams: PropTypes.string,
|
||||
method: PropTypes.string,
|
||||
url: PropTypes.string,
|
||||
interfaceName: PropTypes.string,
|
||||
saveForms: PropTypes.func
|
||||
}
|
||||
|
||||
@ -37,35 +43,21 @@ class AddInterface extends Component {
|
||||
|
||||
@autobind
|
||||
saveForms () {
|
||||
// const config = {
|
||||
// url: '/interface/add',
|
||||
// method: 'POST',
|
||||
// headers: {'Content-Type': 'application/json'},
|
||||
// params: {
|
||||
// method: 'POST',
|
||||
// project_id: 8,
|
||||
// req_headers: [],
|
||||
// req_params_type: 'json',
|
||||
// req_params: this.props.reqParams
|
||||
// }
|
||||
// }
|
||||
const { interfaceName, url, reqParams, resParams } = this.props
|
||||
const params = {
|
||||
url: '/interface/add',
|
||||
title: interfaceName,
|
||||
path: url,
|
||||
method: 'POST',
|
||||
params: {
|
||||
method: 'POST',
|
||||
project_id: 558,
|
||||
req_headers: [],
|
||||
req_params_type: 'json',
|
||||
req_params: this.props.reqParams,
|
||||
title: '接口文档1'
|
||||
}
|
||||
project_id: 558,
|
||||
req_params_type: 'json',
|
||||
req_params_other: reqParams,
|
||||
res_body_type: 'json',
|
||||
res_body: resParams
|
||||
}
|
||||
|
||||
axios.post('/interface/add', params)
|
||||
.then(data => {
|
||||
console.log(data)
|
||||
console.log(this.props.methode)
|
||||
console.log('data', data)
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
state => {
|
||||
return {
|
||||
method: state.addInterface.method,
|
||||
reqInputVal: state.addInterface.inputValue,
|
||||
url: state.addInterface.url,
|
||||
interfaceName: state.addInterface.interfaceName
|
||||
}
|
||||
},
|
||||
@ -29,7 +29,7 @@ class ReqMethod extends Component {
|
||||
pushInputValue: PropTypes.func,
|
||||
pushInterfaceName: PropTypes.func,
|
||||
pushInterfaceMethod: PropTypes.func,
|
||||
inputValue: PropTypes.string,
|
||||
url: PropTypes.string,
|
||||
method: PropTypes.string,
|
||||
interfaceName: PropTypes.string
|
||||
}
|
||||
@ -45,8 +45,8 @@ class ReqMethod extends Component {
|
||||
|
||||
@autobind
|
||||
getInputVal (e) {
|
||||
const inputVal = e.target.value
|
||||
this.props.pushInputValue(inputVal)
|
||||
const url = e.target.value
|
||||
this.props.pushInputValue(url)
|
||||
}
|
||||
|
||||
@autobind
|
||||
@ -57,14 +57,14 @@ class ReqMethod extends Component {
|
||||
|
||||
render () {
|
||||
const { Option } = Select
|
||||
console.log(this.props.method)
|
||||
|
||||
return (
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>协议 :</th>
|
||||
<td>
|
||||
<span className="h3">请求协议 {this.props.inputValue}</span>
|
||||
<span className="h3">请求协议</span>
|
||||
<Select defaultValue="HTTP" style={{ width: 220}} onChange={this.handleChange} size="large">
|
||||
<Option value="HTTP">HTTP</Option>
|
||||
<Option value="HTTPS">HTTPS</Option>
|
||||
|
@ -32,6 +32,7 @@ class ReqParams extends Component {
|
||||
editor.customConfig.menus = []
|
||||
editor.customConfig.onchange = html => {
|
||||
html = html.replace(reg, '')
|
||||
console.log(html)
|
||||
this.props.getReqParams(html)
|
||||
}
|
||||
editor.create()
|
||||
|
@ -26,10 +26,12 @@ class ResParams extends Component {
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
var E = wangEditor
|
||||
var editor = new E('#res-cover')
|
||||
const reg = /(<p>)|(<\/p>)| |(<br>)|\s+/g
|
||||
const E = wangEditor
|
||||
const editor = new E('#res-cover')
|
||||
editor.customConfig.menus = []
|
||||
editor.customConfig.onchange = html => {
|
||||
html = html.replace(reg, '')
|
||||
this.props.getResParams(html)
|
||||
}
|
||||
editor.create()
|
||||
@ -47,4 +49,4 @@ class ResParams extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default ResParams
|
||||
export default ResParams
|
||||
|
@ -6,13 +6,14 @@ import {
|
||||
DELETE_INTERFACE_SEQ_HEADER,
|
||||
GET_INTERFACE_REQ_PARAMS,
|
||||
GET_INTERFACE_RES_PARAMS,
|
||||
SAVE_INTERFACE_FORMS,
|
||||
// SAVE_INTERFACE_FORMS,
|
||||
PUSH_INTERFACE_NAME,
|
||||
PUSH_INTERFACE_METHOD
|
||||
} from '../../constants/action-types.js'
|
||||
|
||||
const initialState = {
|
||||
inputValue: '',
|
||||
interfaceName: '',
|
||||
url: '',
|
||||
tagValue: '',
|
||||
headerValue: '',
|
||||
method: '',
|
||||
@ -33,7 +34,7 @@ export default (state = initialState, action) => {
|
||||
case FETCH_ADD_INTERFACE_INPUT:
|
||||
return {
|
||||
...state,
|
||||
inputValue: action.payload
|
||||
url: action.payload
|
||||
}
|
||||
case FETCH_ADD_INTERFACE_TAG_VALUE:
|
||||
return {
|
||||
@ -65,15 +66,15 @@ export default (state = initialState, action) => {
|
||||
...state,
|
||||
resParams: action.payload
|
||||
}
|
||||
case SAVE_INTERFACE_FORMS:
|
||||
return {
|
||||
...state,
|
||||
resParams: action.payload
|
||||
}
|
||||
// case SAVE_INTERFACE_FORMS:
|
||||
// return {
|
||||
// ...state,
|
||||
// resParams: action.payload
|
||||
// }
|
||||
case PUSH_INTERFACE_NAME:
|
||||
return {
|
||||
...state,
|
||||
resParams: action.payload
|
||||
interfaceName: action.payload
|
||||
}
|
||||
case PUSH_INTERFACE_METHOD:
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user