Forráskód Böngészése

修改了退出登录后在已经打开的页面上切换文档时呈现的一直处于加载中的假象。

Dandy Cheung 7 éve
szülő
commit
15ad23a030
3 módosított fájl, 193 hozzáadás és 116 törlés
  1. 2 3
      TODO
  2. 174 97
      controllers/document.go
  3. 17 16
      static/js/kancloud.js

+ 2 - 3
TODO

@@ -1,6 +1,6 @@
-1、把 log 提取出 dbgout 之类的方法;
+1、把 log 提取出 dbgout 之类的方法;已改作 beego.Info() 调用;
 2、把源代码里的 TODO 完成;
-3、Export 的两个 URL 应该可以合并,用是否有 :id 来区分;这样 0 号文档输出整个 book 更顺;
+3、Export 的两个 URL 应该可以合并,用是否有 :id 来区分;这样 0 号文档输出整个 book 更顺;已完成;
 4、统一代码风格,空格、命名之类的;
 5、美化 PDF 的输出格式;
 6、自动登录新开标签页而且并不能跳转至起始请求页的问题;
@@ -8,4 +8,3 @@
 8、[自动]展示历史版本;增强历史版本对比显示的能力;
 9、[自动]展示作者信息;也许可以和上一需求合并考虑;
 10、查看了解评论功能;
-

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 174 - 97
controllers/document.go


+ 17 - 16
static/js/kancloud.js

@@ -4,17 +4,17 @@
  * @param $id
  * @param $callback
  */
-function loadDocument($url,$id,$callback) {
+function loadDocument($url, $id, $callback) {
     $.ajax({
         url : $url,
         type : "GET",
-        beforeSend :function (xhr) {
+        beforeSend : function (xhr) {
             var body = events.data('body_' + $id);
             var title = events.data('title_' + $id);
             var doc_title = events.data('doc_title_' + $id);
             var doc_info = events.data('doc_info_' + $id);
 
-            if(body && title && doc_title) {
+            if (body && title && doc_title) {
                 if (typeof $callback === "function") {
                     body = $callback(body);
                 }
@@ -24,7 +24,7 @@ function loadDocument($url,$id,$callback) {
                 $("#article-title").text(doc_title);
                 $("#article-info").text(doc_info);
 
-                events.trigger('article.open', { $url : $url, $init : false , $id : $id });
+                events.trigger('article.open', { $url : $url, $init : false, $id : $id });
 
                 return false;
             }
@@ -53,7 +53,8 @@ function loadDocument($url,$id,$callback) {
                 events.data('doc_info_' + $id, doc_info);
 
                 events.trigger('article.open', { $url : $url, $init : true, $id : $id });
-
+            } else if (res.errcode === 6000) {
+                window.location.href = "/";
             } else {
                 layer.msg("加载失败");
             }
@@ -91,7 +92,7 @@ $(function () {
     initHighlighting();
 
     window.jsTree = $("#sidebar").jstree({
-        'plugins':["wholerow", "types"],
+        'plugins' : ["wholerow", "types"],
         "types": {
             "default" : {
                 "icon" : false  // 删除默认图标
@@ -102,7 +103,7 @@ $(function () {
             "multiple" : false,
             'animation' : 0
         }
-    }).on('select_node.jstree',function (node,selected,event) {
+    }).on('select_node.jstree', function (node, selected, event) {
         $(".m-manual").removeClass('manual-mobile-show-left');
         var url = selected.node.a_attr.href;
 
@@ -123,7 +124,7 @@ $(function () {
     /**
      * 关闭侧边栏
      */
-    $(".manual-fullscreen-switch").on("click",function () {
+    $(".manual-fullscreen-switch").on("click", function () {
         isFullScreen = !isFullScreen;
         if (isFullScreen) {
             $(".m-manual").addClass('manual-fullscreen-active');
@@ -148,7 +149,7 @@ $(function () {
         $(".manual-right").scrollTop(0);
     });
 
-    $(".navg-item[data-mode]").on("click",function () {
+    $(".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);
@@ -160,23 +161,23 @@ $(function () {
     $("#searchForm").ajaxForm({
         beforeSubmit : function () {
             var keyword = $.trim($("#searchForm").find("input[name='keyword']").val());
-            if(keyword === ""){
+            if (keyword === "") {
                 $(".search-empty").show();
                 $("#searchList").html("");
                 return false;
             }
-            $("#btnSearch").attr("disabled","disabled").find("i").removeClass("fa-search").addClass("loading");
+            $("#btnSearch").attr("disabled", "disabled").find("i").removeClass("fa-search").addClass("loading");
             window.keyword = keyword;
         },
         success : function (res) {
             var html = "";
-            if(res.errcode === 0){
-                for(var i in res.data){
+            if (res.errcode === 0) {
+                for(var i in res.data) {
                     var item = res.data[i];
                     html += '<li><a href="javascript:;" title="' + item.doc_name + '" data-id="' + item.doc_id + '"> ' + item.doc_name + ' </a></li>';
                 }
             }
-            if(html !== "") {
+            if (html !== "") {
                 $(".search-empty").hide();
             } else {
                 $(".search-empty").show();
@@ -204,8 +205,8 @@ $(function () {
     try {
         var $node = window.jsTree.jstree().get_selected();
         if (typeof $node === "object") {
-            $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});
+            $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 });
         }
     } catch (e) {
         console.log(e);

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott