diff --git a/controllers/BaseController.go b/controllers/BaseController.go index f8dbc786..85a11f13 100644 --- a/controllers/BaseController.go +++ b/controllers/BaseController.go @@ -161,7 +161,6 @@ func (c *BaseController) ShowErrorPage(errCode int, errMsg string) { if errCode >= 200 && errCode <= 510 { c.CustomAbort(errCode, buf.String()) }else{ - c.CustomAbort(200, buf.String()) + c.CustomAbort(500, buf.String()) } - } diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index 56d47374..ff92f06b 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -120,7 +120,7 @@ func (c *DocumentController) Read() { doc, err = doc.FromCacheById(docId) if err != nil { beego.Error("从缓存中读取文档时失败 ->", err) - c.ShowErrorPage(500, "文档不存在或已删除") + c.ShowErrorPage(404, "文档不存在或已删除") } } else { doc, err = doc.FromCacheByIdentify(id, bookResult.BookId) diff --git a/static/js/markdown.js b/static/js/markdown.js index 6d9983f5..9ad1a8d0 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -202,10 +202,8 @@ $(function () { timeout : 30000, dataType: "json", success: function (res) { - layer.close(index); if (res.errcode === 0) { resetEditorChanged(false); - window.saveing = false; for (var i in window.documentCategory) { var item = window.documentCategory[i]; @@ -230,8 +228,10 @@ $(function () { } }, error : function (XMLHttpRequest, textStatus, errorThrown) { - layer.close(index); layer.msg("服务器错误:" + errorThrown); + }, + complete :function () { + layer.close(index); window.saveing = false; } }); diff --git a/static/js/quill.js b/static/js/quill.js index 039c0196..fdd3cf8e 100644 --- a/static/js/quill.js +++ b/static/js/quill.js @@ -138,7 +138,7 @@ $(function () { pushVueLists(res.data.attach); initHighlighting(); - + setLastSelectNode($node); }else{ layer.msg("文档加载失败"); } @@ -182,13 +182,13 @@ $(function () { $.ajax({ beforeSend : function () { index = layer.load(1, {shade: [0.1,'#fff'] }); + window.saveing = true; }, url : window.editURL, data : {"identify" : window.book.identify,"doc_id" : doc_id,"markdown" : content,"html" : html,"cover" : $is_cover ? "yes":"no","version": version}, type :"post", dataType :"json", success : function (res) { - layer.close(index); if(res.errcode === 0){ for(var i in window.documentCategory){ var item = window.documentCategory[i]; @@ -214,6 +214,13 @@ $(function () { }else{ layer.msg(res.message); } + }, + error : function (XMLHttpRequest, textStatus, errorThrown) { + layer.msg("服务器错误:" + errorThrown); + }, + complete :function () { + layer.close(index); + window.saveing = false; } }); } @@ -317,17 +324,8 @@ $(function () { } }).on('loaded.jstree', function () { window.treeCatalog = $(this).jstree(); - var $select_node_id = window.treeCatalog.get_selected(); - if ($select_node_id) { - var $select_node = window.treeCatalog.get_node($select_node_id[0]) - if ($select_node) { - $select_node.node = { - id: $select_node.id - }; - - loadDocument($select_node); - } - } + //如果没有选中节点则选中默认节点 + openLastSelectedNode(); }).on('select_node.jstree', function (node, selected, event) { if(window.menu_save.hasClass('change')) { diff --git a/uploads/20170501203542.png b/uploads/20170501203542.png index d1f3e78e..b44b3e87 100644 Binary files a/uploads/20170501203542.png and b/uploads/20170501203542.png differ diff --git a/uploads/20170501203656.png b/uploads/20170501203656.png index fc22e19a..0828f04b 100644 Binary files a/uploads/20170501203656.png and b/uploads/20170501203656.png differ diff --git a/uploads/20170501204438.png b/uploads/20170501204438.png index d00d8691..22310ef2 100644 Binary files a/uploads/20170501204438.png and b/uploads/20170501204438.png differ diff --git a/uploads/20170501204609.png b/uploads/20170501204609.png index 3b20e6fa..4942f2b1 100644 Binary files a/uploads/20170501204609.png and b/uploads/20170501204609.png differ diff --git a/uploads/20170501204651.png b/uploads/20170501204651.png index 06a753f7..f94571f2 100644 Binary files a/uploads/20170501204651.png and b/uploads/20170501204651.png differ diff --git a/views/errors/error.tpl b/views/errors/error.tpl index 6819cb0d..448a1895 100644 --- a/views/errors/error.tpl +++ b/views/errors/error.tpl @@ -7,7 +7,7 @@ - 服务器异常 - Powered by MinDoc + {{if eq 200 .ErrorCode}}友情提示{{else if eq 404 .ErrorCode}}页面不存在{{else}}服务器异0常{{end}} - Powered by MinDoc