mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-30 13:20:24 +08:00
Merge branch 'dev' of http://gitlab.corp.qunar.com/mfe/yapi into dev
This commit is contained in:
commit
39070b39a1
@ -6,7 +6,7 @@ import { autobind } from 'core-decorators';
|
||||
import crossRequest from 'cross-request';
|
||||
import mockEditor from '../../containers/Project/Interface/InterfaceList/mockEditor'
|
||||
import URL from 'url';
|
||||
|
||||
const MockExtra = require('common/mock-extra.js')
|
||||
import './Postman.scss'
|
||||
|
||||
const { TextArea } = Input;
|
||||
@ -158,8 +158,29 @@ export default class Run extends Component {
|
||||
}
|
||||
const { res_body, res_body_type } = this.props.data;
|
||||
let validRes = '';
|
||||
let query = {};
|
||||
this.state.query.forEach(item=>{
|
||||
query[item.name] = item.value;
|
||||
})
|
||||
let body = {};
|
||||
if(this.state.bodyType === 'form'){
|
||||
this.state.bodyForm.forEach(item=>{
|
||||
body[item.name] = item.value;
|
||||
})
|
||||
}else if(this.state.bodyType === 'json'){
|
||||
try{
|
||||
body = JSON.parse(this.state.bodyOther);
|
||||
}catch(e){
|
||||
body = {}
|
||||
}
|
||||
}
|
||||
if (res_body && res_body_type === 'json' && typeof res === 'object') {
|
||||
validRes = Mock.valid(JSON.parse(res_body), res)
|
||||
let tpl = MockExtra(JSON.parse(res_body), {
|
||||
query: query,
|
||||
body: body
|
||||
})
|
||||
console.log(tpl, this.state)
|
||||
validRes = Mock.valid(tpl, res)
|
||||
console.log(validRes)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import _ from 'underscore'
|
||||
import constants from '../../../../constants/variable.js'
|
||||
import { handlePath } from '../../../../common.js'
|
||||
|
||||
|
||||
import {
|
||||
Form, Select, Input, Tooltip,
|
||||
Button, Row, Col, Radio, Icon, AutoComplete, Switch
|
||||
@ -89,6 +90,7 @@ class InterfaceEditForm extends Component {
|
||||
if (!err) {
|
||||
if (values.res_body_type === 'json') values.res_body = this.state.res_body;
|
||||
values.method = this.state.method;
|
||||
values.req_params = values.req_params || [];
|
||||
let isfile = false, isHavaContentType = false;
|
||||
if (values.req_body_type === 'form') {
|
||||
values.req_body_form.forEach((item) => {
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
import { formatTime } from '../../../../common.js'
|
||||
import AddInterfaceForm from './AddInterfaceForm';
|
||||
import { fetchInterfaceList} from '../../../../reducer/modules/interface.js';
|
||||
import { Link } from 'react-router-dom';
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
@ -102,7 +103,10 @@ class InterfaceList extends Component {
|
||||
sorter: (a, b) => {
|
||||
return a.title.localeCompare(b.title) === 1
|
||||
},
|
||||
sortOrder: sortedInfo.columnKey === 'title' && sortedInfo.order
|
||||
sortOrder: sortedInfo.columnKey === 'title' && sortedInfo.order,
|
||||
render: (text, item)=>{
|
||||
return <Link to={"/project/" + item.project_id + "/interface/api/" + item._id} >{text}</Link>
|
||||
}
|
||||
}, {
|
||||
title: '接口路径',
|
||||
dataIndex: 'path',
|
||||
|
@ -18,7 +18,8 @@ const TreeNode = Tree.TreeNode;
|
||||
return {
|
||||
list: state.inter.list,
|
||||
inter: state.inter.curdata,
|
||||
curProject: state.project.currProject
|
||||
curProject: state.project.currProject,
|
||||
expands: []
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -73,7 +74,8 @@ class InterfaceMenu extends Component {
|
||||
add_cat_modal_visible: false,
|
||||
change_cat_modal_visible: false,
|
||||
del_cat_modal_visible: false,
|
||||
curCatdata: {}
|
||||
curCatdata: {},
|
||||
expands: null
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +99,9 @@ class InterfaceMenu extends Component {
|
||||
} else {
|
||||
history.push(basepath + '/' + curkey)
|
||||
}
|
||||
this.setState({
|
||||
expands: null
|
||||
})
|
||||
}
|
||||
|
||||
handleAddInterface = (data) => {
|
||||
@ -199,34 +204,42 @@ class InterfaceMenu extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
onExpand = (e)=>{
|
||||
this.setState({
|
||||
expands: e
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const matchParams = this.props.match.params;
|
||||
let menuList = this.props.list;
|
||||
|
||||
|
||||
if(menuList.length === 0){
|
||||
return null;
|
||||
}
|
||||
const defaultExpandedKeys = () => {
|
||||
const { router, inter, list } = this.props, rNull = { expands: [], selects: [] };
|
||||
if (list.length === 0) return rNull;
|
||||
if (list.length === 0){
|
||||
return rNull;
|
||||
}
|
||||
if (router) {
|
||||
if (!isNaN(router.params.actionId)) {
|
||||
let _actionId = parseInt(router.params.actionId, 10)
|
||||
if (!inter._id || inter._id !== _actionId) return rNull;
|
||||
if (!inter._id) {
|
||||
return rNull;
|
||||
}
|
||||
return {
|
||||
expands: ['cat_' + inter.catid],
|
||||
expands: this.state.expands ?this.state.expands : ['cat_' + inter.catid],
|
||||
selects: [inter._id + ""]
|
||||
}
|
||||
} else {
|
||||
let catid = router.params.actionId.substr(4);
|
||||
return {
|
||||
expands: ['cat_' + catid],
|
||||
expands: this.state.expands ?this.state.expands :['cat_' + catid],
|
||||
selects: ['cat_' + catid]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
expands: ['cat_' + list[0]._id],
|
||||
expands: this.state.expands ?this.state.expands :['cat_' + list[0]._id],
|
||||
selects: ['root']
|
||||
}
|
||||
}
|
||||
@ -279,6 +292,7 @@ class InterfaceMenu extends Component {
|
||||
|
||||
|
||||
let currentKes = defaultExpandedKeys();
|
||||
|
||||
if (this.state.filter) {
|
||||
let arr = [];
|
||||
menuList = this.props.list.filter(item => {
|
||||
@ -328,7 +342,10 @@ class InterfaceMenu extends Component {
|
||||
className="interface-list"
|
||||
defaultExpandedKeys={currentKes.expands}
|
||||
defaultSelectedKeys={currentKes.selects}
|
||||
expandedKeys={currentKes.expands}
|
||||
selectedKeys={currentKes.selects}
|
||||
onSelect={this.onSelect}
|
||||
onExpand={this.onExpand}
|
||||
>
|
||||
<TreeNode className="item-all-interface" title={<Link style={{ fontSize: '14px' }} to={"/project/" + matchParams.id + "/interface/api"}><Icon type="folder" style={{ marginRight: 5 }} />全部接口</Link>} key="root" />
|
||||
{menuList.map((item) => {
|
||||
|
@ -4,6 +4,7 @@ require('brace/mode/javascript');
|
||||
require('brace/theme/xcode');
|
||||
require("brace/ext/language_tools.js");
|
||||
var json5 = require('json5');
|
||||
const MockExtra = require('common/mock-extra.js')
|
||||
|
||||
var langTools = ace.acequire("ace/ext/language_tools"),
|
||||
wordList = [
|
||||
@ -67,7 +68,7 @@ function run(options) {
|
||||
curData.text = json;
|
||||
curData.format = true;
|
||||
curData.jsonData = obj;
|
||||
curData.mockData = Mock.mock(obj);
|
||||
curData.mockData = Mock.mock(MockExtra(obj, {}));
|
||||
curData.mockText = JSON.stringify(curData.mockData, null, " ");
|
||||
} catch (e) {
|
||||
curData.format = e.message;
|
||||
|
@ -1,70 +1,67 @@
|
||||
var mockjs = require('mockjs');
|
||||
var strRegex = /\${([a-zA-Z0-9_\.]+)\}/g
|
||||
var varSplit = ".";
|
||||
var mockSplit = "|";
|
||||
var strRegex = /\${([a-zA-Z0-9_\.]+)\}/g;
|
||||
var varSplit = '.';
|
||||
var mockSplit = '|';
|
||||
|
||||
function mock(mockJSON, context) {
|
||||
context = context || {};
|
||||
var filtersMap = {
|
||||
regexp: handleRegexp
|
||||
}
|
||||
return mockjs.mock(parse(mockJSON))
|
||||
context = context || {};
|
||||
var filtersMap = {
|
||||
regexp: handleRegexp
|
||||
};
|
||||
|
||||
function parse(p, c) {
|
||||
c = c || {};
|
||||
for (var i in p) {
|
||||
if (!p.hasOwnProperty(i)) {
|
||||
continue;
|
||||
}
|
||||
if (typeof p[i] === 'object') {
|
||||
c[i] = (p[i].constructor === Array) ? [] : {};
|
||||
parse(p[i], c[i]);
|
||||
} else {
|
||||
p[i] = handleStr(p[i]);
|
||||
var filters = i.split(mockSplit), newFilters = [].concat(filters);
|
||||
if (filters.length > 1) {
|
||||
for (var f = 1, l = filters.length, index; f < l; f++) {
|
||||
if (filters[f] in filtersMap) {
|
||||
if ((index = newFilters.indexOf(filters[f])) !== -1) {
|
||||
newFilters.splice(index, 1);
|
||||
}
|
||||
c[newFilters.join(mockSplit)] = filtersMap[filters[f]].call(p, p[i])
|
||||
return parse(mockJSON);
|
||||
|
||||
function parse(p, c) {
|
||||
c = c || {};
|
||||
for (var i in p) {
|
||||
if (!p.hasOwnProperty(i)) {
|
||||
continue;
|
||||
}
|
||||
if (typeof p[i] === 'object') {
|
||||
c[i] = (p[i].constructor === Array) ? [] : {};
|
||||
parse(p[i], c[i]);
|
||||
} else {
|
||||
p[i] = handleStr(p[i]);
|
||||
var filters = i.split(mockSplit), newFilters = [].concat(filters);
|
||||
c[i] = p[i];
|
||||
if (filters.length > 1) {
|
||||
for (var f = 1, l = filters.length, index; f < l; f++) {
|
||||
if (filters[f] in filtersMap) {
|
||||
if ((index = newFilters.indexOf(filters[f])) !== -1) {
|
||||
newFilters.splice(index, 1);
|
||||
}
|
||||
delete c[i];
|
||||
c[newFilters.join(mockSplit)] = filtersMap[filters[f]].call(p, p[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c[i] = p[i]
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
function handleRegexp(item) {
|
||||
return new RegExp(item)
|
||||
}
|
||||
|
||||
function handleStr(str) {
|
||||
if(typeof str !== 'string' ||str.indexOf("{") === -1 || str.indexOf("}") === -1 || str.indexOf("$") === -1){
|
||||
return str;
|
||||
function handleRegexp(item) {
|
||||
return new RegExp(item);
|
||||
}
|
||||
str = str.replace(strRegex, function (matchs, name) {
|
||||
var names = name.split(varSplit);
|
||||
var data = context;
|
||||
names.forEach(function(n){
|
||||
if(data === false) return false;
|
||||
if(n in data){
|
||||
data = data[n];
|
||||
}else{
|
||||
data = false;
|
||||
|
||||
function handleStr(str) {
|
||||
if (typeof str !== 'string' || str.indexOf('{') === -1 || str.indexOf('}') === -1 || str.indexOf('$') === -1) {
|
||||
return str;
|
||||
}
|
||||
})
|
||||
if(data === false){
|
||||
return matchs;
|
||||
}
|
||||
return data;
|
||||
})
|
||||
return str;
|
||||
}
|
||||
str = str.replace(strRegex, function (matchs, name) {
|
||||
var names = name.split(varSplit);
|
||||
var data = context;
|
||||
names.forEach(function (n) {
|
||||
if (data === '') return '';
|
||||
if (n in data) {
|
||||
data = data[n];
|
||||
} else {
|
||||
data = '';
|
||||
}
|
||||
});
|
||||
return data;
|
||||
});
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mock;
|
@ -352,6 +352,7 @@ class interfaceController extends baseController {
|
||||
data.req_params = params.req_params;
|
||||
} else {
|
||||
data.type = 'static'
|
||||
data.req_params = [];
|
||||
}
|
||||
|
||||
if (!_.isUndefined(params.req_query)) {
|
||||
|
@ -471,6 +471,9 @@ class projectController extends baseController {
|
||||
async upSet(ctx) {
|
||||
let id = ctx.request.body.id;
|
||||
let data = {};
|
||||
if (await this.checkAuth(id, 'project', 'danger') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
data.color = ctx.request.body.color;
|
||||
data.icon = ctx.request.body.icon;
|
||||
if (!id) {
|
||||
|
@ -3,6 +3,7 @@ import projectModel from '../models/project.js';
|
||||
import interfaceModel from '../models/interface.js';
|
||||
import mockExtra from '../../common/mock-extra.js';
|
||||
import _ from 'underscore';
|
||||
import Mock from 'mockjs';
|
||||
|
||||
|
||||
function matchApi(apiPath, apiRule) {
|
||||
@ -96,7 +97,9 @@ module.exports = async (ctx, next) => {
|
||||
body: ctx.request.body
|
||||
}
|
||||
);
|
||||
return ctx.body = res;
|
||||
console.log(interfaceData.res_body);
|
||||
console.log(res)
|
||||
return ctx.body = Mock.mock(res);
|
||||
} catch (e) {
|
||||
yapi.commons.log(e, 'error')
|
||||
return ctx.body = {
|
||||
|
@ -72,7 +72,7 @@ app.use(compress({
|
||||
}));
|
||||
|
||||
app.use(function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
|
@ -128,7 +128,7 @@ var interfaceController = function (_baseController) {
|
||||
(0, _createClass3.default)(interfaceController, [{
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _this2 = this;
|
||||
|
||||
var params, auth, checkRepeat, data, paths, name, i, result;
|
||||
@ -324,7 +324,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'get',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, result;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -386,7 +386,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var project_id, result;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
@ -436,7 +436,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'listByCat',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var catid, result;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
@ -486,7 +486,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'listByMenu',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var project_id, result, newResult, i, item, list, j;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
@ -591,7 +591,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _this3 = this;
|
||||
|
||||
var params, id, interfaceData, auth, checkRepeat, data, result, username, cateid, project, interfaceUrl;
|
||||
@ -706,6 +706,7 @@ var interfaceController = function (_baseController) {
|
||||
data.req_params = params.req_params;
|
||||
} else {
|
||||
data.type = 'static';
|
||||
data.req_params = [];
|
||||
}
|
||||
|
||||
if (!_underscore2.default.isUndefined(params.req_query)) {
|
||||
@ -820,7 +821,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _this4 = this;
|
||||
|
||||
var id, data, auth, inter, result, username;
|
||||
@ -917,7 +918,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'solveConflict',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _this5 = this;
|
||||
|
||||
var id, result, userInst, userinfo, data;
|
||||
@ -1000,7 +1001,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addCat',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, auth, result, username;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
@ -1095,7 +1096,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upCat',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var params, result, username, cate, auth;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
@ -1167,7 +1168,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delCat',
|
||||
value: function () {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var id, catData, auth, username, result, r;
|
||||
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
||||
while (1) {
|
||||
@ -1279,7 +1280,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'interUpload',
|
||||
value: function () {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var _this6 = this;
|
||||
|
||||
var interData, project_id, request, data1, catid, auth, len, successNum, i, path, reg, title, inter, _data, item, queryParams, _item, headerData, _item2, checkRepeat, data, res;
|
||||
@ -1551,7 +1552,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getCatMenu',
|
||||
value: function () {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var project_id, res;
|
||||
return _regenerator2.default.wrap(function _callee13$(_context13) {
|
||||
while (1) {
|
||||
|
@ -148,7 +148,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, data, result, colInst, catInst, username;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -320,7 +320,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addMember',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, check, userdata, result, username;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -443,7 +443,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delMember',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _this2 = this;
|
||||
|
||||
var params, check, result, username;
|
||||
@ -541,7 +541,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getUserdata',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(uid, role) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(uid, role) {
|
||||
var userInst, userData;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
@ -599,7 +599,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getMemberList',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var params, project;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
@ -661,7 +661,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'get',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var params, result, catInst, cat;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
@ -746,7 +746,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _this3 = this;
|
||||
|
||||
var group_id, project_list, auth, result, follow, _loop, index, item, r, _ret;
|
||||
@ -781,7 +781,7 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 12:
|
||||
follow = _context8.sent;
|
||||
_loop = _regenerator2.default.mark(function _loop(index, _item, _r) {
|
||||
_loop = /*#__PURE__*/_regenerator2.default.mark(function _loop(index, _item, _r) {
|
||||
var f;
|
||||
return _regenerator2.default.wrap(function _loop$(_context7) {
|
||||
while (1) {
|
||||
@ -898,7 +898,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var id, interfaceInst, interfaceColInst, interfaceCaseInst, result;
|
||||
return _regenerator2.default.wrap(function _callee8$(_context9) {
|
||||
while (1) {
|
||||
@ -991,7 +991,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'changeMemberRole',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var _this4 = this;
|
||||
|
||||
var params, projectInst, check, result, username;
|
||||
@ -1107,7 +1107,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upSet',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _this5 = this;
|
||||
|
||||
var id, data, result;
|
||||
@ -1117,36 +1117,49 @@ var projectController = function (_baseController) {
|
||||
case 0:
|
||||
id = ctx.request.body.id;
|
||||
data = {};
|
||||
_context11.next = 4;
|
||||
return this.checkAuth(id, 'project', 'danger');
|
||||
|
||||
case 4:
|
||||
_context11.t0 = _context11.sent;
|
||||
|
||||
if (!(_context11.t0 !== true)) {
|
||||
_context11.next = 7;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
||||
|
||||
case 7:
|
||||
data.color = ctx.request.body.color;
|
||||
data.icon = ctx.request.body.icon;
|
||||
|
||||
if (id) {
|
||||
_context11.next = 6;
|
||||
_context11.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 6:
|
||||
_context11.prev = 6;
|
||||
_context11.next = 9;
|
||||
case 11:
|
||||
_context11.prev = 11;
|
||||
_context11.next = 14;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
result = _context11.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context11.next = 16;
|
||||
_context11.next = 21;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context11.prev = 13;
|
||||
_context11.t0 = _context11['catch'](6);
|
||||
case 18:
|
||||
_context11.prev = 18;
|
||||
_context11.t1 = _context11['catch'](11);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t0.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t1.message);
|
||||
|
||||
case 16:
|
||||
case 21:
|
||||
try {
|
||||
this.followModel.updateById(this.getUid(), id, data).then(function () {
|
||||
var username = _this5.getUsername();
|
||||
@ -1162,12 +1175,12 @@ var projectController = function (_baseController) {
|
||||
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
|
||||
case 17:
|
||||
case 22:
|
||||
case 'end':
|
||||
return _context11.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[6, 13]]);
|
||||
}, _callee10, this, [[11, 18]]);
|
||||
}));
|
||||
|
||||
function upSet(_x11) {
|
||||
@ -1197,7 +1210,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var id, params, projectData, checkRepeat, data, result, username;
|
||||
return _regenerator2.default.wrap(function _callee11$(_context12) {
|
||||
while (1) {
|
||||
@ -1344,7 +1357,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'search',
|
||||
value: function () {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var q, projectList, groupList, projectRules, groupRules, queryList;
|
||||
return _regenerator2.default.wrap(function _callee12$(_context13) {
|
||||
while (1) {
|
||||
@ -1419,7 +1432,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'download',
|
||||
value: function () {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var project_id, interfaceInst, count, arr, fileName, res;
|
||||
return _regenerator2.default.wrap(function _callee13$(_context14) {
|
||||
while (1) {
|
||||
|
@ -28,6 +28,10 @@ var _underscore = require('underscore');
|
||||
|
||||
var _underscore2 = _interopRequireDefault(_underscore);
|
||||
|
||||
var _mockjs = require('mockjs');
|
||||
|
||||
var _mockjs2 = _interopRequireDefault(_mockjs);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function matchApi(apiPath, apiRule) {
|
||||
@ -47,7 +51,7 @@ function matchApi(apiPath, apiRule) {
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var hostname, config, path, paths, projectId, projectInst, project, interfaceData, newData, newpath, interfaceInst, _newData, findInterface, res;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
@ -180,7 +184,7 @@ module.exports = function () {
|
||||
ctx.set("Access-Control-Allow-Origin", "*");
|
||||
|
||||
if (!(interfaceData.res_body_type === 'json')) {
|
||||
_context.next = 64;
|
||||
_context.next = 66;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -189,10 +193,13 @@ module.exports = function () {
|
||||
query: ctx.request.query,
|
||||
body: ctx.request.body
|
||||
});
|
||||
return _context.abrupt('return', ctx.body = res);
|
||||
|
||||
case 60:
|
||||
_context.prev = 60;
|
||||
console.log(interfaceData.res_body);
|
||||
console.log(res);
|
||||
return _context.abrupt('return', ctx.body = _mockjs2.default.mock(res));
|
||||
|
||||
case 62:
|
||||
_context.prev = 62;
|
||||
_context.t2 = _context['catch'](55);
|
||||
|
||||
_yapi2.default.commons.log(_context.t2, 'error');
|
||||
@ -202,22 +209,22 @@ module.exports = function () {
|
||||
data: interfaceData.res_body
|
||||
});
|
||||
|
||||
case 64:
|
||||
case 66:
|
||||
return _context.abrupt('return', ctx.body = interfaceData.res_body);
|
||||
|
||||
case 67:
|
||||
_context.prev = 67;
|
||||
case 69:
|
||||
_context.prev = 69;
|
||||
_context.t3 = _context['catch'](30);
|
||||
|
||||
console.error(_context.t3);
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 409, _context.t3.message));
|
||||
|
||||
case 71:
|
||||
case 73:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, undefined, [[17, 23], [30, 67], [55, 60]]);
|
||||
}, _callee, undefined, [[17, 23], [30, 69], [55, 62]]);
|
||||
}));
|
||||
|
||||
return function (_x, _x2) {
|
||||
|
@ -363,7 +363,7 @@ function createAction(controller, action, path, method) {
|
||||
var _this = this;
|
||||
|
||||
router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var inst;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
|
6
ykit.js
6
ykit.js
@ -92,7 +92,8 @@ module.exports = {
|
||||
exports: [
|
||||
'./index.js'
|
||||
],
|
||||
modifyWebpackConfig: function (baseConfig) {
|
||||
modifyWebpackConfig: function (baseConfig) {
|
||||
|
||||
var ENV_PARAMS = {};
|
||||
switch (this.env) {
|
||||
case 'local':
|
||||
@ -113,7 +114,8 @@ module.exports = {
|
||||
|
||||
//初始化配置
|
||||
baseConfig.devtool = 'cheap-module-eval-source-map'
|
||||
baseConfig.context = path.resolve(__dirname, "client");
|
||||
baseConfig.context = path.resolve(__dirname, './client');
|
||||
baseConfig.resolve.alias.common = '/common';
|
||||
baseConfig.output.prd.path = 'static/prd';
|
||||
baseConfig.output.prd.publicPath = '';
|
||||
baseConfig.output.prd.filename = '[name]@[chunkhash][ext]'
|
||||
|
Loading…
Reference in New Issue
Block a user