Initial commit
This commit is contained in:
57
templates/base.html
Normal file
57
templates/base.html
Normal file
@@ -0,0 +1,57 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>File Share System</title>
|
||||
<link href="{% static 'css/output.css' %}" rel="stylesheet">
|
||||
</head>
|
||||
<body class="bg-gray-100">
|
||||
<nav class="bg-white shadow">
|
||||
<div class="max-w-6xl mx-auto px-4">
|
||||
<div class="flex justify-between">
|
||||
<div class="flex space-x-4">
|
||||
<div>
|
||||
<a href="{% url 'home' %}" class="flex items-center py-5 px-2 text-gray-700 hover:text-gray-900">
|
||||
首页
|
||||
</a>
|
||||
</div>
|
||||
{% if user.is_authenticated %}
|
||||
<div>
|
||||
<a href="{% url 'search' %}" class="flex items-center py-5 px-2 text-gray-700 hover:text-gray-900">
|
||||
搜索
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="flex items-center space-x-1">
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'dashboard' %}" class="py-5 px-3 text-gray-700 hover:text-gray-900">仪表盘</a>
|
||||
<a href="{% url 'upload' %}" class="py-5 px-3 text-gray-700 hover:text-gray-900">上传文件</a>
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'admin:index' %}" class="py-5 px-3 text-gray-700 hover:text-gray-900">管理后台</a>
|
||||
{% endif %}
|
||||
<span class="py-5 px-3 text-gray-700">{{ user.username }}</span>
|
||||
<form action="{% url 'logout' %}" method="post" class="inline" onsubmit="return confirmLogout()">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="py-5 px-3 text-gray-700 hover:text-gray-900">退出</button>
|
||||
</form>
|
||||
<script>
|
||||
function confirmLogout() {
|
||||
return confirm('确定要退出登录吗?');
|
||||
}
|
||||
</script>
|
||||
{% else %}
|
||||
<a href="{% url 'login' %}" class="py-5 px-3 text-gray-700 hover:text-gray-900">登录</a>
|
||||
<a href="{% url 'register' %}" class="py-5 px-3 text-gray-700 hover:text-gray-900">注册</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
35
templates/registration/login.html
Normal file
35
templates/registration/login.html
Normal file
@@ -0,0 +1,35 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-md mx-auto py-8">
|
||||
<h1 class="text-2xl font-bold mb-6">登录</h1>
|
||||
{% if form.errors %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
用户名或密码错误,请重试
|
||||
</div>
|
||||
{% endif %}
|
||||
<form method="post" class="bg-white p-6 rounded-lg shadow">
|
||||
{% csrf_token %}
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="username">
|
||||
用户名
|
||||
</label>
|
||||
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||
type="text" name="username" required>
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">
|
||||
密码
|
||||
</label>
|
||||
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
|
||||
type="password" name="password" required>
|
||||
</div>
|
||||
<div class="flex items-center justify-between">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
|
||||
type="submit">
|
||||
登录
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
32
templates/registration/logout.html
Normal file
32
templates/registration/logout.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-md mx-auto py-8 text-center">
|
||||
<h1 class="text-2xl font-bold mb-6">您已成功退出</h1>
|
||||
<p class="mb-6">正在跳转到首页...</p>
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
setTimeout(function() {
|
||||
window.location.href = "{% url 'home' %}";
|
||||
}, 2000);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.spinner {
|
||||
border: 4px solid #f3f3f3;
|
||||
border-top: 4px solid #3498db;
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
39
templates/registration/register.html
Normal file
39
templates/registration/register.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="max-w-md mx-auto py-8">
|
||||
<h1 class="text-2xl font-bold mb-6">注册</h1>
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<form method="post" class="bg-white p-6 rounded-lg shadow">
|
||||
{% csrf_token %}
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="username">
|
||||
用户名
|
||||
</label>
|
||||
{{ form.username }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="password1">
|
||||
密码
|
||||
</label>
|
||||
{{ form.password1 }}
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="password2">
|
||||
确认密码
|
||||
</label>
|
||||
{{ form.password2 }}
|
||||
</div>
|
||||
<div class="flex items-center justify-between">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
|
||||
type="submit">
|
||||
注册
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user