mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
fix: 解决冲突
This commit is contained in:
commit
8e90284be9
@ -165,7 +165,7 @@ export default class HeaderCom extends Component {
|
||||
<Header className="header-box m-header">
|
||||
<div className="content g-row">
|
||||
<div className="logo">
|
||||
<Link to="/" onClick={this.relieveLink} className="href">
|
||||
<Link to="/group" onClick={this.relieveLink} className="href">
|
||||
<img className="img" src="/image/logo_header@1x.png" /><span className="logo-name">YAPI<span className="ui-badge"></span></span>
|
||||
</Link>
|
||||
</div>
|
||||
|
@ -35,13 +35,15 @@ class InterfaceEditForm extends Component {
|
||||
req_body_type: 'form',
|
||||
req_headers: [{
|
||||
name: 'Content-Type',
|
||||
value: 'application/urlencode', required: "1"
|
||||
value: 'application/x-www-form-urlencoded', required: "1"
|
||||
}],
|
||||
req_body_form: [{
|
||||
name: 'id',
|
||||
type: 'text',
|
||||
required: '1'
|
||||
}]
|
||||
}],
|
||||
res_body_type: 'json',
|
||||
res_body: ''
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,20 +52,29 @@ class InterfaceEditForm extends Component {
|
||||
this.props.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
console.log('Received values of form: ', values);
|
||||
console.log(this.props.form.getFieldValue('keys'))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
let that = this;
|
||||
mockEditor({
|
||||
container: 'req_body_json',
|
||||
data: {
|
||||
name: "@name"
|
||||
},
|
||||
data: that.state.req_body_json,
|
||||
onChange: function (d) {
|
||||
console.log(this)
|
||||
console.log(d)
|
||||
that.setState({
|
||||
req_body_json: d.text
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
mockEditor({
|
||||
container: 'res_body_json',
|
||||
data: that.state.res_body,
|
||||
onChange: function (d) {
|
||||
that.setState({
|
||||
res_body: d.text
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -294,33 +305,94 @@ class InterfaceEditForm extends Component {
|
||||
<Radio value="form">form</Radio>
|
||||
<Radio value="json">json</Radio>
|
||||
<Radio value="file">file</Radio>
|
||||
<Radio value="raw">raw</Radio>
|
||||
</RadioGroup>
|
||||
)}
|
||||
|
||||
</FormItem>
|
||||
{this.props.form.getFieldValue('req_body_type') === 'form' ?
|
||||
<Row >
|
||||
<Col span={14} offset={6} style={{ minHeight: "50px", padding: "15px" }}>
|
||||
<Row>
|
||||
<Col span="24">
|
||||
|
||||
<Row style={{ display: this.props.form.getFieldValue('req_body_type') === 'form' ? 'block' : 'none' }}>
|
||||
<Col span={14} offset={6} style={{ minHeight: "300px", padding: "15px" }}>
|
||||
<Row>
|
||||
<Col span="24">
|
||||
<Button onClick={() => this.addParams('req_body_form')}>添加form参数</Button>
|
||||
|
||||
<Button onClick={() => this.addParams('req_body_form')}>添加form参数</Button>
|
||||
</Col>
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
{requestBodyList}
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
{requestBodyList}
|
||||
</Col>
|
||||
</Row>
|
||||
:
|
||||
null
|
||||
}
|
||||
|
||||
</Row>
|
||||
|
||||
<Row style={{ display: this.props.form.getFieldValue('req_body_type') === 'json' ? 'block' : 'none' }}>
|
||||
<Col span={14} offset={6} id="req_body_json" style={{ minHeight: "300px", padding: "15px" }}>
|
||||
|
||||
<Col span={14} offset={6} id="req_body_json" style={{ minHeight: "300px", padding: "15px" }}>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{this.props.form.getFieldValue('req_body_type') === 'file' ?
|
||||
<Row >
|
||||
<Col span={14} offset={6} style={{ padding: "15px" }}>
|
||||
{getFieldDecorator('req_body_other', { initialValue: this.state.req_body_other })(
|
||||
<Input.TextArea placeholder="备注信息" />
|
||||
)}
|
||||
</Col>
|
||||
|
||||
|
||||
</Row>
|
||||
:
|
||||
null
|
||||
}
|
||||
{this.props.form.getFieldValue('req_body_type') === 'raw' ?
|
||||
<Row>
|
||||
<Col span={14} offset={6} style={{ padding: "15px" }}>
|
||||
{getFieldDecorator('req_body_other', { initialValue: this.state.req_body_other })(
|
||||
<Input.TextArea placeholder="备注信息" />
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
: null
|
||||
}
|
||||
|
||||
<FormItem style={{ marginBottom: "5px" }}
|
||||
{...formItemLayout}
|
||||
label="响应Body"
|
||||
>
|
||||
{getFieldDecorator('res_body_type', {
|
||||
initialValue: this.state.res_body_type
|
||||
})(
|
||||
<RadioGroup>
|
||||
<Radio value="json">json</Radio>
|
||||
<Radio value="raw">raw</Radio>
|
||||
|
||||
</RadioGroup>
|
||||
)}
|
||||
|
||||
</FormItem>
|
||||
<Row style={{ display: this.props.form.getFieldValue('res_body_type') === 'json' ? 'block' : 'none' }}>
|
||||
<Col span={14} offset={6} id="res_body_json" style={{ minHeight: "300px", padding: "15px" }}>
|
||||
|
||||
</Col>
|
||||
|
||||
|
||||
</Row>
|
||||
|
||||
<Row style={{ display: this.props.form.getFieldValue('res_body_type') === 'raw' ? 'block' : 'none' }}>
|
||||
<Col span={14} offset={6} style={{ padding: "15px" }}>
|
||||
{getFieldDecorator('req_body_other', { initialValue: this.state.res_body })(
|
||||
<Input.TextArea placeholder="备注信息" />
|
||||
)}
|
||||
</Col>
|
||||
|
||||
|
||||
</Row>
|
||||
|
||||
|
||||
<FormItem
|
||||
wrapperCol={{ span: 12, offset: 6 }}
|
||||
>
|
||||
|
@ -3,8 +3,6 @@ var ace = require('brace'),
|
||||
require('brace/mode/javascript');
|
||||
require('brace/theme/xcode');
|
||||
require("brace/ext/language_tools.js");
|
||||
require("brace/snippets/javascript.js");
|
||||
|
||||
var json5 = require('json5');
|
||||
|
||||
var langTools = ace.acequire("ace/ext/language_tools"),
|
||||
@ -76,8 +74,9 @@ function run(options) {
|
||||
editor.setTheme('ace/theme/xcode');
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: true
|
||||
enableSnippets: false,
|
||||
enableLiveAutocompletion: true,
|
||||
useWorker: false
|
||||
});
|
||||
mockEditor = {
|
||||
curData: {},
|
||||
|
@ -3,7 +3,7 @@ import { message } from 'antd';
|
||||
export default () => next => action => {
|
||||
if (action.error) {
|
||||
message.error((action.payload && action.payload.message) || '服务器错误');
|
||||
} else if (action.payload && action.payload.data && action.payload.data.errcode) {
|
||||
} else if (action.payload && action.payload.data && action.payload.data.errcode && action.payload.data.errcode !== 40011) {
|
||||
message.error(action.payload.data.errmsg);
|
||||
}
|
||||
return next(action);
|
||||
|
@ -72,7 +72,7 @@ class baseController {
|
||||
result.server_ip = yapi.WEBCONFIG.server_ip;
|
||||
return ctx.body = yapi.commons.resReturn(result);
|
||||
}
|
||||
return ctx.body = yapi.commons.resReturn(null, 300, 'Please login.');
|
||||
return ctx.body = yapi.commons.resReturn(null, 40011, '请登录...');
|
||||
}
|
||||
|
||||
getRole() {
|
||||
|
@ -24,6 +24,11 @@ class interfaceColController extends baseController{
|
||||
try {
|
||||
let id = ctx.query.project_id;
|
||||
let result = await this.colModel.list(id);
|
||||
|
||||
for(let i=0; i< result.length;i++){
|
||||
result[i] = result[i].toObject();
|
||||
result[i].caseList = await this.caseModel.list(result[i]._id)
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -134,13 +139,7 @@ class interfaceColController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
if (!params.col_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
if (!params.env) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '缺少环境配置');
|
||||
}
|
||||
if (!params.path) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, 'path 不能为空');
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口集id不能为空');
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,26 +42,12 @@ class interfaceModel extends baseModel {
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_body_json_doc: [{
|
||||
json_path: String, desc: String,required:{
|
||||
type:String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_body_other: String,
|
||||
res_body_type: {
|
||||
type: String,
|
||||
enum: ['json', 'text', 'xml']
|
||||
},
|
||||
res_body: String,
|
||||
res_body_json_doc: [{
|
||||
json_path: String, desc: String,required:{
|
||||
type:String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}]
|
||||
res_body: String
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,10 @@ class interfaceCase extends baseModel {
|
||||
project_id: { type: Number, required: true },
|
||||
add_time: Number,
|
||||
up_time: Number,
|
||||
env: { type: String, required: true },
|
||||
env: { type: String },
|
||||
domain: {type: String },
|
||||
path: { type: String, required: true },
|
||||
method: { type: String, required: true },
|
||||
path: { type: String },
|
||||
method: { type: String },
|
||||
req_query: [{
|
||||
name: String, value: String
|
||||
}],
|
||||
@ -48,8 +48,10 @@ class interfaceCase extends baseModel {
|
||||
}).exec();
|
||||
}
|
||||
|
||||
list() {
|
||||
return this.model.find().select("casename uid col_id _id index").exec();
|
||||
list(col_id) {
|
||||
return this.model.find({
|
||||
col_id: col_id
|
||||
}).select("casename uid col_id _id index").exec();
|
||||
}
|
||||
|
||||
del(id) {
|
||||
|
@ -320,7 +320,7 @@ function createAction(controller, action, path, method) {
|
||||
if (inst.$auth === true) {
|
||||
await inst[action].call(inst, ctx);
|
||||
} else {
|
||||
ctx.body = yapi.commons.resReturn(null, 40011, '请登录.');
|
||||
ctx.body = yapi.commons.resReturn(null, 40011, '请登录...');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ var baseController = function () {
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result));
|
||||
|
||||
case 7:
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 300, 'Please login.'));
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 40011, '请登录...'));
|
||||
|
||||
case 8:
|
||||
case 'end':
|
||||
|
@ -75,7 +75,7 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var id, result;
|
||||
var id, result, i;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
@ -87,23 +87,43 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 4:
|
||||
result = _context.sent;
|
||||
i = 0;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 11;
|
||||
case 6:
|
||||
if (!(i < result.length)) {
|
||||
_context.next = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
result[i] = result[i].toObject();
|
||||
_context.next = 10;
|
||||
return this.caseModel.list(result[i]._id);
|
||||
|
||||
case 10:
|
||||
result[i].caseList = _context.sent;
|
||||
|
||||
case 11:
|
||||
i++;
|
||||
_context.next = 6;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
_context.prev = 8;
|
||||
case 14:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 20;
|
||||
break;
|
||||
|
||||
case 17:
|
||||
_context.prev = 17;
|
||||
_context.t0 = _context['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 11:
|
||||
case 20:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[0, 8]]);
|
||||
}, _callee, this, [[0, 17]]);
|
||||
}));
|
||||
|
||||
function list(_x) {
|
||||
@ -309,62 +329,46 @@ var interfaceColController = function (_baseController) {
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口集id不能为空'));
|
||||
|
||||
case 7:
|
||||
if (params.env) {
|
||||
_context4.next = 9;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '缺少环境配置'));
|
||||
|
||||
case 9:
|
||||
if (params.path) {
|
||||
_context4.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, 'path 不能为空'));
|
||||
|
||||
case 11:
|
||||
if (params.casename) {
|
||||
_context4.next = 13;
|
||||
_context4.next = 9;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
|
||||
|
||||
case 13:
|
||||
case 9:
|
||||
|
||||
params.uid = this.getUid();
|
||||
params.index = 0;
|
||||
params.add_time = _yapi2.default.commons.time();
|
||||
params.up_time = _yapi2.default.commons.time();
|
||||
_context4.next = 19;
|
||||
_context4.next = 15;
|
||||
return this.caseModel.save(params);
|
||||
|
||||
case 19:
|
||||
case 15:
|
||||
result = _context4.sent;
|
||||
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context4.next = 26;
|
||||
_context4.next = 22;
|
||||
break;
|
||||
|
||||
case 23:
|
||||
_context4.prev = 23;
|
||||
case 19:
|
||||
_context4.prev = 19;
|
||||
_context4.t0 = _context4['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
|
||||
|
||||
case 26:
|
||||
case 22:
|
||||
case 'end':
|
||||
return _context4.stop();
|
||||
}
|
||||
}
|
||||
}, _callee4, this, [[0, 23]]);
|
||||
}, _callee4, this, [[0, 19]]);
|
||||
}));
|
||||
|
||||
function addCase(_x4) {
|
||||
|
@ -81,26 +81,12 @@ var interfaceModel = function (_baseModel) {
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_body_json_doc: [{
|
||||
json_path: String, desc: String, required: {
|
||||
type: String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_body_other: String,
|
||||
res_body_type: {
|
||||
type: String,
|
||||
enum: ['json', 'text', 'xml']
|
||||
},
|
||||
res_body: String,
|
||||
res_body_json_doc: [{
|
||||
json_path: String, desc: String, required: {
|
||||
type: String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}]
|
||||
res_body: String
|
||||
};
|
||||
}
|
||||
}, {
|
||||
|
@ -54,10 +54,10 @@ var interfaceCase = function (_baseModel) {
|
||||
project_id: { type: Number, required: true },
|
||||
add_time: Number,
|
||||
up_time: Number,
|
||||
env: { type: String, required: true },
|
||||
env: { type: String },
|
||||
domain: { type: String },
|
||||
path: { type: String, required: true },
|
||||
method: { type: String, required: true },
|
||||
path: { type: String },
|
||||
method: { type: String },
|
||||
req_query: [{
|
||||
name: String, value: String
|
||||
}],
|
||||
@ -90,8 +90,10 @@ var interfaceCase = function (_baseModel) {
|
||||
}
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function list() {
|
||||
return this.model.find().select("casename uid col_id _id index").exec();
|
||||
value: function list(col_id) {
|
||||
return this.model.find({
|
||||
col_id: col_id
|
||||
}).select("casename uid col_id _id index").exec();
|
||||
}
|
||||
}, {
|
||||
key: 'del',
|
||||
|
@ -339,7 +339,7 @@ function createAction(controller, action, path, method) {
|
||||
break;
|
||||
|
||||
case 8:
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 40011, '请登录.');
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 40011, '请登录...');
|
||||
|
||||
case 9:
|
||||
case 'end':
|
||||
|
Loading…
Reference in New Issue
Block a user