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 %}
|
||||
Reference in New Issue
Block a user