docs: 更新文档

This commit is contained in:
wenbo.dong 2017-09-20 15:39:55 +08:00
parent 4eac0982b5
commit 8f9386a7d0
5 changed files with 64 additions and 67 deletions

View File

@ -161,14 +161,14 @@
<pre><code>mockd地址 http<span class="token operator">:</span>//yapi.corp.qunar.com/mock/<span class="token number">29</span>/api/hackathon/login
</code></pre><p>项目id可以在项目设置里查看到</p>
<h2 class="subject" id="定义mock数据示例">定义mock数据示例 <a class="hashlink" href="#定义mock数据示例">#</a></h2><pre><code><span class="token punctuation">{</span>
"status|<span class="token number">0</span>-<span class="token number">1</span>"<span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span> //接口状态
<span class="token property">"status|0-1"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span> //接口状态
<span class="token property">"message"</span><span class="token operator">:</span> <span class="token string">"请求完成"</span><span class="token punctuation">,</span> //消息提示
<span class="token property">"data"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"counts"</span><span class="token operator">:</span><span class="token string">"@integer"</span><span class="token punctuation">,</span> //统计数量
"totalSubjectType|<span class="token number">4</span>-<span class="token number">10</span>"<span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token property">"totalSubjectType|4-10"</span><span class="token operator">:</span> <span class="token punctuation">[</span>
<span class="token punctuation">{</span>
"subjectName|regexp"<span class="token operator">:</span> "大数据|机器学习|工具<span class="token string">", //主题名
"</span>subjectType|+<span class="token number">1</span>"<span class="token operator">:</span> <span class="token number">1</span> //类型
<span class="token property">"subjectName|regexp"</span><span class="token operator">:</span> <span class="token string">"大数据|机器学习|工具"</span><span class="token punctuation">,</span> //主题名
<span class="token property">"subjectType|+1"</span><span class="token operator">:</span> <span class="token number">1</span> //类型
<span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token property">"data"</span><span class="token operator">:</span><span class="token punctuation">[</span>
@ -181,8 +181,8 @@
<span class="token punctuation">}</span>
</code></pre><h2 class="subject" id="YApi_Mock_跟_mockjs_区别">YApi Mock 跟 mockjs 区别 <a class="hashlink" href="#YApi_Mock_跟_mockjs_区别">#</a></h2><p>1 因为 yapi 基于 json 定义 mock ,无法使用 mockjs 原有的函数功能,正则表达式需要基于 rule 书写,示例如下:</p>
<pre><code><span class="token punctuation">{</span>
"name|regexp"<span class="token operator">:</span> <span class="token string">"[a-z0-9_]+?"</span><span class="token punctuation">,</span>
"type|regexp"<span class="token operator">:</span> "json|text|xml" //枚举数据类型可这样实现
<span class="token property">"name|regexp"</span><span class="token operator">:</span> <span class="token string">"[a-z0-9_]+?"</span><span class="token punctuation">,</span>
<span class="token property">"type|regexp"</span><span class="token operator">:</span> <span class="token string">"json|text|xml"</span> //枚举数据类型可这样实现
<span class="token punctuation">}</span>
</code></pre><p>2 支持替换请求的query,body参数</p>
<pre><code><span class="token punctuation">{</span>
@ -219,9 +219,9 @@ $<span class="token punctuation">.</span><span class="token function">post</span
<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>
<pre><code>// 属性名 name (与生成规则之间用 "|<span class="token string">" 隔开)
// 生成规则 rule生成规则有7种详见下面的生成规则
// 属性值 value可以含有 "</span>@占位符" 同时也指定了最终值的初始值和类型)
<pre><code>// 属性名 name (与生成规则之间用 <span class="token string">"|"</span> 隔开)
// 生成规则 rule生成规则有<span class="token number">7</span>种详见下面的生成规则)
// 属性值 value可以含有 <span class="token string">"@占位符"</span> 同时也指定了最终值的初始值和类型)
'name|rule'<span class="token operator">:</span> value

View File

@ -1,6 +1,3 @@
var EXAMPLE_MAX_HEIGHT = 98,
DEFAULT_SHOW_PARAMS = 5;
$(document).ready(function() {
// 移动端导航
var $openPanel = $('.open-panel');
@ -11,7 +8,6 @@ $(document).ready(function() {
var $versionSelector = $('.version-selector');
var $versionMask = $('.m-version-mask');
var isPanelHide = true;
var winWidth = $(window).width();
var h2 = $('.content-right').find('h2');
var h3 = $('.content-right').find('h3');
var a = $('.content-left').find('a');
@ -125,7 +121,6 @@ $(document).ready(function() {
})
$versionSelector.click(function(e) {
$versionMask.show();
console.log('e');
});
$('.markdown-body pre').map(function(i, item) {
@ -133,59 +128,61 @@ $(document).ready(function() {
$(item).children('code').addClass('js-code-'+i);
});
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');
if (winWidth < 768) {
$('.docs-sidenav').css({
'overflow-x': 'hidden'
});
}
var activeMenu,
barScroll = false;
// var winHeight = $(window).height() - 44,
// sidebar = $('.docs-sidebar');
sidebar.on('mouseover', function() {
barScroll = true;
});
sidebar.on('mouseout', function() {
barScroll = false;
});
};
// var docSideNav = $('.docs-sidenav');
// if (winWidth > 767) {
// docSideNav.width($contentLeftWidth);
// }
$(window).on('scroll', function(e) {
if ($(this).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');
}
// if (sidebar.height() > winHeight) {
// sidebar.css('max-height', winHeight + 'px');
// $('.docs-sidenav').css('max-height', winHeight + 'px');
// if (winWidth < 768) {
// $('.docs-sidenav').css({
// 'overflow-x': 'hidden'
// });
// }
// var activeMenu,
// barScroll = false;
//
// sidebar.on('mouseover', function() {
// barScroll = true;
// });
// sidebar.on('mouseout', function() {
// barScroll = false;
// });
// };
if (!barScroll) {
var activeItem = $('.docs-sidebar li.active a');
if (activeItem.length) {
if (!activeMenu || (activeMenu.attr('href') != activeItem.attr('href'))) {
activeMenu = activeItem;
var top = activeMenu.offset().top - sidebar.offset().top;
if (top < 0) {
//sidebar.scrollTop(sidebar.scrollTop() + top);
$('.docs-sidenav').scrollTop($('.docs-sidenav').scrollTop() + top);
} else if (top > winHeight - 88) {
//sidebar.scrollTop(sidebar.scrollTop() + top - winHeight + 44);
$('.docs-sidenav').scrollTop($('.docs-sidenav').scrollTop() + top - winHeight + 88);
}
}
}
}
});
// $(window).on('scroll', function(e) {
// if ($(this).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');
// }
//
// if (!barScroll) {
// var activeItem = $('.docs-sidebar li.active a');
// if (activeItem.length) {
// if (!activeMenu || (activeMenu.attr('href') != activeItem.attr('href'))) {
// activeMenu = activeItem;
// var top = activeMenu.offset().top - sidebar.offset().top;
// if (top < 0) {
// //sidebar.scrollTop(sidebar.scrollTop() + top);
// $('.docs-sidenav').scrollTop($('.docs-sidenav').scrollTop() + top);
// } else if (top > winHeight - 88) {
// //sidebar.scrollTop(sidebar.scrollTop() + top - winHeight + 44);
// $('.docs-sidenav').scrollTop($('.docs-sidenav').scrollTop() + top - winHeight + 88);
// }
// }
// }
// }
// });
// 退出全屏浏览器窗口大小改变不触发resize
$(window).on('resize', function(e) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -90,7 +90,7 @@
"title": "版本记录",
"banner": {
"title": "YApi",
"description": "Releases"
"description": "这里列举了 YApi 的历史版本、发布时间及变更记录,帮助你追溯到每个版本的演进过程。"
},
"compile": "markdown",
"menuLevel": 2,