Skip to content

Commit

Permalink
opt: opt index view load speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Dec 13, 2020
1 parent a9e4582 commit 838ceb0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 0 additions & 3 deletions apps/sspanel/static/sspanel/js/sspanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ $(function () {
$(window).resize(footerPosition);
});




'use strict';

document.addEventListener('DOMContentLoaded', function () {
Expand Down
15 changes: 10 additions & 5 deletions apps/sspanel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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("已经关闭注册了喵")

Expand All @@ -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):
Expand All @@ -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)


Expand Down
10 changes: 7 additions & 3 deletions templates/basehead.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
<link rel="stylesheet" href="https://cdn.staticfile.org/bulma/0.9.0/css/bulma.min.css" rel="stylesheet">
{% endif %}
<link rel="stylesheet" href="{% static 'sspanel/css/sspanel.css'%}">
{% if not simple_extra_static %}
<link rel="stylesheet" href="https://cdn.staticfile.org/flag-icon-css/3.5.0/css/flag-icon.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/5.14.0/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/simplemde/1.9.0/simplemde.min.css">
{% endif %}

<!-- js -->
<script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/sweetalert/2.1.2/sweetalert.min.js"></script>
{% if not simple_extra_static %}
<script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script>
<script src="{% static 'sspanel/js/sspanel.js' %}"></script>
<script src="https://cdn.staticfile.org/Chart.js/2.9.3/Chart.min.js"></script>
<script src="https://cdn.staticfile.org/clipboard.js/1.7.1/clipboard.min.js"></script>
<script src="https://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script src="{% static 'sspanel/js/sspanel.js' %}"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/simplemde/1.9.0/simplemde.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/simplemde/1.9.0/simplemde.min.js"></script>
{% endif %}

0 comments on commit 838ceb0

Please sign in to comment.