From 10b428ddf60226ceb24c7ad7c52a1aa027d945f0 Mon Sep 17 00:00:00 2001 From: yangjian Date: Wed, 16 Dec 2020 22:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_doc/views.py | 27 +++++++++---------------- template/app_doc/editor/create_doc.html | 14 ++++++------- template/app_doc/editor/modify_doc.html | 8 ++++---- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/app_doc/views.py b/app_doc/views.py index 6db17dd..c930ef5 100644 --- a/app_doc/views.py +++ b/app_doc/views.py @@ -890,14 +890,11 @@ def create_doc(request): except ObjectDoesNotExist: editor_mode = 1 if request.method == 'GET': - try: - # 获取url中自定义编辑器模式 - eid = request.GET.get('eid',0) - if eid in [1,2,3,'1','2','3']: - editor_mode = int(eid) - except Exception as e: - # 异常直接跳过使用设置中的mode - pass + # 获取url切换的编辑器模式 + eid = request.GET.get('eid',editor_mode) + if eid in [1,2,3,'1','2','3']: + editor_mode = int(eid) + try: editor_type = "新建文档" pid = request.GET.get('pid',-999) @@ -917,7 +914,7 @@ def create_doc(request): doc_content = request.POST.get('content','') # 文档内容 pre_content = request.POST.get('pre_content','') # 文档Markdown内容 sort = request.POST.get('sort','') # 文档排序 - editor_mode = request.POST.get('editor_mode','') #获取文档编辑器 + editor_mode = request.POST.get('editor_mode',editor_mode) #获取文档编辑器 status = request.POST.get('status',1) # 文档状态 open_children = request.POST.get('open_children', False) # 展示下级目录 show_children = request.POST.get('show_children', False) # 展示下级目录 @@ -981,17 +978,11 @@ def create_doc(request): @require_http_methods(['GET',"POST"]) def modify_doc(request,doc_id): editor_type = "修改文档" - # 获取用户的编辑器模式 - # try: - # user_opt = UserOptions.objects.get(user=request.user) - # editor_mode = user_opt.editor_mode - # except ObjectDoesNotExist: - # editor_mode = 1 if request.method == 'GET': try: doc = Doc.objects.get(id=doc_id) # 查询文档信息 - editor_mode = doc.editor_mode - eid = request.GET.get('eid',0) + editor_mode = doc.editor_mode # 设置文档编辑器为文档上一次使用的编辑模式 + eid = request.GET.get('eid',editor_mode) if eid in [1,2,3,'1','2','3']: editor_mode = int(eid) doc_tags = ','.join([i.tag.name for i in DocTag.objects.filter(doc=doc)]) # 查询文档标签信息 @@ -1029,7 +1020,7 @@ def modify_doc(request,doc_id): doc_content = request.POST.get('content', '') # 文档内容 pre_content = request.POST.get('pre_content', '') # 文档Markdown格式内容 sort = request.POST.get('sort', '') # 文档排序 - editor_mode = request.POST.get('editor_mode','') #获取文档编辑器 + editor_mode = request.POST.get('editor_mode',1) #获取文档编辑器 status = request.POST.get('status',1) # 文档状态 open_children = request.POST.get('open_children',False) # 展示下级目录 show_children = request.POST.get('show_children', False) # 展示下级目录 diff --git a/template/app_doc/editor/create_doc.html b/template/app_doc/editor/create_doc.html index 9f7bf6f..09cf816 100644 --- a/template/app_doc/editor/create_doc.html +++ b/template/app_doc/editor/create_doc.html @@ -32,7 +32,7 @@
- +