init
This commit is contained in:
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 %}
|
||||
Reference in New Issue
Block a user