add 后台管理页面
@@ -1,9 +1,10 @@
|
|||||||
from django.urls import path, include,re_path
|
from django.urls import path, include,re_path
|
||||||
from jump.views import to_index,to_register,to_login
|
from jump.views import to_index,to_register,to_login,to_adminAccess
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', to_index, name="index_jump"), # 跳转首页界面
|
path('', to_index, name="index_jump"), # 跳转首页界面
|
||||||
path('login', to_login, name="login_jump"), # 跳转到登录页面
|
path('login', to_login, name="login_jump"), # 跳转到登录页面
|
||||||
path('register',to_register, name = "register_jump"), # 跳转到注册页面
|
path('register',to_register, name = "register_jump"), # 跳转到注册页面
|
||||||
|
path('adminAccess ',to_adminAccess, name="adminAccess_jump"), # 跳转到后台管理
|
||||||
]
|
]
|
||||||
@@ -28,3 +28,9 @@ def to_register(request):
|
|||||||
注册页面
|
注册页面
|
||||||
"""
|
"""
|
||||||
return render(request,"html/register.html")
|
return render(request,"html/register.html")
|
||||||
|
|
||||||
|
def to_adminAccess(request):
|
||||||
|
"""
|
||||||
|
后台管理
|
||||||
|
"""
|
||||||
|
return render(request,"html/adminAccess.html")
|
||||||
@@ -77,7 +77,7 @@ NAVBAR
|
|||||||
</li>
|
</li>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="./about.html"><span class="badge badge-primary">后台管理</span></a>
|
<a class="nav-link" href="{% url 'adminAccess_jump' %}"><span class="badge badge-primary">后台管理</span></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -89,7 +89,7 @@ NAVBAR
|
|||||||
<ul class="navbar-nav ml-auto d-flex align-items-center">
|
<ul class="navbar-nav ml-auto d-flex align-items-center">
|
||||||
<li class="nav-item highlight">
|
<li class="nav-item highlight">
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<a class="nav-link" href="{% url 'logout_fun' %}?#">Logout</a>
|
<button class="nav-link" id="logout-button">Logout</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="nav-link" href="{% url 'login_jump' %}?#">Login</a>
|
<a class="nav-link" href="{% url 'login_jump' %}?#">Login</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -8,5 +8,31 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
|
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
|
||||||
|
<script>
|
||||||
|
//注销
|
||||||
|
function logout_() {
|
||||||
|
$.ajax({
|
||||||
|
url: '/api/account/logout', // 后端接口地址
|
||||||
|
type: "POST",
|
||||||
|
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||||
|
data: {},
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
alert(data.msg); // 使用 alert 替换 common_alert
|
||||||
|
setTimeout(function () {
|
||||||
|
location.reload();
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(document).ready(function() {
|
||||||
|
// 绑定注销操作到某个按钮点击事件
|
||||||
|
$('#logout-button').click(function(event) {
|
||||||
|
event.preventDefault(); // 阻止默认行为
|
||||||
|
logout_();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M19 8L12 15L5 8" stroke="#4A4C55" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 214 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M19 8L12 15L5 8" stroke="#dee2e6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 214 B |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |