diff --git a/app_admin/views.py b/app_admin/views.py index e89359571..b019c90f7 100644 --- a/app_admin/views.py +++ b/app_admin/views.py @@ -192,6 +192,7 @@ def register(request): # 注销 +@require_POST def log_out(request): try: logout(request) @@ -199,13 +200,13 @@ def log_out(request): for c in list(request.COOKIES.keys()): if c.startswith('viewcode-'): project_viewcode_list.append(c) - resp = redirect(request.META['HTTP_REFERER']) + resp = request.META['HTTP_REFERER'] for c in project_viewcode_list: resp.delete_cookie(c) - return resp + return JsonResponse({'status': True, 'data': resp}) except Exception as e: logger.exception(_("注销异常")) - return redirect(request.META['HTTP_REFERER']) + return JsonResponse({'status':False}) # 忘记密码 diff --git a/template/app_admin/admin_center.html b/template/app_admin/admin_center.html index 667c90ce6..89a649f89 100644 --- a/template/app_admin/admin_center.html +++ b/template/app_admin/admin_center.html @@ -42,7 +42,7 @@
个人中心
{% endif %}
返回首页
-
退出登录
+
退出登录
@@ -168,5 +168,25 @@ admin.render(pear_admin_config); }) + diff --git a/template/app_doc/head_base.html b/template/app_doc/head_base.html index aca66788b..4d81498cc 100644 --- a/template/app_doc/head_base.html +++ b/template/app_doc/head_base.html @@ -94,7 +94,7 @@
- + {% trans "退出登录" %} @@ -134,4 +134,22 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/template/app_doc/search_result.html b/template/app_doc/search_result.html index c694dad88..706f495dc 100644 --- a/template/app_doc/search_result.html +++ b/template/app_doc/search_result.html @@ -83,7 +83,7 @@
- + {% trans "退出登录" %} @@ -394,6 +394,22 @@

}, }) }; + function Logout(){ + $.ajax({ + url:"{% url 'logout' %}", + method:'post', + success:function(r){ + if(r.status){ + window.location.href = r.data + }else{ + layer.msg("注销失败") + } + }, + error:function(){ + layer.msg("注销失败") + } + }) + } {% if debug %} diff --git a/template/app_doc/user/user_center.html b/template/app_doc/user/user_center.html index 91ce0539d..390113045 100644 --- a/template/app_doc/user/user_center.html +++ b/template/app_doc/user/user_center.html @@ -41,7 +41,7 @@
{% trans "后台管理" %}
{% endif %}
{% trans "返回首页" %}
-
{% trans "退出登录" %}
+
{% trans "退出登录" %}
@@ -167,5 +167,25 @@ admin.render(pear_admin_config); }) + diff --git a/template/search/search.html b/template/search/search.html index 279ab0546..a1692b33e 100644 --- a/template/search/search.html +++ b/template/search/search.html @@ -74,7 +74,7 @@

- + {% trans "退出登录" %} @@ -305,7 +305,22 @@

} } tagCurrentSearchType(); - + function Logout(){ + $.ajax({ + url:"{% url 'logout' %}", + method:'post', + success:function(r){ + if(r.status){ + window.location.href = r.data + }else{ + layer.msg("注销失败") + } + }, + error:function(){ + layer.msg("注销失败") + } + }) + } {% if debug %}