157 lines
6.6 KiB
HTML
157 lines
6.6 KiB
HTML
{% 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 %} |