From df9dd9dd7b20b0cb51dc6cda5d60320eece7d56f Mon Sep 17 00:00:00 2001 From: yangjian Date: Mon, 19 Jul 2021 20:42:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E6=A1=A3=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E7=9A=84=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 1 + template/app_doc/editor/create_doc.html | 62 +++++++++++++++---------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 465b407..3d01888 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ - [修复]文档访问权限可绕过的问题; - [优化]个人中心我协作的文集页面及功能; - [优化]后台邮件服务器配置逻辑和页面展示; +- [优化]文档发布的异常判断和处理; ### v0.6.8 2021-06-27 diff --git a/template/app_doc/editor/create_doc.html b/template/app_doc/editor/create_doc.html index 1aa26fd..ffdcfd6 100644 --- a/template/app_doc/editor/create_doc.html +++ b/template/app_doc/editor/create_doc.html @@ -307,33 +307,47 @@ //发布按钮设为禁用 $("#create_doc").attr({"disabled":"disabled"}); layer.load(); // 加载提示 - $.post("{% url 'create_doc' %}",data,function(r){ - if(r.status){ - //创建成功 - layer.closeAll("loading"); //关闭加载层 - window.localStorage.removeItem('mrdoc_doc_cache') // 清空文档缓存 - if(status === 1){ - layer.msg('发布成功',{time:1000},function(){ - md_changed = false; - //跳转到文档修改 - window.location.href = "/modify_doc/"+r.data.doc+"/"; - }); + $.ajax({ + url:"{% url 'create_doc' %}", + type:'post', + data:data, + success:function(r){ + if(r.status){ + //创建成功 + layer.closeAll("loading"); //关闭加载层 + window.localStorage.removeItem('mrdoc_doc_cache') // 清空文档缓存 + if(status === 1){ + layer.msg('发布成功',{time:1000},function(){ + md_changed = false; + //跳转到文档修改 + window.location.href = "/modify_doc/"+r.data.doc+"/"; + }); + }else{ + layer.msg('保存成功',{time:1000},function(){ + md_changed = false; + //跳转到文档修改 + window.location.href = "/modify_doc/"+r.data.doc+"/"; + }); + } }else{ - layer.msg('保存成功',{time:1000},function(){ - md_changed = false; - //跳转到文档修改 - window.location.href = "/modify_doc/"+r.data.doc+"/"; - }); + //创建失败 + layer.closeAll("loading"); //关闭加载层 + layer.msg('发布文档失败:'+r.data); + //恢复按钮状态 + $('button.layui-btn').attr("disabled",false); + $('button.layui-btn').removeClass('layui-btn-disabled'); } - }else{ - //创建失败 - layer.closeAll("loading"); //关闭加载层 - layer.msg('发布文档失败:'+r.data); - //恢复按钮状态 - $('button.layui-btn').attr("disabled",false); - $('button.layui-btn').removeClass('layui-btn-disabled'); + }, + error:function(){ + //创建失败 + layer.closeAll("loading"); //关闭加载层 + layer.msg('发布文档异常!'); + //恢复按钮状态 + $('button.layui-btn').attr("disabled",false); + $('button.layui-btn').removeClass('layui-btn-disabled'); + } - }); + }) } };