mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-30 13:20:24 +08:00
fix: 解决冲突
This commit is contained in:
commit
b770d95c77
@ -8,7 +8,7 @@ import InterfaceTable from './InterfaceTable/InterfaceTable.js'
|
||||
import InterfaceMode from './InterfaceMode/InterfaceMode.js'
|
||||
import moment from 'moment'
|
||||
import {
|
||||
fetchInterfaceData,
|
||||
fetchInterfaceData,
|
||||
projectMember,
|
||||
closeProjectMember
|
||||
} from '../../actions/interfaceAction.js'
|
||||
|
@ -1,48 +1,19 @@
|
||||
/* .interface-box.css */
|
||||
.interface-box {
|
||||
max-width: 11rem;
|
||||
display: -webkit-box;
|
||||
-webkit-box-flex: 1;
|
||||
margin: 24px auto;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
|
||||
font-size: 0.14rem;
|
||||
background: #FFF;
|
||||
|
||||
.interface-list {
|
||||
width: 216px;
|
||||
line-height: 45px;
|
||||
background: #f9fafe;
|
||||
|
||||
li {
|
||||
padding: 0 0 0 30px;
|
||||
color: #344562;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: #29f;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #344562;
|
||||
&:hover {
|
||||
color: #29f;
|
||||
}
|
||||
}
|
||||
}
|
||||
overflow: hidden;
|
||||
.interface-btngroup {
|
||||
margin: .24rem .24rem 0;
|
||||
}
|
||||
.interface-btn {
|
||||
margin-right: .16rem;
|
||||
}
|
||||
|
||||
.interface-table {
|
||||
-webkit-box-flex: 1;
|
||||
margin: 0 20px;
|
||||
min-height: 740px;
|
||||
.ant-table-wrapper table {
|
||||
font-size: .14rem;
|
||||
|
||||
button {
|
||||
margin: 0 10px 0 0;
|
||||
}
|
||||
}
|
||||
margin: .24rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Button } from 'antd'
|
||||
|
||||
class InterfaceList extends Component {
|
||||
static propTypes = {
|
||||
@ -23,10 +24,10 @@ class InterfaceList extends Component {
|
||||
const getInterfaceId = this.getInterfaceId()
|
||||
console.log(`/AddInterface/${getInterfaceId}`)
|
||||
return (
|
||||
<ul className="interface-list">
|
||||
<li><Link to={`/AddInterface/${getInterfaceId}`}>添加接口</Link></li>
|
||||
<li onClick={projectMember}>管理项目成员</li>
|
||||
</ul>
|
||||
<div className="interface-btngroup">
|
||||
<Link to={`/AddInterface/${getInterfaceId}`}><Button className="interface-btn" type="primary" icon="plus">添加接口</Button></Link>
|
||||
<Button className="interface-btn" type="primary" onClick={projectMember} icon="user">管理成员</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class InterfaceTable extends Component {
|
||||
|
||||
return (
|
||||
<section className="interface-table">
|
||||
<Table columns={columns} dataSource={data} />
|
||||
<Table bordered={true} columns={columns} dataSource={data} />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class UpDateModal extends Component {
|
||||
})(
|
||||
<Input placeholder="请输入环境域名" style={{ width: '90%', marginRight: 8 }} addonBefore={
|
||||
getFieldDecorator(`envs-protocol-${index}`, {
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[0]+'\/\/' : '',
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[0]+'\/\/' : 'http\:\/\/',
|
||||
rules: [{
|
||||
required: true
|
||||
}]
|
||||
@ -266,11 +266,14 @@ class UpDateModal extends Component {
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span={2}>
|
||||
{envs.length > 0 ? (
|
||||
{/* 新增的项中,只有最后一项有删除按钮 */}
|
||||
{ (envs.length > 0 && k._id) || (envs.length == index + 1) ? (
|
||||
<Icon
|
||||
className="dynamic-delete-button"
|
||||
type="minus-circle-o"
|
||||
onClick={() => this.remove(k._id ? k._id : k)}
|
||||
onClick={() => {
|
||||
return this.remove(k._id ? k._id : k);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</Col>
|
||||
|
@ -4,13 +4,14 @@ import interfaceModel from '../models/interface.js'
|
||||
import Mock from 'mockjs'
|
||||
|
||||
module.exports = async (ctx, next) => {
|
||||
yapi.commons.log('mock Server running...')
|
||||
yapi.commons.log('Server Recevie Request...')
|
||||
let hostname = ctx.hostname;
|
||||
let config = yapi.WEBCONFIG;
|
||||
if(ctx.hostname === config.webhost){
|
||||
if(next) await next();
|
||||
return true;
|
||||
}
|
||||
yapi.commons.log('MockServer Running...')
|
||||
let projectInst = yapi.getInst(projectModel), projects;
|
||||
try{
|
||||
projects = await projectInst.getByDomain(hostname);
|
||||
@ -18,10 +19,12 @@ module.exports = async (ctx, next) => {
|
||||
return ctx.body = yapi.commons.resReturn(null, 403, e.message);
|
||||
}
|
||||
|
||||
let matchProject = false, maxBasepath = 0;
|
||||
let matchProject = [], maxBasepath = 0;
|
||||
|
||||
for(let i=0, l = projects.length; i< l; i++){
|
||||
let project = projects[i];
|
||||
if(ctx.path && ctx.path.indexOf(project.basepath) === 0 && project.basepath[project.basepath.length -1] === '/'){
|
||||
|
||||
if(ctx.path && ctx.path.indexOf(project.basepath) === 0){
|
||||
matchProject.push(project);
|
||||
if(project.basepath.length > maxBasepath){
|
||||
maxBasepath = project.basepath.length;
|
||||
|
@ -34,7 +34,7 @@ module.exports = function () {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_yapi2.default.commons.log('mock Server running...');
|
||||
_yapi2.default.commons.log('Server Recevie Request...');
|
||||
hostname = ctx.hostname;
|
||||
config = _yapi2.default.WEBCONFIG;
|
||||
|
||||
@ -55,28 +55,31 @@ module.exports = function () {
|
||||
return _context.abrupt('return', true);
|
||||
|
||||
case 8:
|
||||
_yapi2.default.commons.log('MockServer Running...');
|
||||
projectInst = _yapi2.default.getInst(_project3.default), projects = void 0;
|
||||
_context.prev = 9;
|
||||
_context.next = 12;
|
||||
_context.prev = 10;
|
||||
_context.next = 13;
|
||||
return projectInst.getByDomain(hostname);
|
||||
|
||||
case 12:
|
||||
case 13:
|
||||
projects = _context.sent;
|
||||
_context.next = 18;
|
||||
_context.next = 19;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
_context.prev = 15;
|
||||
_context.t0 = _context['catch'](9);
|
||||
case 16:
|
||||
_context.prev = 16;
|
||||
_context.t0 = _context['catch'](10);
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 403, _context.t0.message));
|
||||
|
||||
case 18:
|
||||
matchProject = false, maxBasepath = 0;
|
||||
case 19:
|
||||
matchProject = [], maxBasepath = 0;
|
||||
|
||||
|
||||
for (i = 0, l = projects.length; i < l; i++) {
|
||||
_project = projects[i];
|
||||
|
||||
if (ctx.path && ctx.path.indexOf(_project.basepath) === 0 && _project.basepath[_project.basepath.length - 1] === '/') {
|
||||
|
||||
if (ctx.path && ctx.path.indexOf(_project.basepath) === 0) {
|
||||
matchProject.push(_project);
|
||||
if (_project.basepath.length > maxBasepath) {
|
||||
maxBasepath = _project.basepath.length;
|
||||
@ -86,62 +89,62 @@ module.exports = function () {
|
||||
}
|
||||
|
||||
if (!(matchProject === false)) {
|
||||
_context.next = 22;
|
||||
_context.next = 23;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '不存在的domain'));
|
||||
|
||||
case 22:
|
||||
case 23:
|
||||
project = matchProject, interfaceData = void 0;
|
||||
interfaceInst = _yapi2.default.getInst(_interface2.default);
|
||||
_context.prev = 24;
|
||||
_context.next = 27;
|
||||
_context.prev = 25;
|
||||
_context.next = 28;
|
||||
return interfaceInst.getByPath(project._id, ctx.path.substr(project.basepath.length));
|
||||
|
||||
case 27:
|
||||
case 28:
|
||||
interfaceData = _context.sent;
|
||||
|
||||
if (!(!interfaceData || interfaceData.length === 0)) {
|
||||
_context.next = 30;
|
||||
_context.next = 31;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 404, '不存在的api'));
|
||||
|
||||
case 30:
|
||||
case 31:
|
||||
if (!(interfaceData.length > 1)) {
|
||||
_context.next = 32;
|
||||
_context.next = 33;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '存在多个api,请检查数据库'));
|
||||
|
||||
case 32:
|
||||
case 33:
|
||||
|
||||
interfaceData = interfaceData[0];
|
||||
|
||||
if (!(interfaceData.res_body_type === 'json')) {
|
||||
_context.next = 35;
|
||||
_context.next = 36;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _mockjs2.default.mock(_yapi2.default.commons.json_parse(interfaceData.res_body)));
|
||||
|
||||
case 35:
|
||||
case 36:
|
||||
return _context.abrupt('return', ctx.body = interfaceData.res_body);
|
||||
|
||||
case 38:
|
||||
_context.prev = 38;
|
||||
_context.t1 = _context['catch'](24);
|
||||
case 39:
|
||||
_context.prev = 39;
|
||||
_context.t1 = _context['catch'](25);
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 409, _context.t1.message));
|
||||
|
||||
case 41:
|
||||
case 42:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, undefined, [[9, 15], [24, 38]]);
|
||||
}, _callee, undefined, [[10, 16], [25, 39]]);
|
||||
}));
|
||||
|
||||
return function (_x, _x2) {
|
||||
|
Loading…
Reference in New Issue
Block a user