opti: docs

This commit is contained in:
suxiaoxin 2018-03-30 20:09:49 +08:00
parent fdbb95b1d3
commit 6727b9efb5
22 changed files with 96 additions and 40 deletions

3
docs/web.css Normal file
View File

@ -0,0 +1,3 @@
img{
margin:16px
}

View File

@ -1,4 +1,4 @@
<html><head><meta charSet="UTF-8"/><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" sizes="180x180" href="../ydoc/images/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="../ydoc/images/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="../ydoc/images/favicon-16x16.png"/><link rel="manifest" href="../ydoc/images/manifest.json"/><link rel="mask-icon" href="../ydoc/images/safari-pinned-tab.svg&quot;" color="#5bbad5"/><meta name="theme-color" content="#ffffff"/><meta http-equiv="Cache-Control" content="no-transform"/><meta http-equiv="Cache-Control" content="no-siteapp"/><title>内网部署</title><link rel="stylesheet" href="../ydoc/styles/style.css"/><meta name="author" content="ymfe"/><meta name="keywords" content="api管理,接口管理,接口文档,api文档"/><meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理"/><meta id="releativePath" content=".."/><link rel="stylesheet" href="../ydoc/ydoc-plugin-search/search.css"/><link rel="stylesheet" href="../ydoc/ydoc-plugin-search/search.css"/></head><body><div class="g-doc"><div class="m-summary" id="js-menu"><div class="m-summary-content" id="js-menu-content"><div class="m-summary-block"><ul class="m-summary-list"><li class="item"><a href="index.html#%e5%ae%89%e8%a3%85" class="href">安装</a></li><li class="item"><a href="index.html#%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%ae%a1%e7%90%86" class="href">服务器管理</a></li><li class="item"><a href="index.html#%e5%8d%87%e7%ba%a7" class="href">升级</a></li><li class="item"><a href="index.html#%e9%85%8d%e7%bd%aeldap%e7%99%bb%e5%bd%95" class="href">配置LDAP登录</a></li></ul></div></div><div class="m-summary-switch" id="js-summary-switch"><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="bottom"><g transform="translate(904.92214,-879.1482)"><path d="m -673.67664,1221.6502 -231.2455,-231.24803 55.6165,-55.627 c 30.5891,-30.59485 56.1806,-55.627 56.8701,-55.627 0.6894,0 79.8637,78.60862 175.9427,174.68583 l 174.6892,174.6858 174.6892,-174.6858 c 96.079,-96.07721 175.253196,-174.68583 175.942696,-174.68583 0.6895,0 26.281,25.03215 56.8701,55.627 l 55.6165,55.627 -231.245496,231.24803 c -127.185,127.1864-231.5279,231.248 -231.873,231.248 -0.3451,0 -104.688,-104.0616 -231.873,-231.248 z" fill="#fff"></path></g></svg><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="top"><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="aaa" fill="#fff" fill-rule="nonzero"><path d="M231.2455,342.502 L0,111.25397 L55.6165,55.62697 C86.2056,25.03212 111.7971,-2.99999998e-05 112.4866,-2.99999998e-05 C113.176,-2.99999998e-05 192.3503,78.60859 288.4293,174.6858 L463.1185,349.3716 L637.8077,174.6858 C733.8867,78.60859 813.060896,-2.99999997e-05 813.750396,-2.99999997e-05 C814.439896,-2.99999997e-05 840.031396,25.03212 870.620496,55.62697 L926.236996,111.25397 L694.9915,342.502 C567.8065,469.6884 463.4636,573.75 463.1185,573.75 C462.7734,573.75 358.4305,469.6884 231.2455,342.502 Z" id="Shape" transform="translate(463.118498, 286.874985) scale(1, -1) translate(-463.118498, -286.874985) "></path></g></g></svg></div></div><div class="m-main" id="js-panel"><header class="m-header" id="js-header"><div class="m-header-title js-logo"><a href="../index.html" target="_self"><img class="logo" src="../documents/images/logo_header@2x.png"/><h6 class="name">YApi</h6></a></div><div><div class="m-search">
<html><head><meta charSet="UTF-8"/><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" sizes="180x180" href="../ydoc/images/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="../ydoc/images/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="../ydoc/images/favicon-16x16.png"/><link rel="manifest" href="../ydoc/images/manifest.json"/><link rel="mask-icon" href="../ydoc/images/safari-pinned-tab.svg&quot;" color="#5bbad5"/><meta name="theme-color" content="#ffffff"/><meta http-equiv="Cache-Control" content="no-transform"/><meta http-equiv="Cache-Control" content="no-siteapp"/><title>内网部署</title><link rel="stylesheet" href="../ydoc/styles/style.css"/><meta name="author" content="ymfe"/><meta name="keywords" content="api管理,接口管理,接口文档,api文档"/><meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理"/><meta id="releativePath" content=".."/><link rel="stylesheet" href="../ydoc/ydoc-plugin-search/search.css"/><link rel="stylesheet" href="../ydoc/ydoc-plugin-search/search.css"/><link rel="stylesheet" href="../web.css"/></head><body><div class="g-doc"><div class="m-summary" id="js-menu"><div class="m-summary-content" id="js-menu-content"><div class="m-summary-block"><ul class="m-summary-list"><li class="item"><a href="index.html#%e5%ae%89%e8%a3%85" class="href">安装</a></li><li class="item"><a href="index.html#%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%ae%a1%e7%90%86" class="href">服务器管理</a></li><li class="item"><a href="index.html#%e5%8d%87%e7%ba%a7" class="href">升级</a></li><li class="item"><a href="index.html#%e9%85%8d%e7%bd%aeldap%e7%99%bb%e5%bd%95" class="href">配置LDAP登录</a></li></ul></div></div><div class="m-summary-switch" id="js-summary-switch"><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="bottom"><g transform="translate(904.92214,-879.1482)"><path d="m -673.67664,1221.6502 -231.2455,-231.24803 55.6165,-55.627 c 30.5891,-30.59485 56.1806,-55.627 56.8701,-55.627 0.6894,0 79.8637,78.60862 175.9427,174.68583 l 174.6892,174.6858 174.6892,-174.6858 c 96.079,-96.07721 175.253196,-174.68583 175.942696,-174.68583 0.6895,0 26.281,25.03215 56.8701,55.627 l 55.6165,55.627 -231.245496,231.24803 c -127.185,127.1864-231.5279,231.248 -231.873,231.248 -0.3451,0 -104.688,-104.0616 -231.873,-231.248 z" fill="#fff"></path></g></svg><svg viewBox="0 0 926.23699 573.74994" version="1.1" x="0px" y="0px" width="15" height="15" class="top"><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="aaa" fill="#fff" fill-rule="nonzero"><path d="M231.2455,342.502 L0,111.25397 L55.6165,55.62697 C86.2056,25.03212 111.7971,-2.99999998e-05 112.4866,-2.99999998e-05 C113.176,-2.99999998e-05 192.3503,78.60859 288.4293,174.6858 L463.1185,349.3716 L637.8077,174.6858 C733.8867,78.60859 813.060896,-2.99999997e-05 813.750396,-2.99999997e-05 C814.439896,-2.99999997e-05 840.031396,25.03212 870.620496,55.62697 L926.236996,111.25397 L694.9915,342.502 C567.8065,469.6884 463.4636,573.75 463.1185,573.75 C462.7734,573.75 358.4305,469.6884 231.2455,342.502 Z" id="Shape" transform="translate(463.118498, 286.874985) scale(1, -1) translate(-463.118498, -286.874985) "></path></g></g></svg></div></div><div class="m-main" id="js-panel"><header class="m-header" id="js-header"><div class="m-header-title js-logo"><a href="../index.html" target="_self"><img class="logo" src="../documents/images/logo_header@2x.png"/><h6 class="name">YApi</h6></a></div><div><div class="m-search">
<div class="icon">&#xf0fd;</div>
<input type="text" class="input js-input" placeholder="搜索文档内容" />
<div class="m-search-result js-search-result"></div>

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

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

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

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

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

@ -1,4 +1,4 @@
<html><head><meta charSet="UTF-8"/><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" sizes="180x180" href="ydoc/images/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="ydoc/images/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="ydoc/images/favicon-16x16.png"/><link rel="manifest" href="ydoc/images/manifest.json"/><link rel="mask-icon" href="ydoc/images/safari-pinned-tab.svg&quot;" color="#5bbad5"/><meta name="theme-color" content="#ffffff"/><meta http-equiv="Cache-Control" content="no-transform"/><meta http-equiv="Cache-Control" content="no-siteapp"/><title>YApi 接口管理平台</title><link rel="stylesheet" href="ydoc/styles/style.css"/><meta name="author" content="ymfe"/><meta name="keywords" content="api管理,接口管理,接口文档,api文档"/><meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理"/><meta id="releativePath" content=""/><link rel="stylesheet" href="ydoc/ydoc-plugin-search/search.css"/><link rel="stylesheet" href="ydoc/ydoc-plugin-search/search.css"/></head><body><div class="g-doc"><div class="m-main" id="js-panel"><header class="m-header" id="js-header"><div class="m-header-title js-logo"><a href="" target="_self"><img class="logo" src="documents/images/logo_header@2x.png"/><h6 class="name">YApi</h6></a></div><div><div class="m-search">
<html><head><meta charSet="UTF-8"/><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black"/><link rel="apple-touch-icon" sizes="180x180" href="ydoc/images/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="ydoc/images/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="ydoc/images/favicon-16x16.png"/><link rel="manifest" href="ydoc/images/manifest.json"/><link rel="mask-icon" href="ydoc/images/safari-pinned-tab.svg&quot;" color="#5bbad5"/><meta name="theme-color" content="#ffffff"/><meta http-equiv="Cache-Control" content="no-transform"/><meta http-equiv="Cache-Control" content="no-siteapp"/><title>YApi 接口管理平台</title><link rel="stylesheet" href="ydoc/styles/style.css"/><meta name="author" content="ymfe"/><meta name="keywords" content="api管理,接口管理,接口文档,api文档"/><meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理"/><meta id="releativePath" content=""/><link rel="stylesheet" href="ydoc/ydoc-plugin-search/search.css"/><link rel="stylesheet" href="ydoc/ydoc-plugin-search/search.css"/><link rel="stylesheet" href="web.css"/></head><body><div class="g-doc"><div class="m-main" id="js-panel"><header class="m-header" id="js-header"><div class="m-header-title js-logo"><a href="" target="_self"><img class="logo" src="documents/images/logo_header@2x.png"/><h6 class="name">YApi</h6></a></div><div><div class="m-search">
<div class="icon">&#xf0fd;</div>
<input type="text" class="input js-input" placeholder="搜索文档内容" />
<div class="m-search-result js-search-result"></div>

3
static/doc/web.css Normal file
View File

@ -0,0 +1,3 @@
img{
margin:16px
}

View File

@ -84,8 +84,8 @@
.m-search .caption:hover {
background-color: #f6f8fa;
}
.m-search .caption .title {
.m-search .caption.active {
background-color: #f6f8fa;
}
.m-search .caption .desc {
font-weight: normal;

View File

@ -1,6 +1,7 @@
$(function(){
var $searchResult = $('.js-search-result'),
$searchInput = $('.js-input');
$searchInput = $('.js-input'),
activeIndex = 0;
// 去除空格
String.prototype.trim = function () {
@ -39,11 +40,19 @@ $(function(){
return addHighlightStr + ellipsis;
}
// 隐藏搜索结果框
function hideSearchResult() {
$searchResult.hide();
}
// 监听输入的内容
$searchInput.on('input', debounce(function(e) {
var val = e.target.value.trim(),
res = window.ydoc_plugin_search_core(val);
activeIndex = 0;
console.log(res);
$(document).off('keydown');
$searchResult.show();
if (realObj(res) || val === '') {
var dom = '';
@ -51,13 +60,21 @@ $(function(){
dom += '<div class="headline">' + key + '</div>';
res[key].forEach(function(item) {
var contentDom = '';
item.children.forEach(function(i) {
i.title = simplifyStrDom(i.title, val);
i.content = simplifyStrDom(i.content, val);
contentDom += '<a class="caption" href="' + i.url + '">'+
'<div class="title">' + i.title + '</div>' +
'<div class="desc">' + i.content + '</div></a>';
});
if (item.children.length) {
item.children.forEach(function (i) {
i.title = simplifyStrDom(i.title, val);
i.content = simplifyStrDom(i.content, val);
contentDom += '<a class="caption" href="' + i.url + '">' +
'<div class="title">' + i.title + '</div>' +
'<div class="desc">' + i.content + '</div></a>';
});
} else {
item.title = simplifyStrDom(item.title, val);
item.content = simplifyStrDom(item.content, val);
contentDom = '<a class="caption" href="' + item.url + '">' +
'<div class="title">' + item.title + '</div>' +
'<div class="desc">' + item.content + '</div></a>';
}
dom += '<div class="row">' +
'<a class="subtitle" href="' + item.url + '">' + item.title + '</a>' +
'<div class="content">' + contentDom + '</div>' +
@ -65,23 +82,51 @@ $(function(){
});
}
$searchResult.html(dom);
var $captions = $('.js-search-result .caption');
var length = $captions.length;
if ($captions.length) {
$captions[activeIndex].classList.add('active');
// 监听键盘事件 up: 38, down: 40, enter: 13
$(document).on('keydown', function (e) {
console.log(e.keyCode);
if (e.keyCode == 38) {
$captions[activeIndex].classList.remove('active');
activeIndex = (activeIndex + length - 1) % length;
$captions[activeIndex].classList.add('active');
} else if (e.keyCode == 40) {
$captions[activeIndex].classList.remove('active');
activeIndex = (activeIndex + 1) % length;
$captions[activeIndex].classList.add('active');
} else if (e.keyCode == 13) {
window.open($captions[activeIndex].href, '_self');
}
});
}
// 按下 ESC 键,清空输入框并收起搜索结果框
$(document).on('keydown', function (e) {
if (e.keyCode == 27) {
$searchInput[0].value = '';
$searchResult.hide();
}
});
} else {
$searchResult.html('<div class="empty">没有找到关键词 <b>' + val + '</b> 的搜索结果</div>')
}
}, 300));
// 关闭搜索结果
$searchInput.on('blur', function(e) {
setTimeout(function() {
$searchResult.hide();
}, 100);
});
// $searchInput.on('blur', function(e) {
// $searchResult.hide();
// });
$searchResult.on('click', function(e){
return false;
})
$(document).on('click', function(e){
$searchResult.hide();
})
// ESCAPE key pressed
$(document).on('keydown', function (e) {
if (e.keyCode == 27) {
$searchInput[0].value = '';
$searchResult.hide();
}
});
})

View File

@ -4,5 +4,10 @@
"author": "ymfe",
"description": "YApi 是高效、易用、功能强大的 api 管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 APIYApi 还为用户提供了优秀的交互体验,开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理",
"plugins": ["search"],
"dist": "static/doc"
"dist": "static/doc",
"pluginsConfig": {
"import-asset": {
"css": "web.css"
}
}
}