Files
Nexusphp-Panel/templates/site/torrents.html
DengDai ad2c65affb init
2025-12-08 14:31:21 +08:00

204 lines
9.5 KiB
HTML

{% 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 %}