From 838ceb0aab990d4175311ef5beddf32cab1a252c Mon Sep 17 00:00:00 2001 From: Ehco1996 Date: Mon, 14 Dec 2020 07:56:48 +0800 Subject: [PATCH] opt: opt index view load speed --- apps/sspanel/static/sspanel/js/sspanel.js | 3 --- apps/sspanel/views.py | 15 ++++++++++----- templates/basehead.html | 10 +++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/sspanel/static/sspanel/js/sspanel.js b/apps/sspanel/static/sspanel/js/sspanel.js index 9dd42ca459..657c46481a 100644 --- a/apps/sspanel/static/sspanel/js/sspanel.js +++ b/apps/sspanel/static/sspanel/js/sspanel.js @@ -12,9 +12,6 @@ $(function () { $(window).resize(footerPosition); }); - - - 'use strict'; document.addEventListener('DOMContentLoaded', function () { diff --git a/apps/sspanel/views.py b/apps/sspanel/views.py index 63eb6afff7..ee9b47b66d 100644 --- a/apps/sspanel/views.py +++ b/apps/sspanel/views.py @@ -27,17 +27,20 @@ class IndexView(View): def get(self, request): """跳转到首页""" - return render(request, "sspanel/index.html") + context = {"simple_extra_static": True} + return render(request, "sspanel/index.html", context=context) class HelpView(View): def get(self, request): """跳转到帮助界面""" - return render(request, "sspanel/help.html") + context = {"simple_extra_static": True} + return render(request, "sspanel/help.html", context=context) class RegisterView(View): def get(self, request): + context = {"simple_extra_static": True} if request.user.is_authenticated: return HttpResponseRedirect(reverse("sspanel:userinfo")) if request.GET.get("ref"): @@ -47,6 +50,7 @@ def get(self, request): return render(request, "sspanel/register.html", {"form": form}) def post(self, request): + context = {"simple_extra_static": True} if not settings.ALLOW_REGISTER: return HttpResponse("已经关闭注册了喵") @@ -64,7 +68,8 @@ def post(self, request): ) login(request, user) return HttpResponseRedirect(reverse("sspanel:userinfo")) - return render(request, "sspanel/register.html", {"form": form}) + context["form":form] + return render(request, "sspanel/register.html", context=context) class UserLogInView(View): @@ -82,11 +87,11 @@ def post(self, request): else: messages.error(request, "请重新填写信息!", extra_tags="登录失败!") - context = {"form": LoginForm()} + context = {"form": LoginForm(), "simple_extra_static": True} return render(request, "sspanel/login.html", context=context) def get(self, request): - context = {"form": LoginForm()} + context = {"form": LoginForm(), "simple_extra_static": True} return render(request, "sspanel/login.html", context=context) diff --git a/templates/basehead.html b/templates/basehead.html index c1f0de7f48..5276f90a19 100644 --- a/templates/basehead.html +++ b/templates/basehead.html @@ -10,15 +10,19 @@ {% endif %} +{% if not simple_extra_static %} +{% endif %} - +{% if not simple_extra_static %} + + - - \ No newline at end of file + +{% endif %} \ No newline at end of file