fix: 修复分组名称显示错误的bug

This commit is contained in:
wenbo.dong 2017-08-25 18:00:53 +08:00
parent 6a417b68b1
commit 8e93a3e46a
14 changed files with 5260 additions and 224 deletions

View File

@ -121,7 +121,7 @@ class ProjectList extends Component {
}]
})(
<Select>
{this.state.groupList.map((item, index) => <Option value={item._id.toString() + ':' + this.state.groupList[0].group_name} key={index}>{item.group_name}</Option>)}
{this.state.groupList.map((item, index) => <Option value={item._id.toString() + ':' + this.state.groupList[index].group_name} key={index}>{item.group_name}</Option>)}
</Select>
)}
</FormItem>

View File

@ -88,7 +88,7 @@ var groupController = function (_baseController) {
(0, _createClass3.default)(groupController, [{
key: 'get',
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, groupInst, result;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
@ -160,7 +160,7 @@ var groupController = function (_baseController) {
}, {
key: 'add',
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, groupUserdata, groupInst, checkRepeat, data, result;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
@ -272,7 +272,7 @@ var groupController = function (_baseController) {
}, {
key: 'getUserdata',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(uid, role) {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(uid, role) {
var userInst, userData;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
@ -333,7 +333,7 @@ var groupController = function (_baseController) {
}, {
key: 'addMember',
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 params, groupInst, check, groupUserdata, result;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
@ -446,7 +446,7 @@ var groupController = function (_baseController) {
}, {
key: 'changeMemberRole',
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, groupInst, check, result;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
@ -547,7 +547,7 @@ var groupController = function (_baseController) {
}, {
key: 'getMemberList',
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, groupInst, group;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
@ -611,7 +611,7 @@ var groupController = function (_baseController) {
}, {
key: 'delMember',
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 params, groupInst, check, result;
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
@ -709,7 +709,7 @@ var groupController = function (_baseController) {
}, {
key: 'list',
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 groupInst, result;
return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) {
@ -762,7 +762,7 @@ var groupController = function (_baseController) {
}, {
key: 'del',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var _this2 = this;
var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, id, projectList, result;
@ -801,7 +801,7 @@ var groupController = function (_baseController) {
projectList = _context10.sent;
projectList.forEach(function () {
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(p) {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(p) {
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
@ -880,7 +880,7 @@ var groupController = 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 groupInst, id, data, result;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,9 @@
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 首页</title>
<link rel="stylesheet" href="source/main.css" />
<link rel="stylesheet" href="source/main.css" />
</head>
<body>
<div class="ydoc">
@ -74,7 +76,7 @@
<div class="ydoc-container">
<div class="ydoc-container-content" id="readme">
<div class="ydoc-container-content ydoc-container-home" id="readme">
<h1 class="home-page-title">为API开发者设计的管理平台</h1>
@ -149,7 +151,7 @@
<script src="source/app.js"></script>
<script>
var lineHeight = 17.4;
var lineHeight = 18;
var EXAMPLE_MAX_HEIGHT;
function fold() {
@ -173,8 +175,8 @@
var $this = $(this);
$this.removeClass('extend').addClass('fold');
$this.html('折叠代码');
$this.prev().height('auto');
$this.prev().parent().height('auto');
$this.parent().children('.js-code').height('auto');
$this.parent().height('auto');
});
$('.ydoc-example').delegate('.fold', 'click', function() {
var $this = $(this);
@ -182,7 +184,7 @@
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
$this.removeClass('fold').addClass('extend');
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
$this.html("展开更多……");
});
}

View File

@ -9,7 +9,9 @@
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi Mock功能</title>
<link rel="stylesheet" href="source/main.css" />
<link rel="stylesheet" href="source/main.css" />
</head>
<body>
<div class="ydoc">
@ -63,7 +65,7 @@
<div class="ydoc-container">
<div class="ydoc-container-content" id="readme">
<div class="ydoc-container-content " id="readme">
<article class="markdown-body">
<h2 class="subject" id="Mock介绍">Mock介绍 <a class="hashlink" href="#Mock介绍">#</a></h2><p> <p style='text-indent:2em;line-height:1.8em'>yapi的Mock功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、mock规则(<a href="#mock">点击到Mock规则</a>生成Mock接口这些接口会自动生成模拟数据创建者可以自由构造需要的数据。而且与常见的Mock方式如将Mock写在代码里和JS拦截等相比yapi的Mock在使用场景和效率和复杂度上是相差甚远的正是由于yapi的Mock是一个第三方平台那么在团队开发时任何人都可以权限许可下创建、修改接口信息等操作这对于团队开发是很有好处的。</p>
@ -71,29 +73,29 @@
<p>项目id可以在项目设置里查看到</p>
<p> </p>
<img src="./images/mock.jpg" style="width: 50%" /></p>
<h3 class="subject" id="1 如何使用Mock?">1 如何使用Mock? <a class="hashlink" href="#1 如何使用Mock?">#</a></h3><h3 class="subject" id="1.1 最简单最直接的方式">1.1 最简单最直接的方式 <a class="hashlink" href="#1.1 最简单最直接的方式">#</a></h3><p>在代码直接请求yapi提供的mock地址以jQuery为例</p>
<h3 class="subject" id="1_如何使用Mock?">1 如何使用Mock? <a class="hashlink" href="#1_如何使用Mock?">#</a></h3><h3 class="subject" id="1.1_最简单最直接的方式">1.1 最简单最直接的方式 <a class="hashlink" href="#1.1_最简单最直接的方式">#</a></h3><p>在代码直接请求yapi提供的mock地址以jQuery为例</p>
<pre><code class="lang-javascript"><span class="token keyword">let</span> prefix <span class="token operator">=</span> <span class="token string">'http://yapi.local.qunar.com:3000/mock/2817'</span>
$<span class="token punctuation">.</span><span class="token function">post</span><span class="token punctuation">(</span>prefix<span class="token operator">+</span><span class="token string">'/baseapi/path'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>username<span class="token punctuation">:</span> <span class="token string">'xxx'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token punctuation">{</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span> <span class="token comment" spellcheck="true">//返回上图预览部分的数据</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre>
<h3 class="subject" id="1.2 基于本地服务器反向代理">1.2 基于本地服务器反向代理 <a class="hashlink" href="#1.2 基于本地服务器反向代理">#</a></h3><p>优点:不用修改项目代码</p>
<h4 class="subject" id="1.2.1 基于nginx反向代理">1.2.1 基于nginx反向代理 <a class="hashlink" href="#1.2.1 基于nginx反向代理">#</a></h4><pre><code class="lang-nginx"><span class="token keyword">location</span> <span class="token operator">/</span>baseapi
<h3 class="subject" id="1.2_基于本地服务器反向代理">1.2 基于本地服务器反向代理 <a class="hashlink" href="#1.2_基于本地服务器反向代理">#</a></h3><p>优点:不用修改项目代码</p>
<h4 class="subject" id="1.2.1_基于nginx反向代理">1.2.1 基于nginx反向代理 <a class="hashlink" href="#1.2.1_基于nginx反向代理">#</a></h4><pre><code class="lang-nginx"><span class="token keyword">location</span> <span class="token operator">/</span>baseapi
<span class="token punctuation">{</span>
<span class="token keyword">proxy_pass</span> <span class="token keyword">http</span><span class="token punctuation">:</span><span class="token operator">/</span><span class="token operator">/</span>yapi<span class="token punctuation">.</span>local<span class="token punctuation">.</span>qunar<span class="token punctuation">.</span>com<span class="token punctuation">:</span><span class="token number">3000</span><span class="token operator">/</span>mock<span class="token operator">/</span><span class="token number">2817</span><span class="token operator">/</span>baseapi<span class="token punctuation">;</span> <span class="token comment" spellcheck="true">#baseapi后面没有"/"</span>
<span class="token punctuation">}</span>
</code></pre>
<h4 class="subject" id="1.2.2 基于ykit Jerry代理">1.2.2 基于ykit Jerry代理 <a class="hashlink" href="#1.2.2 基于ykit Jerry代理">#</a></h4><p>假设您本地服务器访问地址是: <a href="http://xxx.com">http://xxx.com</a></p>
<h4 class="subject" id="1.2.2_基于ykit_Jerry代理">1.2.2 基于ykit Jerry代理 <a class="hashlink" href="#1.2.2_基于ykit_Jerry代理">#</a></h4><p>假设您本地服务器访问地址是: <a href="http://xxx.com">http://xxx.com</a></p>
<p><img src="./images/ykit.jpg" /></p>
<p><span id = "mock"></span></p>
<h3 class="subject" id="2.1 Mock语法规范">2.1 Mock语法规范 <a class="hashlink" href="#2.1 Mock语法规范">#</a></h3><blockquote>
<h3 class="subject" id="2.1_Mock语法规范">2.1 Mock语法规范 <a class="hashlink" href="#2.1_Mock语法规范">#</a></h3><blockquote>
<p>了解更多Mock详情<a href="https://github.com/nuysoft/Mock/wiki/Syntax-Specification">Mock.js 官方文档</a></p>
</blockquote>
<p>Mock.js 的语法规范包括两部分:</p>
<p><a href="#DTD">1. 数据模板定义规范Data Template DefinitionDTD</a></p>
<p><a href="#DPD">2. 数据占位符定义规范Data Placeholder DefinitionDPD</a></p>
<p><span id = "DTD"></span></p>
<h3 class="subject" id="数据模板定义规范Data Template DefinitionDTD">数据模板定义规范Data Template DefinitionDTD <a class="hashlink" href="#数据模板定义规范Data Template DefinitionDTD">#</a></h3><p>数据模板中的每个属性由 3 部分构成:属性名、生成规则、属性值:</p>
<h3 class="subject" id="数据模板定义规范Data_Template_DefinitionDTD">数据模板定义规范Data Template DefinitionDTD <a class="hashlink" href="#数据模板定义规范Data_Template_DefinitionDTD">#</a></h3><p>数据模板中的每个属性由 3 部分构成:属性名、生成规则、属性值:</p>
<pre><code>// 属性名 name (与生成规则之间用 "|<span class="token string">" 隔开)
// 生成规则 rule生成规则有7种详见下面的生成规则
// 属性值 value可以含有 "</span>@占位符" 同时也指定了最终值的初始值和类型)
@ -109,14 +111,14 @@ $<span class="token punctuation">.</span><span class="token function">post</span
'name|count.dcount'<span class="token operator">:</span> value
'name|+step'<span class="token operator">:</span> value
</code></pre><p>下面提供了6种生成规则以及示例包括 String、Number、Boolean、Object、Array</p>
<h4 class="subject" id="1. 属性值是字符串 String">1. 属性值是字符串 String <a class="hashlink" href="#1. 属性值是字符串 String">#</a></h4><pre><code><span class="token number">1</span>. 'name|min-max'<span class="token operator">:</span> string
<h4 class="subject" id="1._属性值是字符串_String">1. 属性值是字符串 String <a class="hashlink" href="#1._属性值是字符串_String">#</a></h4><pre><code><span class="token number">1</span>. 'name|min-max'<span class="token operator">:</span> string
通过重复 string 生成一个字符串,重复次数大于等于 min小于等于 max。
<span class="token number">2</span>. 'name|count'<span class="token operator">:</span> string
通过重复 string 生成一个字符串,重复次数等于 count。
</code></pre><h4 class="subject" id="2. 属性值是数字 Number">2. 属性值是数字 Number <a class="hashlink" href="#2. 属性值是数字 Number">#</a></h4><pre><code><span class="token number">1</span>. 'name|+<span class="token number">1</span>'<span class="token operator">:</span> number
</code></pre><h4 class="subject" id="2._属性值是数字_Number">2. 属性值是数字 Number <a class="hashlink" href="#2._属性值是数字_Number">#</a></h4><pre><code><span class="token number">1</span>. 'name|+<span class="token number">1</span>'<span class="token operator">:</span> number
属性值自动加 <span class="token number">1</span>,初始值为 number。
@ -142,21 +144,21 @@ Mock.mock(<span class="token punctuation">{</span>
<span class="token property">"number3"</span><span class="token operator">:</span> <span class="token number">123.777</span><span class="token punctuation">,</span>
<span class="token property">"number4"</span><span class="token operator">:</span> <span class="token number">123.1231091814</span>
<span class="token punctuation">}</span>
</code></pre><h4 class="subject" id="3. 属性值是布尔型 Boolean">3. 属性值是布尔型 Boolean <a class="hashlink" href="#3. 属性值是布尔型 Boolean">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> boolean
</code></pre><h4 class="subject" id="3._属性值是布尔型_Boolean">3. 属性值是布尔型 Boolean <a class="hashlink" href="#3._属性值是布尔型_Boolean">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> boolean
随机生成一个布尔值,值为 <span class="token boolean">true</span> 的概率是 <span class="token number">1</span>/<span class="token number">2</span>,值为 <span class="token boolean">false</span> 的概率同样是 <span class="token number">1</span>/<span class="token number">2</span>
<span class="token number">2</span>. 'name|min-max'<span class="token operator">:</span> value
随机生成一个布尔值,值为 value 的概率是 min / (min + max<span class="token punctuation">)</span>,值为 !value 的概率是 max / (min + max<span class="token punctuation">)</span>
</code></pre><h4 class="subject" id="4. 属性值是对象 Object">4. 属性值是对象 Object <a class="hashlink" href="#4. 属性值是对象 Object">#</a></h4><pre><code><span class="token number">1</span>. 'name|count'<span class="token operator">:</span> object
</code></pre><h4 class="subject" id="4._属性值是对象_Object">4. 属性值是对象 Object <a class="hashlink" href="#4._属性值是对象_Object">#</a></h4><pre><code><span class="token number">1</span>. 'name|count'<span class="token operator">:</span> object
从属性值 object 中随机选取 count 个属性。
<span class="token number">2</span>. 'name|min-max'<span class="token operator">:</span> object
从属性值 object 中随机选取 min 到 max 个属性。
</code></pre><h4 class="subject" id="5. 属性值是数组 Array">5. 属性值是数组 Array <a class="hashlink" href="#5. 属性值是数组 Array">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> array
</code></pre><h4 class="subject" id="5._属性值是数组_Array">5. 属性值是数组 Array <a class="hashlink" href="#5._属性值是数组_Array">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> array
从属性值 array 中随机选取 <span class="token number">1</span> 个元素,作为最终值。
@ -172,7 +174,7 @@ Mock.mock(<span class="token punctuation">{</span>
通过重复属性值 array 生成一个新数组,重复次数为 count。
</code></pre><p><span id = "DPD"></span></p>
<h3 class="subject" id="数据占位符定义规范Data Placeholder DefinitionDPD">数据占位符定义规范Data Placeholder DefinitionDPD <a class="hashlink" href="#数据占位符定义规范Data Placeholder DefinitionDPD">#</a></h3><pre><code>占位符 只是在属性值字符串中占个位置,并不出现在最终的属性值中。
<h3 class="subject" id="数据占位符定义规范Data_Placeholder_DefinitionDPD">数据占位符定义规范Data Placeholder DefinitionDPD <a class="hashlink" href="#数据占位符定义规范Data_Placeholder_DefinitionDPD">#</a></h3><pre><code>占位符 只是在属性值字符串中占个位置,并不出现在最终的属性值中。
占位符 的格式为:
@ -216,7 +218,7 @@ name<span class="token operator">:</span> <span class="token punctuation">{</spa
<script src="source/app.js"></script>
<script>
var lineHeight = 17.4;
var lineHeight = 18;
var EXAMPLE_MAX_HEIGHT;
function fold() {
@ -240,8 +242,8 @@ name<span class="token operator">:</span> <span class="token punctuation">{</spa
var $this = $(this);
$this.removeClass('extend').addClass('fold');
$this.html('折叠代码');
$this.prev().height('auto');
$this.prev().parent().height('auto');
$this.parent().children('.js-code').height('auto');
$this.parent().height('auto');
});
$('.ydoc-example').delegate('.fold', 'click', function() {
var $this = $(this);
@ -249,7 +251,7 @@ name<span class="token operator">:</span> <span class="token punctuation">{</spa
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
$this.removeClass('fold').addClass('extend');
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
$this.html("展开更多……");
});
}

View File

@ -129,26 +129,10 @@ $(document).ready(function() {
});
$('.markdown-body pre').map(function(i, item) {
$(item).addClass('ydoc-example');
$(item).addClass('ydoc-example').append('<div class="ui-copy js-copy" data-clipboard-action="copy" data-clipboard-target=".js-code-' + i + '" data-copy-number="' + i + '">copy</div><div class="copy-tip copy-tip-' + i + '">已复制</div>');
$(item).children('code').addClass('js-code-'+i);
});
// $('code').each(function(i, block) {
// if (block.innerHTML.indexOf('\n') != -1) {
// var pn = block.parentNode;
// if (pn.tagName.toUpperCase() == 'PRE') {
// try {
// hljs.highlightBlock(block);
// } catch(e) {}
// } else {
// pn.innerHTML = '<pre><code>' + block.innerHTML + '</code></pre>';
// try {
// hljs.highlightBlock(pn.childNodes[0].childNodes[0]);
// } catch(e) {}
// }
// }
// });
var winHeight = $(window).height() - 44,
sidebar = $('.docs-sidebar');
var docSideNav = $('.docs-sidenav');
@ -205,46 +189,9 @@ $(document).ready(function() {
// 退出全屏浏览器窗口大小改变不触发resize
$(window).on('resize', function(e) {
resizeSidebar();
$contentLeftWidth = $contentLeft.width() - 1;
});
function resizeSidebar() {
var winHeight = $(window).height() - 44,
sidebar = $('.docs-sidebar');
var docSideNav = $('.docs-sidenav');
if (winWidth > 767) {
docSideNav.width($contentLeftWidth);
}
if (sidebar.height() > winHeight) {
sidebar.css('max-height', winHeight + 'px');
$('.docs-sidenav').css('max-height', winHeight + 'px');
$('.docs-sidenav').css({
'overflow-y': 'scroll',
'overflow-x': 'hidden'
});
var barScroll = false;
sidebar.on('mouseover', function() {
barScroll = true;
});
sidebar.on('mouseout', function() {
barScroll = false;
});
// scroll
if ($(window).scrollTop() > ($('.footer').offset().top - $(window).height())) {
winHeight = $(window).height() - $('.footer').outerHeight() - 44;
sidebar.css('max-height', winHeight + 'px');
$('.docs-sidenav').css('max-height', winHeight + 'px');
} else {
winHeight = $(window).height() - 44;
sidebar.css('max-height', winHeight + 'px');
$('.docs-sidenav').css('max-height', winHeight + 'px');
}
}
}
function sortAsOffset(propertyName) {
return function(obj1, obj2) {
var val1 = obj1[propertyName];
@ -267,4 +214,17 @@ $(document).ready(function() {
return false;
}
}
// 代码复制功能
var clipboard = new Clipboard('.js-copy');
clipboard.on('success', function(e) {
var copyNumber = $(e.trigger).attr('data-copy-number');
$('.copy-tip-'+copyNumber).show();
setTimeout(function() {
$('.copy-tip-'+copyNumber).hide();
}, 1000);
e.clearSelection();
});
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,9 @@
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 快速开始</title>
<link rel="stylesheet" href="source/main.css" />
<link rel="stylesheet" href="source/main.css" />
</head>
<body>
<div class="ydoc">
@ -63,23 +65,23 @@
<div class="ydoc-container">
<div class="ydoc-container-content" id="readme">
<div class="ydoc-container-content " id="readme">
<article class="markdown-body">
<h2 class="subject" id="快速开始">快速开始 <a class="hashlink" href="#快速开始">#</a></h2><h3 class="subject" id="1 创建项目分组">1 创建项目分组 <a class="hashlink" href="#1 创建项目分组">#</a></h3><p>登录之后进到项目首页,左边侧边栏显示的即分组列表。</p>
<h2 class="subject" id="快速开始">快速开始 <a class="hashlink" href="#快速开始">#</a></h2><h3 class="subject" id="1_创建项目分组">1 创建项目分组 <a class="hashlink" href="#1_创建项目分组">#</a></h3><p>登录之后进到项目首页,左边侧边栏显示的即分组列表。</p>
<p><img src="./images/project_group.png" width = "200" style="margin-left:170px;display:block;" alt="图片名称" align=center /></p>
<p>联系管理员添加分组并且把你设置为组长或让组长邀请你加入到某项目分组</p>
<h4 class="subject" id="2 项目列表">2 项目列表 <a class="hashlink" href="#2 项目列表">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
<h4 class="subject" id="2_项目列表">2 项目列表 <a class="hashlink" href="#2_项目列表">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
<p><img src="./images/project_list.png" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<h3 class="subject" id="3 添加项目">3 添加项目 <a class="hashlink" href="#3 添加项目">#</a></h3><h4 class="subject" id="3.1 点击右上角的“+“号进入添加项目页面">3.1 点击右上角的“+“号进入添加项目页面 <a class="hashlink" href="#3.1 点击右上角的“+“号进入添加项目页面">#</a></h4><p><img src="./images/project_add.png" width = "100%" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<h4 class="subject" id="3.2 添加项目页面">3.2 添加项目页面 <a class="hashlink" href="#3.2 添加项目页面">#</a></h4><p><img src="./images/project_add_view.png" width = "100%" style="margin:0px auto;display:block;" alt="图片名称" align=center />
<h3 class="subject" id="3_添加项目">3 添加项目 <a class="hashlink" href="#3_添加项目">#</a></h3><h4 class="subject" id="3.1_点击右上角的“+“号进入添加项目页面">3.1 点击右上角的“+“号进入添加项目页面 <a class="hashlink" href="#3.1_点击右上角的“+“号进入添加项目页面">#</a></h4><p><img src="./images/project_add.png" width = "100%" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<h4 class="subject" id="3.2_添加项目页面">3.2 添加项目页面 <a class="hashlink" href="#3.2_添加项目页面">#</a></h4><p><img src="./images/project_add_view.png" width = "100%" style="margin:0px auto;display:block;" alt="图片名称" align=center />
添加完成后进去项目详情页面</p>
<h3 class="subject" id="4 项目详情页面">4 项目详情页面 <a class="hashlink" href="#4 项目详情页面">#</a></h3><h4 class="subject" id="4.1 添加接口分类">4.1 添加接口分类 <a class="hashlink" href="#4.1 添加接口分类">#</a></h4><p><img src="./images/interface_add_cat.png" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<h3 class="subject" id="4_项目详情页面">4 项目详情页面 <a class="hashlink" href="#4_项目详情页面">#</a></h3><h4 class="subject" id="4.1_添加接口分类">4.1 添加接口分类 <a class="hashlink" href="#4.1_添加接口分类">#</a></h4><p><img src="./images/interface_add_cat.png" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<p>添加完成后可以在左侧列表看到新添加的接口分类</p>
<h4 class="subject" id="4.2 添加接口">4.2 添加接口 <a class="hashlink" href="#4.2 添加接口">#</a></h4><p>鼠标移动到接口分类的菜单icon点击添加接口</p>
<h4 class="subject" id="4.2_添加接口">4.2 添加接口 <a class="hashlink" href="#4.2_添加接口">#</a></h4><p>鼠标移动到接口分类的菜单icon点击添加接口</p>
<p><img src="./images/interface_add.png" width="400" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<h4 class="subject" id="4.3 接口编辑">4.3 接口编辑 <a class="hashlink" href="#4.3 接口编辑">#</a></h4><p>添加完接口点击新添加的接口,跳转到接口预览页面,可看到刚才填写的信息。接口的详细信息点击编辑功能进行添加</p>
<h4 class="subject" id="4.4 测试接口">4.4 测试接口 <a class="hashlink" href="#4.4 测试接口">#</a></h4><p>点击运行tab,可进入到接口测试页面,首先安装chrome crossRequest扩展才可正常使用此功能
<h4 class="subject" id="4.3_接口编辑">4.3 接口编辑 <a class="hashlink" href="#4.3_接口编辑">#</a></h4><p>添加完接口点击新添加的接口,跳转到接口预览页面,可看到刚才填写的信息。接口的详细信息点击编辑功能进行添加</p>
<h4 class="subject" id="4.4_测试接口">4.4 测试接口 <a class="hashlink" href="#4.4_测试接口">#</a></h4><p>点击运行tab,可进入到接口测试页面,首先安装chrome crossRequest扩展才可正常使用此功能
<img src="./images/interface_run.png" width="800" style="margin:0px auto;display:block;" alt="图片名称" align=center />
点击保存按钮可把当前测试保存到测试集,方便下次调试</p>
@ -103,7 +105,7 @@
<script src="source/app.js"></script>
<script>
var lineHeight = 17.4;
var lineHeight = 18;
var EXAMPLE_MAX_HEIGHT;
function fold() {
@ -127,8 +129,8 @@
var $this = $(this);
$this.removeClass('extend').addClass('fold');
$this.html('折叠代码');
$this.prev().height('auto');
$this.prev().parent().height('auto');
$this.parent().children('.js-code').height('auto');
$this.parent().height('auto');
});
$('.ydoc-example').delegate('.fold', 'click', function() {
var $this = $(this);
@ -136,7 +138,7 @@
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
$this.removeClass('fold').addClass('extend');
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
$this.html("展开更多……");
});
}

View File

@ -161,7 +161,7 @@ class groupController extends baseController {
async addMember(ctx){
async addMember(ctx) {
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@ -341,7 +341,7 @@ class groupController extends baseController {
if (!id) {
return ctx.body = yapi.commons.resReturn(null, 402, 'id不能为空');
}
let projectList =await projectInst.list(id, true);
let projectList = await projectInst.list(id, true);
projectList.forEach(async (p) => {
await interfaceInst.delByProjectId(p._id)
await interfaceCaseInst.delByProjectId(p._id)
@ -368,6 +368,11 @@ class groupController extends baseController {
* @example ./api/group/up.json
*/
async up(ctx) {
let groupInst = yapi.getInst(groupModel);
let id = ctx.request.body.id;
let data = {};
if (await this.checkAuth(id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
@ -377,9 +382,7 @@ class groupController extends baseController {
group_name: 'string',
group_desc: 'string'
});
let groupInst = yapi.getInst(groupModel);
let id = ctx.request.body.id;
let data = {};
ctx.request.body.group_name && (data.group_name = ctx.request.body.group_name);
ctx.request.body.group_desc && (data.group_desc = ctx.request.body.group_desc);
if (Object.keys(data).length === 0) {

View File

@ -140,16 +140,19 @@ class interfaceController extends baseController {
}
let result = await this.Model.save(data);
let username = this.getUsername();
// let project = await this.projectModel.get(params.project_id);
let cate = await this.catModel.get(params.catid);
yapi.commons.saveLog({
content: `用户 "${username}" 为分类 "${cate.name}" 添加了接口 "${data.title}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.project_id
this.catModel.get(params.catid).then((cate)=>{
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 为分类 "${cate.name}" 添加了接口 "${data.title}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.project_id
});
});
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@ -367,21 +370,30 @@ class interfaceController extends baseController {
try {
let result = await this.Model.up(id, data);
let username = this.getUsername();
let cate;
if (params.catid) {
cate = await this.catModel.get(+params.catid);
this.catModel.get(+params.catid).then((cate)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: cate.project_id
});
});
} else {
let inter = await this.Model.get(id);
cate = interfaceData.catid;
let cateid = interfaceData.catid;
this.catModel.get(cateid).then((cate)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: cate.project_id
});
});
}
yapi.commons.saveLog({
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: cate.project_id
});
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@ -421,14 +433,16 @@ class interfaceController extends baseController {
let result = await this.Model.del(id);
let username = this.getUsername();
let cate = await this.catModel.get(inter.catid);
yapi.commons.saveLog({
content: `用户 "${username}" 删除了分类 "${cate.name}" 下的接口 "${inter.title}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: cate.project_id
});
this.catModel.get(inter.catid).then((cate)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 删除了分类 "${cate.name}" 下的接口 "${inter.title}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: cate.project_id
});
})
ctx.body = yapi.commons.resReturn(result);
} catch (err) {
@ -556,22 +570,18 @@ class interfaceController extends baseController {
}
}
let cate = await this.catModel.get(id);
let result = await this.catModel.del(id);
let r = await this.Model.delByCatid(id);
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 删除了分类 "${cate.name}" 及该分类下的接口`,
content: `用户 "${username}" 删除了分类 "${catData.name}" 及该分类下的接口`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: cate.project_id
typeid: catData.project_id
});
let result = await this.catModel.del(id);
let r = await this.Model.delByCatid(id);
return ctx.body = yapi.commons.resReturn(r);
} catch (e) {
yapi.commons.resReturn(null, 400, e.message)
}

View File

@ -103,7 +103,15 @@ class interfaceColController extends baseController{
uid: this.getUid(),
add_time: yapi.commons.time(),
up_time: yapi.commons.time()
})
});
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 添加了接口集 "${params.name}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.project_id
});
ctx.body = yapi.commons.resReturn(result);
}catch(e){
@ -189,7 +197,19 @@ class interfaceColController extends baseController{
params.add_time = yapi.commons.time();
params.up_time = yapi.commons.time();
let result = await this.caseModel.save(params);
let username = this.getUsername();
this.colModel.get(params.col_id).then((col)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 在接口集 "${col.name}" 下添加了接口用例 "${params.casename}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.project_id
});
});
ctx.body = yapi.commons.resReturn(result);
}catch(e){
@ -198,7 +218,7 @@ class interfaceColController extends baseController{
}
/**
* 增加一个接口用例
* 更新一个接口用例
* @interface /col/up_case
* @method POST
* @category col
@ -235,8 +255,8 @@ class interfaceColController extends baseController{
return ctx.body = yapi.commons.resReturn(null, 400, '用例名称不能为空');
}
let caseData = await this.caseModel.get(id);
let auth = await this.checkAuth(caseData.project_id, 'project', 'edit')
let caseData = await this.caseModel.get(params.id);
let auth = await this.checkAuth(caseData.project_id, 'project', 'edit');
if (!auth) {
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
}
@ -244,6 +264,18 @@ class interfaceColController extends baseController{
params.uid = this.getUid();
let result = await this.caseModel.up(params.id, params);
let username = this.getUsername();
this.colModel.get(caseData.col_id).then((col)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 在接口集 "${col.name}" 更新了接口用例 "${params.casename}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: caseData.project_id
});
});
ctx.body = yapi.commons.resReturn(result);
@ -299,7 +331,15 @@ class interfaceColController extends baseController{
name: params.name,
desc: params.desc,
up_time: yapi.commons.time()
})
});
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 更新了接口集 "${params.name}" 的信息`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: colData.project_id
});
ctx.body = yapi.commons.resReturn(result)
}catch(e){
ctx.body = yapi.commons.resReturn(null, 400, e.message)
@ -323,6 +363,7 @@ class interfaceColController extends baseController{
if(!params || !Array.isArray(params)){
ctx.body = yapi.commons.resReturn(null, 400, "请求参数必须是数组")
}
// let caseName = "";
params.forEach((item) => {
if(item.id && item.index){
this.caseModel.upCaseIndex(item.id, item.index).then((res) => {}, (err) => {
@ -330,7 +371,16 @@ class interfaceColController extends baseController{
})
}
})
});
// let username = this.getUsername();
// yapi.commons.saveLog({
// content: `用户 "${username}" 更新了接口集 "${params.col_name}"`,
// type: 'project',
// uid: this.getUid(),
// username: username,
// typeid: params.project_id
// });
return ctx.body = yapi.commons.resReturn('success')
}catch(e){
@ -363,12 +413,17 @@ class interfaceColController extends baseController{
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
}
}
let result = await this.colModel.del(id);
await this.caseModel.delByCol(id)
await this.caseModel.delByCol(id);
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 删除了接口集 "${colData.name}" 及其下面的接口`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: colData.project_id
});
return ctx.body = yapi.commons.resReturn(result);
}catch(e){
yapi.commons.resReturn(null, 400, e.message)
}
@ -395,6 +450,19 @@ class interfaceColController extends baseController{
}
let result = await this.caseModel.del(caseid);
let username = this.getUsername();
this.colModel.get(caseData.col_id).then((col)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 删除了接口集 "${col.name}" 下的接口 "${caseData.casename}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: caseData.project_id
});
});
return ctx.body = yapi.commons.resReturn(result);

View File

@ -259,14 +259,14 @@ class projectController extends baseController {
try {
let result = await this.Model.delMember(params.id, params.member_uid);
let username = this.getUsername();
let project = await this.Model.get(params.id);
let member = await yapi.getInst(userModel).findById(params.member_uid);
yapi.commons.saveLog({
content: `用户 "${username}" 删除了项目 "${project.name}" 中的成员 "${member.username}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.id
yapi.getInst(userModel).findById(params.member_uid).then((member)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 删除了项目中的成员 "${member.username}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.id
});
});
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
@ -468,15 +468,15 @@ class projectController extends baseController {
let result = await projectInst.changeMemberRole(params.id, params.member_uid, params.role);
let username = this.getUsername();
let project = await this.Model.get(params.id);
let member = await yapi.getInst(userModel).findById(params.member_uid);
yapi.commons.saveLog({
content: `用户 "${username}" 修改了项目 "${project.name}" 中成员 "${member.username}" 的角色为 "${params.role}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.id
});
yapi.getInst(userModel).findById(params.member_uid).then((member)=>{
yapi.commons.saveLog({
content: `用户 "${username}" 修改了项目中的成员 "${member.username}" 的角色为 "${params.role}"`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.id
});
})
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@ -510,7 +510,16 @@ class projectController extends baseController {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
try {
this.followModel.updateById(this.getUid(), id, data).then();
this.followModel.updateById(this.getUid(), id, data).then(()=>{
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户 "${username}" 修改了项目图标、颜色`,
type: 'project',
uid: this.getUid(),
username: username,
typeid: id
});
});
} catch (e) {
yapi.commons.log(e, 'error'); // eslint-disable-line
}
@ -597,43 +606,6 @@ class projectController extends baseController {
}
}
/**
* 修改项目头像
* @interface /project/upset
* @method POST
* @category project
* @foldnumber 10
* @param {Number} id
* @param {String} color
* @param {String} icon
* @return {Object}
*/
async upSet(ctx) {
let id = ctx.request.body.id;
let data = {};
data.color = ctx.request.body.color;
data.icon = ctx.request.body.icon;
if (!id) {
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
}
let auth = await this.checkAuth(id, 'project', 'danger')
if (!auth) {
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
}
try {
let result = await this.Model.up(id, data);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
try {
this.followModel.updateById(this.getUid(), id, data).then();
} catch (e) {
yapi.commons.log(e, 'error'); // eslint-disable-line
}
}
/**
* 模糊搜索项目名称或者组名称
* @interface /project/search