mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-18 13:04:46 +08:00
Merge branch 'dev' into dev-mock
This commit is contained in:
commit
a3dd8f4a3d
@ -45,6 +45,7 @@ YApi 是<strong>高效</strong>、<strong>易用</strong>、<strong>功能强大
|
||||
* 去哪儿
|
||||
* 唯品支付
|
||||
* 链家网
|
||||
* 快手
|
||||
* 中山市鲣鸟网络科技有限公司
|
||||
* 广州大象健康科技有限公司
|
||||
* 杭州数慧科技有限公司
|
||||
|
@ -139,7 +139,7 @@ export default class Run extends Component {
|
||||
test_res_body = '',
|
||||
test_report = [],
|
||||
test_res_header = '',
|
||||
mock_verify = true
|
||||
mock_verify = false
|
||||
} = data;
|
||||
|
||||
// case 任意编辑 pathname,不管项目的 basepath
|
||||
|
@ -124,7 +124,7 @@ class InterfaceColContent extends Component {
|
||||
return item;
|
||||
})
|
||||
rows = rows.sort((n, o) => {
|
||||
return n.index > o.index
|
||||
return n.index - o.index;
|
||||
})
|
||||
this.setState({
|
||||
rows: rows
|
||||
@ -174,7 +174,7 @@ class InterfaceColContent extends Component {
|
||||
}
|
||||
|
||||
let params = Object.assign({}, query, body);
|
||||
this.reports = result;
|
||||
this.reports[curitem._id] = result;
|
||||
this.records[curitem._id] = {
|
||||
params: params,
|
||||
body: result.res_body
|
||||
@ -523,7 +523,6 @@ class InterfaceColContent extends Component {
|
||||
row: dnd.Row
|
||||
}
|
||||
};
|
||||
|
||||
const resolvedColumns = resolve.columnChildren({ columns });
|
||||
const resolvedRows = resolve.resolve({
|
||||
columns: resolvedColumns,
|
||||
|
@ -163,13 +163,14 @@ class InterfaceEditForm extends Component {
|
||||
})
|
||||
}
|
||||
} else if (values.req_body_type === 'json') {
|
||||
values.req_headers.map((item) => {
|
||||
values.req_headers?values.req_headers.map((item) => {
|
||||
if (item.name === 'Content-Type') {
|
||||
item.value = 'application/json'
|
||||
isHavaContentType = true;
|
||||
}
|
||||
})
|
||||
}):[];
|
||||
if (isHavaContentType === false) {
|
||||
values.req_headers = values.req_headers || [];
|
||||
values.req_headers.unshift({
|
||||
name: 'Content-Type',
|
||||
value: 'application/json'
|
||||
@ -514,9 +515,9 @@ class InterfaceEditForm extends Component {
|
||||
return queryTpl(item, index)
|
||||
})
|
||||
|
||||
const headerList = this.state.req_headers.map((item, index) => {
|
||||
const headerList = this.state.req_headers?this.state.req_headers.map((item, index) => {
|
||||
return headerTpl(item, index)
|
||||
})
|
||||
}):[];
|
||||
|
||||
const requestBodyList = this.state.req_body_form.map((item, index) => {
|
||||
return requestBodyTpl(item, index)
|
||||
|
@ -1,8 +1,9 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Form, Input, Icon, Tooltip, Button, Row, Col, message, Card, Radio, Alert, Modal, Popover } from 'antd';
|
||||
import { Form, Input,Select, Icon, Tooltip, Button, Row, Col, message, Card, Radio, Alert, Modal, Popover } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { updateProject, delProject, getProjectMsg, upsetProject } from '../../../../reducer/modules/project';
|
||||
import { fetchGroupMsg } from '../../../../reducer/modules/group';
|
||||
import { fetchGroupList } from '../../../../reducer/modules/group.js'
|
||||
import { connect } from 'react-redux';
|
||||
const { TextArea } = Input;
|
||||
import { withRouter } from 'react-router';
|
||||
@ -28,10 +29,13 @@ const formItemLayout = {
|
||||
className: 'form-item'
|
||||
};
|
||||
|
||||
const Option = Select.Option;
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
projectList: state.project.projectList,
|
||||
groupList: state.group.groupList,
|
||||
projectMsg: state.project.projectMsg
|
||||
}
|
||||
},
|
||||
@ -40,7 +44,8 @@ const formItemLayout = {
|
||||
delProject,
|
||||
getProjectMsg,
|
||||
fetchGroupMsg,
|
||||
upsetProject
|
||||
upsetProject,
|
||||
fetchGroupList
|
||||
}
|
||||
)
|
||||
@withRouter
|
||||
@ -62,10 +67,14 @@ class ProjectMessage extends Component {
|
||||
history: PropTypes.object,
|
||||
fetchGroupMsg: PropTypes.func,
|
||||
upsetProject: PropTypes.func,
|
||||
groupList: PropTypes.array,
|
||||
projectList: PropTypes.array,
|
||||
projectMsg: PropTypes.object
|
||||
projectMsg: PropTypes.object,
|
||||
fetchGroupList: PropTypes.func
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 确认修改
|
||||
handleOk = (e) => {
|
||||
e.preventDefault();
|
||||
@ -149,6 +158,7 @@ class ProjectMessage extends Component {
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
await this.props.fetchGroupList();
|
||||
await this.props.getProjectMsg(this.props.projectId);
|
||||
const groupMsg = await this.props.fetchGroupMsg(this.props.projectMsg.group_id);
|
||||
this.setState({
|
||||
@ -161,8 +171,8 @@ class ProjectMessage extends Component {
|
||||
const { projectMsg } = this.props;
|
||||
const mockUrl = location.protocol + '//' + location.hostname + (location.port !== "" ? ":" + location.port : "") + `/mock/${projectMsg._id}${projectMsg.basepath}+$接口请求路径`
|
||||
let initFormValues = {};
|
||||
const { name, basepath, desc, project_type } = projectMsg;
|
||||
initFormValues = { name, basepath, desc, project_type };
|
||||
const { name, basepath, desc, project_type, group_id } = projectMsg;
|
||||
initFormValues = { name, basepath, desc, project_type, group_id };
|
||||
|
||||
const colorArr = entries(constants.PROJECT_COLOR);
|
||||
const colorSelector = (<RadioGroup onChange={this.changeProjectColor} value={projectMsg.color} className="color">
|
||||
@ -185,7 +195,7 @@ class ProjectMessage extends Component {
|
||||
</Popover>
|
||||
</Col>
|
||||
<Col xs={18} sm={15} lg={19} className="setting-intro">
|
||||
<h2 className="ui-title">{this.state.currGroup + ' / ' + projectMsg.name}</h2>
|
||||
<h2 className="ui-title">{(this.state.currGroup || '') + ' / ' + (projectMsg.name || '')}</h2>
|
||||
{/* <p className="ui-desc">{projectMsg.desc}</p> */}
|
||||
</Col>
|
||||
</Row>
|
||||
@ -209,14 +219,25 @@ class ProjectMessage extends Component {
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="所属分组"
|
||||
>
|
||||
<Input value={this.state.currGroup} disabled={true} />
|
||||
{getFieldDecorator('group_id', {
|
||||
initialValue: initFormValues.group_id+'' ,
|
||||
rules: [{
|
||||
required: true, message: '请选择项目所属的分组!'
|
||||
}]
|
||||
})(
|
||||
<Select>
|
||||
{this.props.groupList.map((item, index) => (
|
||||
<Option value={item._id.toString()} key={index}>{item.group_name}</Option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={(
|
||||
|
@ -162,14 +162,15 @@ export function addProject(data) {
|
||||
|
||||
// 修改项目
|
||||
export function updateProject(data) {
|
||||
const { name, project_type, basepath, desc, _id, env } = data;
|
||||
const { name, project_type, basepath, desc, _id, env, group_id } = data;
|
||||
const param = {
|
||||
name,
|
||||
project_type,
|
||||
basepath,
|
||||
desc,
|
||||
id: _id,
|
||||
env
|
||||
env,
|
||||
group_id
|
||||
};
|
||||
return {
|
||||
type: PROJECT_UPDATE,
|
||||
|
@ -156,6 +156,8 @@ function postman(importDataModule){
|
||||
res[item] = [];
|
||||
}
|
||||
|
||||
}else if(item === 'req_body_other' && reqType === 'json' && data.request.postData){
|
||||
res[item] = json_format(data.request.postData.text);
|
||||
}else if(item === "req_headers"){
|
||||
res[item] = [{
|
||||
name: 'Content-Type',
|
||||
|
@ -151,6 +151,9 @@ class interfaceColController extends baseController{
|
||||
result.req_params = this.handleParamsValue(data.req_params, result.req_params)
|
||||
resultList[index] = result;
|
||||
}
|
||||
resultList = resultList.sort((a,b)=>{
|
||||
return a.index - b.index;
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(resultList);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
@ -603,6 +603,7 @@ class projectController extends baseController {
|
||||
|
||||
if (!_.isUndefined(params.name)) data.name = params.name;
|
||||
if (!_.isUndefined(params.desc)) data.desc = params.desc;
|
||||
if (!_.isUndefined(params.group_id)) data.group_id = params.group_id;
|
||||
data.basepath = params.basepath;
|
||||
if (!_.isUndefined(params.color)) data.color = params.color;
|
||||
if (!_.isUndefined(params.icon)) data.icon = params.icon;
|
||||
|
@ -137,7 +137,13 @@ module.exports = async (ctx, next) => {
|
||||
body: ctx.request.body
|
||||
}
|
||||
);
|
||||
res = Mock.mock(res);
|
||||
|
||||
try{
|
||||
res = Mock.mock(res);
|
||||
}catch(e){
|
||||
res = res;
|
||||
}
|
||||
|
||||
let context = {
|
||||
projectData: project,
|
||||
interfaceData: interfaceData,
|
||||
|
Loading…
Reference in New Issue
Block a user