219 lines
No EOL
6 KiB
HTML
219 lines
No EOL
6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>离线下载任务管理</title>
|
|
<link href="static/css/bootstarp/5/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
|
<link href="static/css/custom/Common.css" rel="stylesheet" crossorigin="anonymous">
|
|
|
|
<style>
|
|
body {
|
|
padding: 20px;
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1000px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
h1 {
|
|
text-align: center;
|
|
color: #343a40;
|
|
}
|
|
|
|
.table-responsive {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.table th,
|
|
.table td {
|
|
padding: 10px;
|
|
vertical-align: middle;
|
|
border: 1px solid #dee2e6;
|
|
text-align: center;
|
|
}
|
|
|
|
.table th {
|
|
background-color: #007bff;
|
|
color: white;
|
|
font-weight: bold;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.table td {
|
|
word-break: break-word;
|
|
}
|
|
|
|
.table tbody tr:nth-child(even) {
|
|
background-color: #f1f3f5;
|
|
}
|
|
|
|
.table tbody tr:hover {
|
|
background-color: #e2e6ea;
|
|
}
|
|
|
|
.hidden-on-small {
|
|
display: table-cell;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
.table th,
|
|
.table td {
|
|
font-size: 0.9em;
|
|
padding: 8px;
|
|
}
|
|
|
|
.hidden-on-small {
|
|
display: none;
|
|
}
|
|
|
|
.table td {
|
|
white-space: normal;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
.statusData {
|
|
width: 20%;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 576px) {
|
|
|
|
.table th,
|
|
.table td {
|
|
font-size: 0.8em;
|
|
padding: 5px;
|
|
}
|
|
|
|
.table-responsive {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
}
|
|
|
|
@media (min-width: 1200px) {
|
|
.timeData {
|
|
width: 16%;
|
|
}
|
|
|
|
|
|
|
|
|
|
.hashData {
|
|
width: 25%;
|
|
}
|
|
}
|
|
|
|
.containerCustom {
|
|
max-width: 95%
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container containerCustom">
|
|
<h1 class="text-center">离线下载任务管理</h1>
|
|
<div class="table-responsive">
|
|
<div id="loading-mask" style="display: none;">
|
|
<div class="loading-spinner"></div>
|
|
<p class="loading-text">数据加载中,请稍等...</p>
|
|
</div>
|
|
|
|
<table id="data-table" class="table table-striped table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>文件名</th>
|
|
<th style="width: 10%" class="hidden-on-small">大小</th>
|
|
<th class="timeData">提交时间</th>
|
|
<th class="timeData hidden-on-small">结束时间</th>
|
|
|
|
<th class="statusData">状态</th>
|
|
<th class="hidden-on-small hashData">哈希</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="taskTableBody">
|
|
<!-- 数据将在这里动态填充 -->
|
|
</tbody>
|
|
</table>
|
|
<p class="more-content"><a href="/index.html">返回主页</a> | 捐赠</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="static/js/bootstarp/5/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
|
|
<script src="static/js/jquery/2.1.4/jquery.min.js"></script>
|
|
<script src="static/js/custom/Common.js"></script>
|
|
|
|
<script>
|
|
showLoadingMask();
|
|
let statusStrDict = new Map([
|
|
[0, "排队中"],
|
|
[1, "进行中"],
|
|
[2, "错误"],
|
|
[3, "已完成"],
|
|
[4, "已缓存"],
|
|
[5, "已被清理"],
|
|
[6, "排队中"]
|
|
]);
|
|
data = [];
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/GetMyTasks",
|
|
dataType: "json",
|
|
success: function (response) {
|
|
hideLoadingMask();
|
|
if (response.retcode === 0) {
|
|
data = response.data;
|
|
populateTable(data);
|
|
} else {
|
|
alert(response.message);
|
|
}
|
|
},
|
|
error(xhr, status, error) {
|
|
alert(error);
|
|
}
|
|
});
|
|
|
|
function formatBytes(bytes, decimals = 2) {
|
|
if (bytes === 0) return '0 Bytes';
|
|
const k = 1024;
|
|
const dm = decimals || 2;
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
}
|
|
|
|
function populateTable(data) {
|
|
const tableBody = document.getElementById('taskTableBody');
|
|
tableBody.innerHTML = ''; // 清空现有内容
|
|
|
|
data.forEach(item => {
|
|
const row = document.createElement('tr');
|
|
row.innerHTML = `
|
|
<td>${item.status === 3 || item.status === 4 ? `<a href="/Download/${item.tid}">${item.file_name}</a>` : item.file_name}</td>
|
|
<td class="hidden-on-small">${formatBytes(item.size)}</td>
|
|
<td>${item.add_time}</td>
|
|
<td class="hidden-on-small">${item.update_time}</td>
|
|
<td>${statusStrDict.get(item.status) + (item.status == 6 ? " #" + (item.queue_position + 1) : "")}</td>
|
|
<td class="hidden-on-small">${item.hash || 'N/A'}</td>
|
|
`;
|
|
tableBody.appendChild(row);
|
|
});
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |