docs: 文档更新

This commit is contained in:
wenbo.dong 2017-08-22 17:28:00 +08:00
parent b39a6d0f40
commit bde62b3ed4
12 changed files with 157 additions and 138 deletions

View File

@ -492,7 +492,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -837,7 +837,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
@ -935,7 +935,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -1031,7 +1031,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -1119,7 +1119,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"logout success..."</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -1158,7 +1158,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span>
@ -1249,7 +1249,7 @@
<div>示例:</div>
<pre class="ydoc-example" ><code><span class="token punctuation">{</span>
<pre class="ydoc-example" ><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -1345,7 +1345,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"logout success..."</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -1830,7 +1830,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
@ -1943,7 +1943,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#42" target="_blank">./server/controllers/project.js:42</a>
<a href="./static/server/controllers/project.js.html#45" target="_blank">./server/controllers/project.js:45</a>
</p>
@ -2043,7 +2043,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -2084,7 +2084,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#127" target="_blank">./server/controllers/project.js:127</a>
<a href="./static/server/controllers/project.js.html#130" target="_blank">./server/controllers/project.js:130</a>
</p>
@ -2138,7 +2138,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -2168,7 +2168,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#183" target="_blank">./server/controllers/project.js:183</a>
<a href="./static/server/controllers/project.js.html#186" target="_blank">./server/controllers/project.js:186</a>
</p>
@ -2222,7 +2222,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -2252,7 +2252,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#248" target="_blank">./server/controllers/project.js:248</a>
<a href="./static/server/controllers/project.js.html#251" target="_blank">./server/controllers/project.js:251</a>
</p>
@ -2294,7 +2294,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
@ -2330,7 +2330,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#273" target="_blank">./server/controllers/project.js:273</a>
<a href="./static/server/controllers/project.js.html#276" target="_blank">./server/controllers/project.js:276</a>
</p>
@ -2372,7 +2372,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -2413,7 +2413,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#305" target="_blank">./server/controllers/project.js:305</a>
<a href="./static/server/controllers/project.js.html#308" target="_blank">./server/controllers/project.js:308</a>
</p>
@ -2455,7 +2455,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -2629,7 +2629,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#345" target="_blank">./server/controllers/project.js:345</a>
<a href="./static/server/controllers/project.js.html#358" target="_blank">./server/controllers/project.js:358</a>
</p>
@ -2671,7 +2671,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -2701,7 +2701,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#381" target="_blank">./server/controllers/project.js:381</a>
<a href="./static/server/controllers/project.js.html#394" target="_blank">./server/controllers/project.js:394</a>
</p>
@ -2787,7 +2787,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#434" target="_blank">./server/controllers/project.js:434</a>
<a href="./static/server/controllers/project.js.html#446" target="_blank">./server/controllers/project.js:446</a>
</p>
@ -2893,7 +2893,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code">
<span class="token comment" spellcheck="true">//请求示例</span>
<span class="token punctuation">{</span>
<span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token number">8</span><span class="token punctuation">,</span>
@ -2935,7 +2935,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#519" target="_blank">./server/controllers/project.js:519</a>
<a href="./static/server/controllers/project.js.html#565" target="_blank">./server/controllers/project.js:565</a>
</p>
@ -2977,7 +2977,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -3030,7 +3030,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#573" target="_blank">./server/controllers/project.js:573</a>
<a href="./static/server/controllers/project.js.html#619" target="_blank">./server/controllers/project.js:619</a>
</p>
@ -3323,7 +3323,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code">
<span class="token comment" spellcheck="true">//请求 /interface/add</span>
<span class="token comment" spellcheck="true">//header Content-Type:application/json</span>
@ -3458,7 +3458,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span><span class="token keyword">get</span><span class="token punctuation">.</span>json</code></pre>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span><span class="token keyword">get</span><span class="token punctuation">.</span>json</code></pre>
</div>
@ -3523,7 +3523,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span>list<span class="token punctuation">.</span>json</code></pre>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span>list<span class="token punctuation">.</span>json</code></pre>
</div>
@ -3748,7 +3748,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -3821,7 +3821,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
@ -3854,7 +3854,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/follow.js.html#24" target="_blank">./server/controllers/follow.js:24</a>
<a href="./static/server/controllers/follow.js.html#10" target="_blank">./server/controllers/follow.js:10</a>
</p>
@ -3879,18 +3879,6 @@
</tr>
</thead>
<tr>
<td>uid</td>
<td>Number</td>
<td>用户id 不能为空</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>page</td>
<td>Number</td>
@ -3916,7 +3904,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>list</code></pre>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>list</code></pre>
</div>
@ -3939,7 +3927,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/follow.js.html#60" target="_blank">./server/controllers/follow.js:60</a>
<a href="./static/server/controllers/follow.js.html#43" target="_blank">./server/controllers/follow.js:43</a>
</p>
@ -3965,9 +3953,9 @@
</thead>
<tr>
<td>id</td>
<td>projectid</td>
<td>Number</td>
<td>关注id</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
@ -3981,7 +3969,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>del</code></pre>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>del</code></pre>
</div>
@ -4004,7 +3992,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/follow.js.html#86" target="_blank">./server/controllers/follow.js:86</a>
<a href="./static/server/controllers/follow.js.html#75" target="_blank">./server/controllers/follow.js:75</a>
</p>
@ -4029,18 +4017,6 @@
</tr>
</thead>
<tr>
<td>uid</td>
<td>Number</td>
<td>用户id</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>projectid</td>
<td>Number</td>
@ -4082,7 +4058,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>add</code></pre>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>add</code></pre>
</div>
@ -4835,7 +4811,7 @@
<div>示例:</div>
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>log<span class="token operator">/</span>list</code></pre>
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>log<span class="token operator">/</span>list</code></pre>
</div>
@ -4890,8 +4866,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);
@ -4899,7 +4875,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("展开更多……");
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

View File

@ -175,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);
@ -184,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

@ -70,7 +70,7 @@
<article class="markdown-body">
<h2 class="subject" id="Mock功能">Mock功能 <a class="hashlink" href="#Mock功能">#</a></h2> <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>
<h3 class="subject" id="1 Mock步骤">1 Mock步骤 <a class="hashlink" href="#1 Mock步骤">#</a></h3><h4 class="subject" id="1.1 创建接口">1.1 创建接口 <a class="hashlink" href="#1.1 创建接口">#</a></h4><p>通过点击页面上的&quot;+添加接口&quot;</p>
<h3 class="subject" id="1_Mock步骤">1 Mock步骤 <a class="hashlink" href="#1_Mock步骤">#</a></h3><h4 class="subject" id="1.1_创建接口">1.1 创建接口 <a class="hashlink" href="#1.1_创建接口">#</a></h4><p>通过点击页面上的&quot;+添加接口&quot;</p>
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB613bd4f29db038f2b41c03dcfceda2b6?method=download&shareKey=29bfc2b855f6f26ce0079baf567e54cc" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<p> 输入协议、URL、接口名、请求头、请求参数、Mock规则<a href="#mock">点击到Mock规则</a>)等信息。</p>
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB680a37ba304768804b23cf2cf36ed40d?method=download&shareKey=0d750695dce3a4c7abf697fa58d24c57" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
@ -84,14 +84,14 @@
<p>取到上面的链接在浏览器中请求就可以得到如下结果。</p>
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB1d1f7dc7b83a8cd6f576953cf45e9719?method=download&shareKey=99b4af9baac527b969543dd0a909d2a1" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></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>@占位符" 同时也指定了最终值的初始值和类型)
@ -107,14 +107,14 @@
'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。
@ -140,21 +140,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> 个元素,作为最终值。
@ -170,7 +170,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>占位符 只是在属性值字符串中占个位置,并不出现在最终的属性值中。
占位符 的格式为:
@ -240,8 +240,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 +249,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,7 +129,8 @@ $(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);
});
var winHeight = $(window).height() - 44,
@ -213,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

@ -68,23 +68,21 @@
<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>平台以<strong>项目分组</strong> -&gt; <strong>项目</strong> -&gt; <strong>接口</strong>的划分进行接口组织管理。</p>
<p><img src="./images/yapi-base-flow.jpg" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<h4 class="subject" id="1.1 项目分组">1.1 项目分组 <a class="hashlink" href="#1.1 项目分组">#</a></h4><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><h4 class="subject" id="1.1_项目分组">1.1 项目分组 <a class="hashlink" href="#1.1_项目分组">#</a></h4><p>登录之后进到项目首页,左边侧边栏显示的即分组列表。</p>
<p><img src="http://upload-images.jianshu.io/upload_images/842107-d90ca4b3242fa760.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "200" style="margin-left:170px;display:block;" alt="图片名称" align=center /></p>
<p>管理员有权限添加或删除分组。</p>
<p><img src="http://upload-images.jianshu.io/upload_images/842107-a0d4d9a98003896a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "500" style="margin-left:170px;display:block;" alt="图片名称" align=center /></p>
<blockquote>
<p>分组名称具有唯一性</p>
</blockquote>
<h4 class="subject" id="1.2 项目">1.2 项目 <a class="hashlink" href="#1.2 项目">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
<h4 class="subject" id="1.2_项目">1.2 项目 <a class="hashlink" href="#1.2_项目">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
<p><img src="http://upload-images.jianshu.io/upload_images/842107-137bcae58b84715e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<p>创建项目需要填写项目名称,项目线上域名(添加完成后可配置项目其他环境域名),项目接口基本路径(接口路径前面相同的部分)以及项目描述。</p>
<p><img src="http://upload-images.jianshu.io/upload_images/842107-360a50ddb746f73d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<blockquote>
<p>项目『线上域名 + 基本路径』具有唯一性</p>
</blockquote>
<h4 class="subject" id="1.3 接口">1.3 接口 <a class="hashlink" href="#1.3 接口">#</a></h4><p>点击项目名称,进入该项目接口列表。</p>
<h4 class="subject" id="1.3_接口">1.3 接口 <a class="hashlink" href="#1.3_接口">#</a></h4><p>点击项目名称,进入该项目接口列表。</p>
<p><img src="http://upload-images.jianshu.io/upload_images/842107-e858005f714f4889.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
<p>点击编辑,进入接口详情页(之后接口详情页和编辑也会分开),可以编辑接口或者请求测试真实接口。</p>
<p><img src="http://upload-images.jianshu.io/upload_images/842107-78c0ea839619d068.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
@ -134,8 +132,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);
@ -143,7 +141,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

@ -33,20 +33,6 @@ class followController extends baseController {
constructor(ctx) {
super(ctx);
this.Model = yapi.getInst(followModel);
// try{
// var res = this.Model.save({
// uid: 107,
// projectid: 221,
// projectname: 'Flight',
// icon: 'code'
// });
// // var res = this.Model.del(107);
// ctx.body = yapi.commons.resReturn(null, 200,res);
// }catch(err){
// ctx.body = yapi.commons.resReturn(null, 402, err.message);
// }
}
/**
@ -55,7 +41,6 @@ class followController extends baseController {
* @method GET
* @category follow
* @foldnumber 10
* @param {Number} uid 用户id 不能为空
* @param {Number} [page] 分页页码
* @param {Number} [limit] 分页大小
* @returns {Object}
@ -63,7 +48,7 @@ class followController extends baseController {
*/
async list(ctx) {
let uid = ctx.request.query.uid,
let uid = this.getUid(),
page = ctx.request.query.page || 1,
limit = ctx.request.query.limit || 10;
@ -72,11 +57,9 @@ class followController extends baseController {
}
try {
let result = await this.Model.listWithPaging(uid, page, limit);
let count = await this.Model.listCount(uid);
let result = await this.Model.list(uid);
ctx.body = yapi.commons.resReturn({
total: Math.ceil(count / limit),
list: result
});
} catch (err) {
@ -91,20 +74,26 @@ class followController extends baseController {
* @method POST
* @category follow
* @foldnumber 10
* @param {Number} id 关注id
* @param {Number} projectid
* @returns {Object}
* @example /follow/del
*/
async del(ctx) {
let params = ctx.request.body;
let params = ctx.request.body, uid = this.getUid();
if(params.followid){
return ctx.body = yapi.commons.resReturn(null, 400, '关注id不能为空');
if(!params.projectid){
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
let checkRepeat = await this.Model.checkProjectRepeat(uid,params.projectid);
if (checkRepeat == 0) {
return ctx.body = yapi.commons.resReturn(null, 401, '项目未关注');
}
try {
let result = await this.Model.del(params.id);
let result = await this.Model.del(params.projectid, this.getUid());
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@ -117,7 +106,6 @@ class followController extends baseController {
* @method GET
* @category follow
* @foldnumber 10
* @param {Number} uid 用户id
* @param {Number} projectid 项目id
* @param {String} projectname 项目名
* @param {String} icon 项目icon
@ -128,22 +116,20 @@ class followController extends baseController {
async add(ctx) {
let params = ctx.request.body;
params = yapi.commons.handleParams(params, {
uid: 'number',
projectid: 'number',
projectname: 'string',
icon: 'string',
color: 'string'
});
if (!params.uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '用户id不为空');
}
let uid = this.getUid()
if (!params.projectid) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
let checkRepeat = await this.Model.checkProjectRepeat(params.uid,params.projectid);
let checkRepeat = await this.Model.checkProjectRepeat(uid,params.projectid);
if (checkRepeat) {
return ctx.body = yapi.commons.resReturn(null, 401, '项目已关注');
}
@ -159,12 +145,11 @@ class followController extends baseController {
}
let data = {
uid: params.uid,
uid: uid,
projectid: params.projectid,
projectname: params.projectname,
icon: params.icon,
color: params.color
};
try {

View File

@ -27,6 +27,7 @@
<pre class="brush: js;">
import projectModel from '../models/project.js';
import yapi from '../yapi.js';
import _ from "underscore"
import baseController from './base.js';
import interfaceModel from '../models/interface.js';
import interfaceColModel from '../models/interfaceCol.js';
@ -36,6 +37,7 @@ import groupModel from '../models/group';
import commons from '../utils/commons.js';
import userModel from '../models/user.js';
import logModel from '../models/log.js';
import followModel from '../models/follow.js';
import Mock from 'mockjs';
const send = require('koa-send');
@ -46,6 +48,7 @@ class projectController extends baseController {
this.Model = yapi.getInst(projectModel);
this.groupModel = yapi.getInst(groupModel);
this.logModel = yapi.getInst(logModel);
this.followModel = yapi.getInst(followModel);
}
handleBasepath(basepath) {
@ -351,8 +354,18 @@ class projectController extends baseController {
let auth =await this.checkAuth(group_id, 'group', 'edit')
try {
let result = await this.Model.list(group_id, auth);
let follow = await this.followModel.list(this.getUid());
let uids = [];
result.forEach((item) => {
result.forEach((item, index) => {
result[index] = item.toObject();
let f = _.find(follow, (fol)=>{
return fol.projectid === item._id
})
if(f){
result[index].follow = true;
}else{
result[index].follow = false;
}
if (uids.indexOf(item.uid) === -1) {
uids.push(item.uid);
}
@ -420,7 +433,6 @@ class projectController extends baseController {
*/
async changeMemberRole(ctx){
let params = ctx.request.body;
console.log(params);
let projectInst = yapi.getInst(projectModel);
if (!params.member_uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目成员uid不能为空');
@ -475,7 +487,26 @@ class projectController extends baseController {
* @returns {Object}
* @example ./api/project/up.json
*/
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不能为空');
}
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
}
}
async up(ctx) {
try {
let id = ctx.request.body.id;
@ -527,7 +558,22 @@ class projectController extends baseController {
if(params.color) data.color = params.color;
if(params.icon) data.icon = params.icon;
let result = await this.Model.up(id, data);
// try{
// let data = {};
// if(params.name){
// data.projectname = params.name;
// }
// if(params.icon){
// data.icon = params.icon;
// }
// if(params.color){
// data.color = params.color;
// }
// this.followModel.updateById(this.getUid(),id,data);
// }catch(e){
// yapi.commons.log(e, 'error'); // eslint-disable-line
// }
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户${username}更新了项目${projectData.name}`,