mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-24 13:14:16 +08:00
fix: add cat bug
This commit is contained in:
parent
c2a4b3b51a
commit
79ef20f2de
@ -51,22 +51,28 @@ class InterfaceEditForm extends Component {
|
|||||||
path: '',
|
path: '',
|
||||||
status: 'undone',
|
status: 'undone',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|
||||||
req_params: [],
|
req_params: [],
|
||||||
|
|
||||||
req_query: [{
|
req_query: [{
|
||||||
name: '',
|
name: '',
|
||||||
desc: '',
|
desc: '',
|
||||||
required: "1"
|
required: "1"
|
||||||
}],
|
}],
|
||||||
req_body_type: 'form',
|
|
||||||
req_headers: [{
|
req_headers: [{
|
||||||
name: '',
|
name: '',
|
||||||
value: '', required: "1"
|
value: '', required: "1"
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
req_body_type: 'form',
|
||||||
req_body_form: [{
|
req_body_form: [{
|
||||||
name: '',
|
name: '',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
required: '1'
|
required: '1'
|
||||||
}],
|
}],
|
||||||
|
req_body_other: '',
|
||||||
|
|
||||||
res_body_type: 'json',
|
res_body_type: 'json',
|
||||||
res_body: '',
|
res_body: '',
|
||||||
desc: '',
|
desc: '',
|
||||||
@ -83,7 +89,7 @@ class InterfaceEditForm extends Component {
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
if (values.res_body_type === 'json') values.res_body = this.state.res_body;
|
if (values.res_body_type === 'json') values.res_body = this.state.res_body;
|
||||||
values.req_params = this.state.req_params;
|
values.req_params = this.state.req_params;
|
||||||
values.req_body_json = this.state.res_body;
|
values.req_body_other = this.state.req_body_other;
|
||||||
values.method = this.state.method;
|
values.method = this.state.method;
|
||||||
let isfile = false, isHavaContentType = false;
|
let isfile = false, isHavaContentType = false;
|
||||||
if (values.req_body_type === 'form') {
|
if (values.req_body_type === 'form') {
|
||||||
@ -105,6 +111,19 @@ class InterfaceEditForm extends Component {
|
|||||||
value: isfile ? 'multipart/form-data' : 'application/x-www-form-urlencoded'
|
value: isfile ? 'multipart/form-data' : 'application/x-www-form-urlencoded'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}else if(values.req_body_type === 'json'){
|
||||||
|
values.req_headers.map((item) => {
|
||||||
|
if (item.name === 'Content-Type') {
|
||||||
|
item.value = 'application/json'
|
||||||
|
isHavaContentType = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(isHavaContentType === false){
|
||||||
|
values.req_headers.unshift({
|
||||||
|
name: 'Content-Type',
|
||||||
|
value: 'application/json'
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
values.req_headers = values.req_headers ?values.req_headers.filter((item) => item.name !== '') : []
|
values.req_headers = values.req_headers ?values.req_headers.filter((item) => item.name !== '') : []
|
||||||
values.req_body_form = values.req_body_form ? values.req_body_form.filter((item) => item.name !== ''): []
|
values.req_body_form = values.req_body_form ? values.req_body_form.filter((item) => item.name !== ''): []
|
||||||
@ -123,11 +142,11 @@ class InterfaceEditForm extends Component {
|
|||||||
let that = this, mockPreview, resBodyEditor;
|
let that = this, mockPreview, resBodyEditor;
|
||||||
mockEditor({
|
mockEditor({
|
||||||
container: 'req_body_json',
|
container: 'req_body_json',
|
||||||
data: that.state.req_body_json,
|
data: that.state.req_body_other,
|
||||||
onChange: function (d) {
|
onChange: function (d) {
|
||||||
if (d.format !== true) return false;
|
if (d.format !== true) return false;
|
||||||
that.setState({
|
that.setState({
|
||||||
req_body_json: d.text
|
req_body_other: d.text
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -374,7 +393,7 @@ class InterfaceEditForm extends Component {
|
|||||||
})}
|
})}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
<Tooltip title="接口基本路径,可在项目配置里修改">
|
<Tooltip title="接口基本路径,可在项目配置里修改" style={{display: this.props.basepath == '' ? 'block': 'none'}}>
|
||||||
<Input disabled value={this.props.basepath} readOnly onChange={() => { }} style={{ width: '25%' }} />
|
<Input disabled value={this.props.basepath} readOnly onChange={() => { }} style={{ width: '25%' }} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
{getFieldDecorator('path', {
|
{getFieldDecorator('path', {
|
||||||
@ -577,9 +596,9 @@ class InterfaceEditForm extends Component {
|
|||||||
|
|
||||||
<FormItem
|
<FormItem
|
||||||
className="interface-edit-item"
|
className="interface-edit-item"
|
||||||
wrapperCol={{ span: 12, offset: 6 }}
|
wrapperCol={{ span: 14, offset: 10 }}
|
||||||
>
|
>
|
||||||
<Button type="primary" htmlType="submit">Submit</Button>
|
<Button type="primary" htmlType="submit">保存</Button>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user