mirror of https://github.com/mindoc-org/mindoc.git
实现项目内搜索功能
parent
d02768aad0
commit
f7725c0a1f
|
@ -832,6 +832,12 @@ func (c *DocumentController) QrCode() {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *DocumentController) Search() {
|
||||
c.Prepare()
|
||||
|
||||
c.JsonResult(0,"ok")
|
||||
}
|
||||
|
||||
//递归生成文档序列数组.
|
||||
func RecursiveFun(parent_id int, prefix, dpath string, c *DocumentController, book *models.BookResult, docs []*models.Document, paths *list.List) {
|
||||
for _, item := range docs {
|
||||
|
|
|
@ -61,6 +61,7 @@ func init() {
|
|||
|
||||
beego.Router("/docs/:key", &controllers.DocumentController{},"*:Index")
|
||||
beego.Router("/docs/:key/:id", &controllers.DocumentController{},"*:Read")
|
||||
beego.Router("/docs/:key/search", &controllers.DocumentController{},"post:Search")
|
||||
beego.Router("/export/:key", &controllers.DocumentController{},"*:Export")
|
||||
beego.Router("/qrcode/:key.png",&controllers.DocumentController{},"get:QrCode")
|
||||
|
||||
|
|
|
@ -138,9 +138,6 @@ h6 {
|
|||
.m-manual .manual-tab .tab-navg {
|
||||
zoom:1;border-bottom: 1px solid #ddd
|
||||
}
|
||||
.m-manual .manual-tab .tab-navg {
|
||||
zoom:1;border-bottom: 1px solid #ddd
|
||||
}
|
||||
|
||||
.m-manual .manual-tab .tab-util {
|
||||
position: absolute;
|
||||
|
@ -244,16 +241,14 @@ h6 {
|
|||
.m-manual .manual-tab .tab-navg .navg-item.active .icon,.m-manual .manual-tab .tab-navg .navg-item.active:hover .icon,.m-manual .manual-tab .tab-navg .navg-item:hover .icon {
|
||||
color: #333
|
||||
}
|
||||
.m-manual .manual-catalog {
|
||||
display: block !important;
|
||||
}
|
||||
.m-manual .manual-tab .tab-navg .navg-item.active {
|
||||
border-bottom: 1px solid #fafafa;
|
||||
margin-bottom: -1px;
|
||||
border-left: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px
|
||||
padding-right: 8px;
|
||||
height: 31px;
|
||||
}
|
||||
.m-manual .manual-tab .tab-item {
|
||||
display: none;
|
||||
|
@ -270,6 +265,24 @@ h6 {
|
|||
.m-manual .manual-tab .tab-item.active {
|
||||
display: block
|
||||
}
|
||||
.m-manual.manual-mode-search .manual-search {
|
||||
display: block
|
||||
}
|
||||
.m-manual.manual-mode-view .manual-catalog {
|
||||
display: block
|
||||
}
|
||||
.m-manual .manual-search .search-form{
|
||||
margin: 5px ;
|
||||
position: relative;
|
||||
}
|
||||
.m-manual .manual-search .btn-search{
|
||||
background-color: #ffffff;
|
||||
border: 0;
|
||||
padding: 5px;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 5px;
|
||||
}
|
||||
.m-manual .manual-left .m-copyright {
|
||||
border-top: 0;
|
||||
background: #fafafa;
|
||||
|
@ -322,6 +335,13 @@ h6 {
|
|||
position: relative;
|
||||
zoom:1;padding: 10px 20px
|
||||
}
|
||||
.manual-reader .book-title{
|
||||
color: #333333;
|
||||
}
|
||||
.manual-reader .book-title:hover{
|
||||
text-decoration: none;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.manual-article .article-head h1 {
|
||||
margin: 0;
|
||||
|
|
|
@ -28,12 +28,12 @@
|
|||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="m-manual manual-reader">
|
||||
<div class="m-manual manual-mode-view manual-reader">
|
||||
<header class="navbar navbar-static-top manual-head" role="banner">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header pull-left manual-title">
|
||||
<span class="slidebar" id="slidebar"><i class="fa fa-align-justify"></i></span>
|
||||
{{.Model.BookName}}
|
||||
<a href="{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" title="{{.Model.BookName}}" class="book-title">{{.Model.BookName}}</a>
|
||||
<span style="font-size: 12px;font-weight: 100;"></span>
|
||||
</div>
|
||||
<div class="navbar-header pull-right manual-menu">
|
||||
|
@ -67,6 +67,7 @@
|
|||
<div class="manual-tab">
|
||||
<div class="tab-navg">
|
||||
<span data-mode="view" class="navg-item active"><i class="fa fa-align-justify"></i><b class="text">目录</b></span>
|
||||
<span data-mode="search" class="navg-item"><i class="fa fa-search"></i><b class="text">搜索</b></span>
|
||||
</div>
|
||||
<div class="tab-util">
|
||||
<span class="manual-fullscreen-switch">
|
||||
|
@ -81,6 +82,25 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<div class="tab-item manual-search">
|
||||
<div class="search-container">
|
||||
<div class="search-form">
|
||||
<form id="searchForm" action="{{urlfor "DocumentController.Search" ":key" .Model.Identify}}" method="post">
|
||||
<div class="form-group">
|
||||
<input type="search" placeholder="请输入搜索关键字" class="form-control" name="keyword">
|
||||
<button type="submit" class="btn btn-default btn-search">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="search-result">
|
||||
<ul class="search-list">
|
||||
<li data-id="256300"><span class="text">下载及安装</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-copyright">
|
||||
|
@ -195,6 +215,7 @@
|
|||
</div>
|
||||
<script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}"></script>
|
||||
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
|
||||
<script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
|
||||
<script src="{{cdnjs "/static/jstree/3.3.4/jstree.min.js"}}" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="{{cdnjs "/static/nprogress/nprogress.js"}}"></script>
|
||||
<script type="text/javascript" src="{{cdnjs "/static/highlight/highlight.js"}}"></script>
|
||||
|
@ -311,6 +332,24 @@
|
|||
initHighlighting();
|
||||
|
||||
});
|
||||
|
||||
$(".navg-item[data-mode]").on("click",function () {
|
||||
var mode = $(this).data('mode');
|
||||
$(this).siblings().removeClass('active').end().addClass('active');
|
||||
$(".m-manual").removeClass("manual-mode-view manual-mode-collect manual-mode-search").addClass("manual-mode-" + mode);
|
||||
});
|
||||
|
||||
$("#searchForm").ajaxForm({
|
||||
beforeSubmit : function () {
|
||||
var keyword = $.trim($("#searchForm").find("input[name='keyword']").val());
|
||||
if(keyword === ""){
|
||||
return false;
|
||||
}
|
||||
},
|
||||
success :function () {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue