init
This commit is contained in:
45
templates/auth/change_password.html
Normal file
45
templates/auth/change_password.html
Normal file
@@ -0,0 +1,45 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}修改密码 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}修改密码{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6 max-w-2xl mx-auto">
|
||||
<h2 class="text-xl font-semibold mb-6">修改账户密码</h2>
|
||||
|
||||
{% 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">
|
||||
<div class="mb-4">
|
||||
<label for="current_password" class="block text-gray-700 text-sm font-bold mb-2">当前密码</label>
|
||||
<input type="password" id="current_password" name="current_password" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="new_password" class="block text-gray-700 text-sm font-bold mb-2">新密码</label>
|
||||
<input type="password" id="new_password" name="new_password" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label for="confirm_password" class="block text-gray-700 text-sm font-bold mb-2">确认新密码</label>
|
||||
<input type="password" id="confirm_password" name="confirm_password" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div class="flex items-center justify-between">
|
||||
<button type="submit"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
|
||||
修改密码
|
||||
</button>
|
||||
<a href="{{ url_for('main.index') }}"
|
||||
class="inline-block align-baseline font-bold text-sm text-blue-600 hover:text-blue-800">
|
||||
返回首页
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
37
templates/auth/login.html
Normal file
37
templates/auth/login.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}登录 - PT Manager{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="flex items-center justify-center min-h-full">
|
||||
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
|
||||
<div class="text-center mb-6">
|
||||
<h1 class="text-2xl font-bold text-gray-800">PT Manager</h1>
|
||||
<p class="text-gray-600">请登录您的账户</p>
|
||||
</div>
|
||||
|
||||
{% 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">
|
||||
<div class="mb-4">
|
||||
<label for="username" class="block text-gray-700 text-sm font-bold mb-2">用户名</label>
|
||||
<input type="text" id="username" name="username" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label for="password" class="block text-gray-700 text-sm font-bold mb-2">密码</label>
|
||||
<input type="password" id="password" name="password" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<button type="submit"
|
||||
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
|
||||
登录
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
87
templates/base.html
Normal file
87
templates/base.html
Normal file
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}PT Manager{% endblock %}</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
<body class="bg-gray-100">
|
||||
<div class="flex h-screen">
|
||||
<!-- Sidebar -->
|
||||
{% if session.user_id %}
|
||||
<div class="w-64 bg-blue-800 text-white">
|
||||
<div class="p-4 border-b border-blue-700">
|
||||
<h1 class="text-xl font-semibold">PT Manager</h1>
|
||||
<p class="text-blue-200 text-sm">{{ session.username }}</p>
|
||||
</div>
|
||||
<nav class="mt-4">
|
||||
<a href="{{ url_for('main.index') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700 {% if request.endpoint == 'main.index' %}bg-blue-700{% endif %}">
|
||||
<i class="fas fa-home mr-3"></i> 首页
|
||||
</a>
|
||||
<a href="{{ url_for('site.site_index') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700 {% if request.endpoint and 'site.' in request.endpoint %}bg-blue-700{% endif %}">
|
||||
<i class="fas fa-globe mr-3"></i> 站点
|
||||
</a>
|
||||
<a href="{{ url_for('qbittorrent.qbittorrent_index') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700 {% if request.endpoint and 'qbittorrent.' in request.endpoint %}bg-blue-700{% endif %}">
|
||||
<i class="fas fa-download mr-3"></i> qBittorrent
|
||||
</a>
|
||||
<a href="{{ url_for('transmission.transmission_index') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700 {% if request.endpoint and 'transmission.' in request.endpoint %}bg-blue-700{% endif %}">
|
||||
<i class="fas fa-cloud-download-alt mr-3"></i> Transmission
|
||||
</a>
|
||||
{% if session.role == 'admin' %}
|
||||
<a href="{{ url_for('user.user_index') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700 {% if request.endpoint and 'user.' in request.endpoint %}bg-blue-700{% endif %}">
|
||||
<i class="fas fa-users mr-3"></i> 用户管理
|
||||
</a>
|
||||
<a href="{{ url_for('settings.settings_index') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700 {% if request.endpoint and 'settings.' in request.endpoint %}bg-blue-700{% endif %}">
|
||||
<i class="fas fa-cog mr-3"></i> 设置
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('auth.change_password') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700 {% if request.endpoint == 'auth.change_password' %}bg-blue-700{% endif %}">
|
||||
<i class="fas fa-key mr-3"></i> 修改密码
|
||||
</a>
|
||||
<a href="{{ url_for('auth.logout') }}" class="flex items-center px-4 py-3 text-sm hover:bg-blue-700">
|
||||
<i class="fas fa-sign-out-alt mr-3"></i> 登出
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="flex-1 flex flex-col overflow-hidden">
|
||||
{% if session.user_id %}
|
||||
<header class="bg-white shadow">
|
||||
<div class="flex justify-between items-center px-6 py-4">
|
||||
<h2 class="text-lg font-semibold text-gray-800">{% block page_title %}{% endblock %}</h2>
|
||||
<div class="flex items-center">
|
||||
<span class="text-gray-600 mr-4">欢迎, {{ session.username }}</span>
|
||||
<span class="bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded">{{ session.role }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
{% endif %}
|
||||
|
||||
<main class="flex-1 overflow-y-auto p-6 bg-gray-100">
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="bg-blue-100 border-l-4 border-blue-500 text-blue-700 p-4 mb-4" role="alert">
|
||||
<p>{{ message }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Container -->
|
||||
<div id="modal-container"></div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
117
templates/main/index.html
Normal file
117
templates/main/index.html
Normal file
@@ -0,0 +1,117 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}首页 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}仪表板{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex items-center">
|
||||
<div class="p-3 rounded-full bg-blue-100 text-blue-600 mr-4">
|
||||
<i class="fas fa-globe fa-lg"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500 text-sm">站点管理</p>
|
||||
<h3 class="text-xl font-bold">NexusPHP</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a href="{{ url_for('site.site_index') }}"
|
||||
class="text-blue-600 hover:text-blue-800 text-sm font-medium inline-flex items-center">
|
||||
进入管理 <i class="fas fa-arrow-right ml-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex items-center">
|
||||
<div class="p-3 rounded-full bg-green-100 text-green-600 mr-4">
|
||||
<i class="fas fa-download fa-lg"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500 text-sm">下载客户端</p>
|
||||
<h3 class="text-xl font-bold">qBittorrent</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a href="{{ url_for('qbittorrent.qbittorrent_index') }}"
|
||||
class="text-blue-600 hover:text-blue-800 text-sm font-medium inline-flex items-center">
|
||||
进入管理 <i class="fas fa-arrow-right ml-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex items-center">
|
||||
<div class="p-3 rounded-full bg-purple-100 text-purple-600 mr-4">
|
||||
<i class="fas fa-cloud-download-alt fa-lg"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500 text-sm">下载客户端</p>
|
||||
<h3 class="text-xl font-bold">Transmission</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a href="{{ url_for('transmission.transmission_index') }}"
|
||||
class="text-blue-600 hover:text-blue-800 text-sm font-medium inline-flex items-center">
|
||||
进入管理 <i class="fas fa-arrow-right ml-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex items-center">
|
||||
<div class="p-3 rounded-full bg-yellow-100 text-yellow-600 mr-4">
|
||||
<i class="fas fa-users fa-lg"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500 text-sm">用户管理</p>
|
||||
<h3 class="text-xl font-bold">用户中心</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a href="{{ url_for('user.user_index') }}"
|
||||
class="text-blue-600 hover:text-blue-800 text-sm font-medium inline-flex items-center">
|
||||
进入管理 <i class="fas fa-arrow-right ml-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex items-center">
|
||||
<div class="p-3 rounded-full bg-red-100 text-red-600 mr-4">
|
||||
<i class="fas fa-cog fa-lg"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500 text-sm">系统配置</p>
|
||||
<h3 class="text-xl font-bold">设置</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a href="{{ url_for('settings.settings_index') }}"
|
||||
class="text-blue-600 hover:text-blue-800 text-sm font-medium inline-flex items-center">
|
||||
进入管理 <i class="fas fa-arrow-right ml-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex items-center">
|
||||
<div class="p-3 rounded-full bg-indigo-100 text-indigo-600 mr-4">
|
||||
<i class="fas fa-key fa-lg"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-gray-500 text-sm">账户安全</p>
|
||||
<h3 class="text-xl font-bold">修改密码</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a href="{{ url_for('auth.change_password') }}"
|
||||
class="text-blue-600 hover:text-blue-800 text-sm font-medium inline-flex items-center">
|
||||
进入管理 <i class="fas fa-arrow-right ml-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
17
templates/qbittorrent/index.html
Normal file
17
templates/qbittorrent/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}qBittorrent - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}qBittorrent{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-xl font-semibold">qBittorrent 客户端管理</h2>
|
||||
<a href="{{ url_for('qbittorrent.torrents') }}"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
种子列表
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
157
templates/qbittorrent/torrents.html
Normal file
157
templates/qbittorrent/torrents.html
Normal file
@@ -0,0 +1,157 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}qBittorrent 种子列表 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}qBittorrent 种子列表{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
<a href="{{ url_for('qbittorrent.qbittorrent_index') }}"
|
||||
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
|
||||
返回 qBittorrent 管理
|
||||
</a>
|
||||
{% elif torrents %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">名称</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">大小</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">进度</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">状态</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">做种/下载</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
{% for torrent in torrents %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm font-medium text-gray-900">{{ torrent.name }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ torrent.size }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div class="w-full bg-gray-200 rounded-full h-2">
|
||||
<div class="bg-blue-600 h-2 rounded-full" style="width: {{ torrent.progress * 100 }}%"></div>
|
||||
</div>
|
||||
<span class="text-sm text-gray-500 ml-2">{{ (torrent.progress * 100)|round(1) }}%</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
|
||||
{% if torrent.state == 'uploading' %}bg-green-100 text-green-800
|
||||
{% elif torrent.state == 'downloading' %}bg-blue-100 text-blue-800
|
||||
{% elif torrent.state == 'paused' %}bg-yellow-100 text-yellow-800
|
||||
{% else %}bg-gray-100 text-gray-800{% endif %}">
|
||||
{{ torrent.status }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<div>做种: {{ torrent.num_seeds }}</div>
|
||||
<div>下载: {{ torrent.num_leechs }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||
{% if torrent.state == 'paused' %}
|
||||
<button onclick="resumeTorrent('{{ torrent.hash }}')"
|
||||
class="text-green-600 hover:text-green-900 mr-3">
|
||||
开始
|
||||
</button>
|
||||
{% else %}
|
||||
<button onclick="pauseTorrent('{{ torrent.hash }}')"
|
||||
class="text-yellow-600 hover:text-yellow-900 mr-3">
|
||||
暂停
|
||||
</button>
|
||||
{% endif %}
|
||||
<button onclick="deleteTorrent('{{ torrent.hash }}')"
|
||||
class="text-red-600 hover:text-red-900">
|
||||
删除
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<i class="fas fa-inbox text-gray-400 text-4xl mb-4"></i>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-1">暂无种子</h3>
|
||||
<p class="text-gray-500">qBittorrent 客户端中没有种子任务</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function pauseTorrent(infoHash) {
|
||||
fetch(`/qbittorrent/torrent/${infoHash}/pause`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已暂停');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('操作失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('操作失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function resumeTorrent(infoHash) {
|
||||
fetch(`/qbittorrent/torrent/${infoHash}/resume`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已开始');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('操作失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('操作失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function deleteTorrent(infoHash) {
|
||||
if (confirm('确定要删除这个种子吗?这将同时删除下载的文件。')) {
|
||||
fetch(`/qbittorrent/torrent/${infoHash}/delete`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已删除');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('删除失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('删除失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
183
templates/settings/index.html
Normal file
183
templates/settings/index.html
Normal file
@@ -0,0 +1,183 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}设置 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}系统设置{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="mb-8">
|
||||
<h2 class="text-xl font-semibold mb-4">NexusPHP 站点设置</h2>
|
||||
<form id="nexusphp-settings-form">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label for="site_url" class="block text-sm font-medium text-gray-700 mb-1">站点URL</label>
|
||||
<input type="url" id="site_url" name="site_url" value="{{ nexusphp_site_url }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="api_token" class="block text-sm font-medium text-gray-700 mb-1">API Token</label>
|
||||
<input type="password" id="api_token" name="api_token" value="{{ nexusphp_api_token }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
<button type="submit"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
保存设置
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-gray-200 pt-8">
|
||||
<h2 class="text-xl font-semibold mb-4">qBittorrent 客户端设置</h2>
|
||||
<form id="qbittorrent-settings-form">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-4">
|
||||
<div>
|
||||
<label for="qb_host" class="block text-sm font-medium text-gray-700 mb-1">主机地址</label>
|
||||
<input type="text" id="qb_host" name="host" value="{{ qbittorrent_config.host if qbittorrent_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="qb_port" class="block text-sm font-medium text-gray-700 mb-1">端口</label>
|
||||
<input type="number" id="qb_port" name="port" value="{{ qbittorrent_config.port if qbittorrent_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="qb_username" class="block text-sm font-medium text-gray-700 mb-1">用户名</label>
|
||||
<input type="text" id="qb_username" name="username" value="{{ qbittorrent_config.username if qbittorrent_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="qb_password" class="block text-sm font-medium text-gray-700 mb-1">密码</label>
|
||||
<input type="password" id="qb_password" name="password" value="{{ qbittorrent_config.password if qbittorrent_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center mb-6">
|
||||
<input type="checkbox" id="qb_enabled" name="enabled" {% if qbittorrent_config and qbittorrent_config.enabled %}checked{% endif %}
|
||||
class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
|
||||
<label for="qb_enabled" class="ml-2 block text-sm text-gray-900">
|
||||
启用 qBittorrent 客户端
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
保存设置
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-gray-200 pt-8 mt-8">
|
||||
<h2 class="text-xl font-semibold mb-4">Transmission 客户端设置</h2>
|
||||
<form id="transmission-settings-form">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-4">
|
||||
<div>
|
||||
<label for="tr_host" class="block text-sm font-medium text-gray-700 mb-1">主机地址</label>
|
||||
<input type="text" id="tr_host" name="host" value="{{ transmission_config.host if transmission_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="tr_port" class="block text-sm font-medium text-gray-700 mb-1">端口</label>
|
||||
<input type="number" id="tr_port" name="port" value="{{ transmission_config.port if transmission_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="tr_username" class="block text-sm font-medium text-gray-700 mb-1">用户名</label>
|
||||
<input type="text" id="tr_username" name="username" value="{{ transmission_config.username if transmission_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div>
|
||||
<label for="tr_password" class="block text-sm font-medium text-gray-700 mb-1">密码</label>
|
||||
<input type="password" id="tr_password" name="password" value="{{ transmission_config.password if transmission_config else '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center mb-6">
|
||||
<input type="checkbox" id="tr_enabled" name="enabled" {% if transmission_config and transmission_config.enabled %}checked{% endif %}
|
||||
class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
|
||||
<label for="tr_enabled" class="ml-2 block text-sm text-gray-900">
|
||||
启用 Transmission 客户端
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
保存设置
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('nexusphp-settings-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
|
||||
fetch('/settings/nexusphp', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('NexusPHP 设置已保存');
|
||||
} else {
|
||||
alert('保存失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('保存失败: ' + error.message);
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('qbittorrent-settings-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
|
||||
fetch('/settings/qbittorrent', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('qBittorrent 设置已保存');
|
||||
} else {
|
||||
alert('保存失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('保存失败: ' + error.message);
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('transmission-settings-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
|
||||
fetch('/settings/transmission', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('Transmission 设置已保存');
|
||||
} else {
|
||||
alert('保存失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('保存失败: ' + error.message);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
141
templates/site/bookmarks.html
Normal file
141
templates/site/bookmarks.html
Normal file
@@ -0,0 +1,141 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}个人收藏 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}个人收藏{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
<a href="{{ url_for('site.site_index') }}"
|
||||
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
|
||||
返回站点管理
|
||||
</a>
|
||||
{% elif bookmarks and bookmarks.data %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">标题</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">大小</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">做种</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">下载</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
{% for bookmark in bookmarks.data %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm font-medium text-gray-900">{{ bookmark.torrent.name }}</div>
|
||||
<div class="text-sm text-gray-500">{{ bookmark.torrent.small_descr }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ bookmark.torrent.size }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ bookmark.torrent.seeders }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ bookmark.torrent.leechers }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||
<button onclick="showTorrentDetail({{ bookmark.torrent.id }})"
|
||||
class="text-blue-600 hover:text-blue-900 mr-3">
|
||||
查看详情
|
||||
</button>
|
||||
<button onclick="removeBookmark({{ bookmark.torrent.id }})"
|
||||
class="text-red-600 hover:text-red-900">
|
||||
取消收藏
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<i class="fas fa-bookmark text-gray-400 text-4xl mb-4"></i>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-1">暂无收藏</h3>
|
||||
<p class="text-gray-500">您还没有收藏任何种子</p>
|
||||
<div class="mt-6">
|
||||
<a href="{{ url_for('site.torrents') }}"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
去浏览种子
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- 种子详情模态框 -->
|
||||
<div id="torrent-detail-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden overflow-y-auto h-full w-full z-50">
|
||||
<div class="relative top-20 mx-auto p-5 border w-11/12 md:w-3/4 lg:w-1/2 shadow-lg rounded-md bg-white">
|
||||
<div class="mt-3">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-medium text-gray-900">种子详情</h3>
|
||||
<button onclick="closeTorrentDetail()" class="text-gray-400 hover:text-gray-500">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="torrent-detail-content" class="mt-2">
|
||||
<!-- 详情内容将通过 AJAX 加载 -->
|
||||
<div class="text-center py-8">
|
||||
<i class="fas fa-spinner fa-spin text-2xl text-blue-500"></i>
|
||||
<p class="mt-2 text-gray-600">加载中...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showTorrentDetail(torrentId) {
|
||||
// 显示模态框
|
||||
document.getElementById('torrent-detail-modal').classList.remove('hidden');
|
||||
|
||||
// 通过 AJAX 获取种子详情
|
||||
fetch(`/site/torrent/${torrentId}`)
|
||||
.then(response => response.text())
|
||||
.then(html => {
|
||||
document.getElementById('torrent-detail-content').innerHTML = html;
|
||||
})
|
||||
.catch(error => {
|
||||
document.getElementById('torrent-detail-content').innerHTML =
|
||||
'<div class="text-center py-8"><p class="text-red-500">加载失败: ' + error.message + '</p></div>';
|
||||
});
|
||||
}
|
||||
|
||||
function closeTorrentDetail() {
|
||||
document.getElementById('torrent-detail-modal').classList.add('hidden');
|
||||
}
|
||||
|
||||
function removeBookmark(torrentId) {
|
||||
if (confirm('确定要取消收藏这个种子吗?')) {
|
||||
fetch(`/site/bookmark/remove/${torrentId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('已取消收藏');
|
||||
// 刷新页面
|
||||
location.reload();
|
||||
} else {
|
||||
alert('取消收藏失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('取消收藏失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
53
templates/site/index.html
Normal file
53
templates/site/index.html
Normal file
@@ -0,0 +1,53 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}站点管理 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}站点管理{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<h2 class="text-xl font-semibold mb-6">NexusPHP 站点管理</h2>
|
||||
|
||||
{% if sites %}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{% for site in sites %}
|
||||
<div class="border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
|
||||
<div class="flex justify-between items-start">
|
||||
<h3 class="font-medium text-gray-900 text-lg">{{ site.name }}</h3>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
|
||||
在线
|
||||
</span>
|
||||
</div>
|
||||
<p class="text-gray-600 text-sm mt-1">{{ site.url }}</p>
|
||||
<div class="flex space-x-2 mt-4">
|
||||
<a href="{{ url_for('site.profile', site_id=site.id) }}"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
个人信息
|
||||
</a>
|
||||
<a href="{{ url_for('site.torrents', site_id=site.id) }}"
|
||||
class="bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
种子列表
|
||||
</a>
|
||||
<a href="{{ url_for('site.bookmarks', site_id=site.id) }}"
|
||||
class="bg-yellow-600 hover:bg-yellow-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
个人收藏
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<i class="fas fa-globe text-gray-400 text-4xl mb-4"></i>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-1">暂无站点配置</h3>
|
||||
<p class="text-gray-500">请在设置中添加NexusPHP站点</p>
|
||||
<div class="mt-6">
|
||||
<a href="{{ url_for('settings.settings_index') }}"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
去设置站点
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
90
templates/site/profile.html
Normal file
90
templates/site/profile.html
Normal file
@@ -0,0 +1,90 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}个人信息 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}个人信息{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<!-- 站点选择器 -->
|
||||
{% if sites and sites|length > 1 %}
|
||||
<div class="mb-6">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">选择站点</label>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{% for site in sites %}
|
||||
<a href="{{ url_for('site.profile', site_id=site.id) }}"
|
||||
class="px-3 py-1 rounded text-sm {% if site.id == current_site_id %}bg-blue-600 text-white{% else %}bg-gray-200 text-gray-700 hover:bg-gray-300{% endif %}">
|
||||
{{ site.name }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
<a href="{{ url_for('site.site_index') }}"
|
||||
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
|
||||
返回站点管理
|
||||
</a>
|
||||
|
||||
{% elif profile %}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<h3 class="text-lg font-medium mb-4">基本信息</h3>
|
||||
<div class="space-y-3">
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">用户名:</span>
|
||||
<span class="font-medium">{{ profile.data.data.username }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">用户ID:</span>
|
||||
<span class="font-medium">{{ profile.data.data.id }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">注册时间:</span>
|
||||
<span class="font-medium">{{ profile.data.data.added_human }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">上传量:</span>
|
||||
<span class="font-medium">{{ profile.data.data.uploaded_text }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">下载量:</span>
|
||||
<span class="font-medium">{{ profile.data.data.downloaded_text }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">分享率:</span>
|
||||
<span class="font-medium">{{ profile.data.data.share_ratio }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-lg font-medium mb-4">统计数据</h3>
|
||||
<div class="space-y-3">
|
||||
<!-- <div class="flex">
|
||||
<span class="w-32 text-gray-600">做种数:</span>
|
||||
<span class="font-medium">{{ profile.data.data.seeding }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">下载数:</span>
|
||||
<span class="font-medium">{{ profile.data.data.leeching }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">完成数:</span>
|
||||
<span class="font-medium">{{ profile.data.data.completed }}</span>
|
||||
</div> -->
|
||||
<div class="flex">
|
||||
<span class="w-32 text-gray-600">魔力值:</span>
|
||||
<span class="font-medium">{{ profile.data.data.bonus }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>暂无个人信息数据</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
101
templates/site/torrent_detail.html
Normal file
101
templates/site/torrent_detail.html
Normal file
@@ -0,0 +1,101 @@
|
||||
<div class="mt-2">
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% elif torrent %}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-2">{{ torrent.name }}</h3>
|
||||
<p class="text-gray-600 mb-4">{{ torrent.data.data.small_descr }}</p>
|
||||
<div class="space-y-2">
|
||||
<div class="flex">
|
||||
<span class="w-24 text-gray-600">文件大小:</span>
|
||||
<span class="font-medium">{{ torrent.data.data.size_human }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-24 text-gray-600">做种人数:</span>
|
||||
<span class="font-medium">{{ torrent.data.data.seeders }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-24 text-gray-600">下载人数:</span>
|
||||
<span class="font-medium">{{ torrent.data.data.leechers }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-24 text-gray-600">完成次数:</span>
|
||||
<span class="font-medium">{{ torrent.data.data.times_completed }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-24 text-gray-600">发布者:</span>
|
||||
<span class="font-medium">{{ torrent.data.data.user.username }}</span>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<span class="w-24 text-gray-600">发布时间:</span>
|
||||
<span class="font-medium">{{ torrent.data.data.added_human }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 class="font-medium text-gray-900 mb-2">标签</h4>
|
||||
<div class="flex flex-wrap gap-2 mb-4">
|
||||
{% for tag in torrent.data.data.tags %}
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
{{ tag.name }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<h4 class="font-medium text-gray-900 mb-2">操作</h4>
|
||||
<div class="flex space-x-2">
|
||||
<button onclick=f"downloadTorrent({{ torrent.data.data.download_url }})"
|
||||
class="bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
下载种子
|
||||
</button>
|
||||
<button onclick=f"addBookmark({{ torrent.data.data.id }})"
|
||||
class="bg-yellow-600 hover:bg-yellow-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
{% if torrent.has_bookmarked %}已收藏{% else %}收藏{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
<h4 class="font-medium text-gray-900 mb-2">描述</h4>
|
||||
<div class="bg-gray-50 p-4 rounded-md">
|
||||
<p class="text-gray-700">{{ torrent.description }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>暂无种子详情数据</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function downloadTorrent(torrentId) {
|
||||
// 在实际应用中,这里会触发种子下载
|
||||
alert('下载种子功能待实现,种子ID: ' + torrentId);
|
||||
}
|
||||
|
||||
function addBookmark(torrentId) {
|
||||
fetch(`/site/bookmark/add/${torrentId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('收藏状态已更新');
|
||||
// 可以刷新页面或更新按钮状态
|
||||
} else {
|
||||
alert('操作失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('操作失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
204
templates/site/torrents.html
Normal file
204
templates/site/torrents.html
Normal file
@@ -0,0 +1,204 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}种子列表 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}种子列表{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<!-- 站点选择器 -->
|
||||
{% if sites and sites|length > 1 %}
|
||||
<div class="mb-6">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">选择站点</label>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{% for site in sites %}
|
||||
<a href="{{ url_for('site.torrents', site_id=site.id) }}"
|
||||
class="px-3 py-1 rounded text-sm {% if site.id == current_site_id %}bg-blue-600 text-white{% else %}bg-gray-200 text-gray-700 hover:bg-gray-300{% endif %}">
|
||||
{{ site.name }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
<a href="{{ url_for('site.site_index') }}"
|
||||
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
|
||||
返回站点管理
|
||||
</a>
|
||||
{% else %}
|
||||
<!-- 搜索和筛选 -->
|
||||
<div class="mb-6">
|
||||
<form method="GET" class="flex flex-wrap gap-4">
|
||||
<div class="flex-1 min-w-[200px]">
|
||||
<label for="title" class="block text-sm font-medium text-gray-700 mb-1">标题搜索</label>
|
||||
<input type="text" id="title" name="title" value="{{ title_filter or '' }}"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div class="flex-1 min-w-[150px]">
|
||||
<label for="sort" class="block text-sm font-medium text-gray-700 mb-1">排序方式</label>
|
||||
<select id="sort" name="sort"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
<option value="-seeders" {% if sort=='-seeders' %}selected{% endif %}>最多做种</option>
|
||||
<option value="seeders" {% if sort=='seeders' %}selected{% endif %}>最少做种</option>
|
||||
<option value="-size" {% if sort=='-size' %}selected{% endif %}>最大体积</option>
|
||||
<option value="size" {% if sort=='size' %}selected{% endif %}>最小体积</option>
|
||||
<option value="-id" {% if sort=='-id' %}selected{% endif %}>最新发布</option>
|
||||
<option value="id" {% if sort=='id' %}selected{% endif %}>最早发布</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex items-end">
|
||||
<button type="submit"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
搜索
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 种子列表 -->
|
||||
{% if torrents and torrents.data %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">标题</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">大小</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">做种</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">下载</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">完成</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
{% for torrent in torrents.data.data %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm font-medium text-gray-900">{{ torrent.name }}</div>
|
||||
<div class="text-sm text-gray-500">{{ torrent.small_descr }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ torrent.size_human }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ torrent.seeders }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ torrent.leechers }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ torrent.times_completed }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||
<button onclick="showTorrentDetail({{ torrent.id }})"
|
||||
class="text-blue-600 hover:text-blue-900 mr-3">
|
||||
查看详情
|
||||
</button>
|
||||
<button onclick="addBookmark({{ torrent.id }})"
|
||||
class="text-yellow-600 hover:text-yellow-900">
|
||||
收藏
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="mt-6 flex items-center justify-between">
|
||||
<div class="text-sm text-gray-700">
|
||||
显示第 <span class="font-medium">{{ (page-1)*per_page+1 }}</span> 到 <span class="font-medium">{{ [page*per_page, torrents.total or page*per_page]|min }}</span> 条结果,
|
||||
共 <span class="font-medium">{{ torrents.total or 0 }}</span> 条
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
{% if page > 1 %}
|
||||
<a href="?page={{ page-1 }}&per_page={{ per_page }}&sort={{ sort }}&title={{ title_filter or '' }}"
|
||||
class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
||||
上一页
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if torrents.total and page < (torrents.total/per_page)|round(0, 'ceil')|int %}
|
||||
<a href="?page={{ page+1 }}&per_page={{ per_page }}&sort={{ sort }}&title={{ title_filter or '' }}"
|
||||
class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
||||
下一页
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<i class="fas fa-inbox text-gray-400 text-4xl mb-4"></i>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-1">暂无种子数据</h3>
|
||||
<p class="text-gray-500">没有找到符合条件的种子资源</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- 种子详情模态框 -->
|
||||
<div id="torrent-detail-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden overflow-y-auto h-full w-full z-50">
|
||||
<div class="relative top-20 mx-auto p-5 border w-11/12 md:w-3/4 lg:w-1/2 shadow-lg rounded-md bg-white">
|
||||
<div class="mt-3">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-medium text-gray-900">种子详情</h3>
|
||||
<button onclick="closeTorrentDetail()" class="text-gray-400 hover:text-gray-500">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="torrent-detail-content" class="mt-2">
|
||||
<!-- 详情内容将通过 AJAX 加载 -->
|
||||
<div class="text-center py-8">
|
||||
<i class="fas fa-spinner fa-spin text-2xl text-blue-500"></i>
|
||||
<p class="mt-2 text-gray-600">加载中...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showTorrentDetail(torrentId) {
|
||||
// 显示模态框
|
||||
document.getElementById('torrent-detail-modal').classList.remove('hidden');
|
||||
|
||||
// 通过 AJAX 获取种子详情
|
||||
fetch(`/site/{{ current_site_id }}/torrent/${torrentId}`)
|
||||
.then(response => response.text())
|
||||
.then(html => {
|
||||
document.getElementById('torrent-detail-content').innerHTML = html;
|
||||
})
|
||||
.catch(error => {
|
||||
document.getElementById('torrent-detail-content').innerHTML =
|
||||
'<div class="text-center py-8"><p class="text-red-500">加载失败: ' + error.message + '</p></div>';
|
||||
});
|
||||
}
|
||||
|
||||
function closeTorrentDetail() {
|
||||
document.getElementById('torrent-detail-modal').classList.add('hidden');
|
||||
}
|
||||
|
||||
function addBookmark(torrentId) {
|
||||
fetch(`/site/{{ current_site_id }}/bookmark/add/${torrentId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('收藏成功');
|
||||
} else {
|
||||
alert('收藏失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('收藏失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
17
templates/transmission/index.html
Normal file
17
templates/transmission/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Transmission - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}Transmission{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-xl font-semibold">Transmission 客户端管理</h2>
|
||||
<a href="{{ url_for('transmission.torrents') }}"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
种子列表
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
157
templates/transmission/torrents.html
Normal file
157
templates/transmission/torrents.html
Normal file
@@ -0,0 +1,157 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Transmission 种子列表 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}Transmission 种子列表{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
<a href="{{ url_for('transmission.transmission_index') }}"
|
||||
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
|
||||
返回 Transmission 管理
|
||||
</a>
|
||||
{% elif torrents %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">名称</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">大小</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">进度</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">状态</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">做种/下载</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
{% for torrent in torrents %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm font-medium text-gray-900">{{ torrent.name }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ torrent.totalSize }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div class="w-full bg-gray-200 rounded-full h-2">
|
||||
<div class="bg-blue-600 h-2 rounded-full" style="width: {{ torrent.percentDone * 100 }}%"></div>
|
||||
</div>
|
||||
<span class="text-sm text-gray-500 ml-2">{{ (torrent.percentDone * 100)|round(1) }}%</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
|
||||
{% if torrent.status == 6 %}bg-green-100 text-green-800
|
||||
{% elif torrent.status == 4 %}bg-blue-100 text-blue-800
|
||||
{% elif torrent.status == 0 %}bg-yellow-100 text-yellow-800
|
||||
{% else %}bg-gray-100 text-gray-800{% endif %}">
|
||||
{{ torrent.statusString }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<div>做种: {{ torrent.peersSendingToUs }}</div>
|
||||
<div>下载: {{ torrent.peersGettingFromUs }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||
{% if torrent.status == 0 %}
|
||||
<button onclick="startTorrent({{ torrent.id }})"
|
||||
class="text-green-600 hover:text-green-900 mr-3">
|
||||
开始
|
||||
</button>
|
||||
{% else %}
|
||||
<button onclick="stopTorrent({{ torrent.id }})"
|
||||
class="text-yellow-600 hover:text-yellow-900 mr-3">
|
||||
暂停
|
||||
</button>
|
||||
{% endif %}
|
||||
<button onclick="removeTorrent({{ torrent.id }})"
|
||||
class="text-red-600 hover:text-red-900">
|
||||
删除
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<i class="fas fa-inbox text-gray-400 text-4xl mb-4"></i>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-1">暂无种子</h3>
|
||||
<p class="text-gray-500">Transmission 客户端中没有种子任务</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function stopTorrent(torrentId) {
|
||||
fetch(`/transmission/torrent/${torrentId}/stop`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已暂停');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('操作失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('操作失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function startTorrent(torrentId) {
|
||||
fetch(`/transmission/torrent/${torrentId}/start`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已开始');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('操作失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('操作失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function removeTorrent(torrentId) {
|
||||
if (confirm('确定要删除这个种子吗?这将同时删除下载的文件。')) {
|
||||
fetch(`/transmission/torrent/${torrentId}/remove`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已删除');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('删除失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('删除失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
163
templates/user/index.html
Normal file
163
templates/user/index.html
Normal file
@@ -0,0 +1,163 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}用户管理 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}用户管理{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-xl font-semibold">用户列表</h2>
|
||||
<button onclick="showAddUserModal()"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded text-sm">
|
||||
添加用户
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{% if users %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">用户名</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">角色</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">创建时间</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm font-medium text-gray-900">{{ user.username }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
|
||||
{% if user.role == 'admin' %}bg-purple-100 text-purple-800
|
||||
{% else %}bg-green-100 text-green-800{% endif %}">
|
||||
{{ user.role }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ user.created_at }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||
{% if user.id != session.user_id %}
|
||||
<button onclick="deleteUser({{ user.id }})"
|
||||
class="text-red-600 hover:text-red-900">
|
||||
删除
|
||||
</button>
|
||||
{% else %}
|
||||
<span class="text-gray-400">当前用户</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<i class="fas fa-users text-gray-400 text-4xl mb-4"></i>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-1">暂无用户</h3>
|
||||
<p class="text-gray-500">系统中还没有其他用户</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- 添加用户模态框 -->
|
||||
<div id="add-user-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden overflow-y-auto h-full w-full z-50">
|
||||
<div class="relative top-20 mx-auto p-5 border w-11/12 md:w-1/3 shadow-lg rounded-md bg-white">
|
||||
<div class="mt-3">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h3 class="text-lg font-medium text-gray-900">添加用户</h3>
|
||||
<button onclick="closeAddUserModal()" class="text-gray-400 hover:text-gray-500">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
<form id="add-user-form">
|
||||
<div class="mb-4">
|
||||
<label for="username" class="block text-sm font-medium text-gray-700 mb-1">用户名</label>
|
||||
<input type="text" id="username" name="username" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="role" class="block text-sm font-medium text-gray-700 mb-1">角色</label>
|
||||
<select id="role" name="role"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
<option value="user">普通用户</option>
|
||||
<option value="admin">管理员</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex justify-end space-x-2">
|
||||
<button type="button" onclick="closeAddUserModal()"
|
||||
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
|
||||
取消
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
||||
添加
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showAddUserModal() {
|
||||
document.getElementById('add-user-modal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeAddUserModal() {
|
||||
document.getElementById('add-user-modal').classList.add('hidden');
|
||||
}
|
||||
|
||||
function deleteUser(userId) {
|
||||
if (confirm('确定要删除这个用户吗?')) {
|
||||
fetch(`/user/delete/${userId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('用户已删除');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('删除失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('删除失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('add-user-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
|
||||
fetch('/user/add', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert(`用户添加成功!\n用户名: ${data.username}\n临时密码: ${data.password}`);
|
||||
closeAddUserModal();
|
||||
location.reload();
|
||||
} else {
|
||||
alert('添加失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('添加失败: ' + error.message);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user