mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
修复文档查看返回BUG
This commit is contained in:
@@ -85,7 +85,7 @@ func (c *BaseController) JsonResult(errCode int, errMsg string, data ...interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/json; charset=utf-8")
|
c.Ctx.ResponseWriter.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
c.Ctx.ResponseWriter.Header().Set("Cache-Control", "no-cache, no-store")
|
||||||
io.WriteString(c.Ctx.ResponseWriter, string(returnJSON))
|
io.WriteString(c.Ctx.ResponseWriter, string(returnJSON))
|
||||||
|
|
||||||
c.StopRun()
|
c.StopRun()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function loadDocument($url, $id, $callback) {
|
|||||||
$("#article-title").text(doc_title);
|
$("#article-title").text(doc_title);
|
||||||
$("#article-info").text(doc_info);
|
$("#article-info").text(doc_info);
|
||||||
|
|
||||||
events.trigger('article.open', { $url : $url, $init : false, $id : $id });
|
events.trigger('article.open', { $url : $url, $id : $id });
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ function loadDocument($url, $id, $callback) {
|
|||||||
events.data('doc_title_' + $id, doc_title);
|
events.data('doc_title_' + $id, doc_title);
|
||||||
events.data('doc_info_' + $id, doc_info);
|
events.data('doc_info_' + $id, doc_info);
|
||||||
|
|
||||||
events.trigger('article.open', { $url : $url, $init : true, $id : $id });
|
events.trigger('article.open', { $url : $url, $id : $id });
|
||||||
} else if (res.errcode === 6000) {
|
} else if (res.errcode === 6000) {
|
||||||
window.location.href = "/";
|
window.location.href = "/";
|
||||||
} else {
|
} else {
|
||||||
@@ -138,11 +138,20 @@ $(function () {
|
|||||||
|
|
||||||
// 处理打开事件
|
// 处理打开事件
|
||||||
events.on('article.open', function (event, $param) {
|
events.on('article.open', function (event, $param) {
|
||||||
|
|
||||||
|
var prevState = window.history.state || {};
|
||||||
if ('pushState' in history) {
|
if ('pushState' in history) {
|
||||||
if ($param.$init === false) {
|
// if ($param.$init === false) {
|
||||||
window.history.replaceState($param, $param.$id, $param.$url);
|
// window.history.replaceState($param, $param.$id, $param.$url);
|
||||||
|
// } else {
|
||||||
|
// window.history.pushState($param, $param.$id, $param.$url);
|
||||||
|
// }
|
||||||
|
|
||||||
|
if ($param.$id) {
|
||||||
|
prevState.$id === $param.$id || window.history.pushState($param, $param.$id, $param.$url);
|
||||||
} else {
|
} else {
|
||||||
window.history.pushState($param, $param.$id, $param.$url);
|
window.history.pushState($param, $param.$id, $param.$url);
|
||||||
|
window.history.replaceState($param, $param.$id, $param.$url);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.location.hash = $param.$url;
|
window.location.hash = $param.$url;
|
||||||
@@ -196,12 +205,15 @@ $(function () {
|
|||||||
|
|
||||||
window.onpopstate = function (e) {
|
window.onpopstate = function (e) {
|
||||||
var $param = e.state;
|
var $param = e.state;
|
||||||
console.log($param);
|
if (!$param) return;
|
||||||
if($param.hasOwnProperty("$url")) {
|
if($param.hasOwnProperty("$url")) {
|
||||||
window.jsTree.jstree().deselect_all();
|
window.jsTree.jstree().deselect_all();
|
||||||
|
|
||||||
window.jsTree.jstree().select_node({ id : $param.$id });
|
if ($param.$id) {
|
||||||
$param.$init = false;
|
window.jsTree.jstree().select_node({ id : $param.$id });
|
||||||
|
}else{
|
||||||
|
window.location.assign($param.$url);
|
||||||
|
}
|
||||||
// events.trigger('article.open', $param);
|
// events.trigger('article.open', $param);
|
||||||
} else {
|
} else {
|
||||||
console.log($param);
|
console.log($param);
|
||||||
@@ -209,9 +221,9 @@ $(function () {
|
|||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
var $node = window.jsTree.jstree().get_selected();
|
var $node = window.jsTree.jstree().get_selected();
|
||||||
if (typeof $node === "object") {
|
if ($node instanceof Array && $node.length) {
|
||||||
$node = window.jsTree.jstree().get_node({ id: $node[0] });
|
$node = window.jsTree.jstree().get_node({ id: $node[0] });
|
||||||
events.trigger('article.open', { $url: $node.a_attr.href, $init: true, $id: $node.a_attr.id });
|
events.trigger('article.open', { $url: $node.a_attr.href, $id: $node.id });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body" id="userList">
|
||||||
<div class="users-list" id="userList">
|
<div class="users-list">
|
||||||
<template v-if="lists.length <= 0">
|
<template v-if="lists.length <= 0">
|
||||||
<div class="text-center">暂无数据</div>
|
<div class="text-center">暂无数据</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -86,6 +86,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
<template v-if="lists.length >= 0">
|
||||||
|
<nav class="pagination-container">
|
||||||
|
{{.PageHtml}}
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user