You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
4.9 KiB
181 lines
4.9 KiB
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>HD4K下载测试</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
input, textarea {
|
|
width: 100%;
|
|
padding: 8px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
textarea {
|
|
height: 200px;
|
|
font-family: monospace;
|
|
}
|
|
|
|
button {
|
|
background-color: #007bff;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 20px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
}
|
|
|
|
button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
|
|
.result {
|
|
margin-top: 20px;
|
|
padding: 15px;
|
|
border-radius: 4px;
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.success {
|
|
color: #28a745;
|
|
}
|
|
|
|
.error {
|
|
color: #dc3545;
|
|
}
|
|
|
|
.status-item {
|
|
margin: 5px 0;
|
|
padding: 5px;
|
|
border-left: 3px solid #ddd;
|
|
}
|
|
|
|
.status-success {
|
|
border-left-color: #28a745;
|
|
}
|
|
|
|
.status-skipped {
|
|
border-left-color: #ffc107;
|
|
}
|
|
|
|
.status-failed {
|
|
border-left-color: #dc3545;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>HD4K下载测试</h1>
|
|
|
|
<div class="form-group">
|
|
<label for="title">标题:</label>
|
|
<input type="text" id="title" value="测试">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="jsonData">JSON数据:</label>
|
|
<textarea id="jsonData">{
|
|
"title": "测试",
|
|
"imgs": {
|
|
"0001": "https://i.imgur.com/3dV1KnX1.jpg",
|
|
"0002": "https://i.imgur.com/3dV1KnX2.jpg",
|
|
"0003": "https://i.imgur.com/3dV1KnX3.jpg",
|
|
"0004": "https://i.imgur.com/3dV1KnX4.jpg"
|
|
}
|
|
}</textarea>
|
|
</div>
|
|
|
|
<button onclick="downloadComic()">开始下载</button>
|
|
|
|
<div id="result" class="result" style="display: none;"></div>
|
|
|
|
<script>
|
|
async function downloadComic() {
|
|
const title = document.getElementById('title').value;
|
|
const jsonData = document.getElementById('jsonData').value;
|
|
|
|
let imgs;
|
|
try {
|
|
imgs = JSON.parse(jsonData);
|
|
} catch (e) {
|
|
showResult('error', 'JSON格式错误: ' + e.message);
|
|
return;
|
|
}
|
|
|
|
const data = {
|
|
title: title,
|
|
imgs: imgs.imgs || imgs
|
|
};
|
|
|
|
try {
|
|
const response = await fetch('http://127.0.0.1:8888/api/save_imgs', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(data)
|
|
});
|
|
|
|
const result = await response.json();
|
|
showResult('success', result);
|
|
} catch (error) {
|
|
showResult('error', '请求失败: ' + error.message);
|
|
}
|
|
}
|
|
|
|
function showResult(type, result) {
|
|
const resultDiv = document.getElementById('result');
|
|
resultDiv.style.display = 'block';
|
|
|
|
if (type === 'error') {
|
|
resultDiv.innerHTML = `<div class="error"><strong>错误:</strong> ${result}</div>`;
|
|
return;
|
|
}
|
|
|
|
let html = `<div class="success"><strong>下载完成!</strong></div>`;
|
|
html += `<p><strong>标题:</strong> ${result.title}</p>`;
|
|
html += `<p><strong>文件夹:</strong> ${result.folder}</p>`;
|
|
html += `<p><strong>总计:</strong> ${result.total} 张</p>`;
|
|
html += `<p><strong>新增:</strong> ${result.saved} 张</p>`;
|
|
html += `<p><strong>跳过:</strong> ${result.skipped} 张</p>`;
|
|
html += `<p><strong>失败:</strong> ${result.failed} 张</p>`;
|
|
html += `<p><strong>消息:</strong> ${result.message}</p>`;
|
|
|
|
if (result.details && result.details.length > 0) {
|
|
html += `<h3>下载详情:</h3>`;
|
|
result.details.forEach(detail => {
|
|
let statusClass = '';
|
|
if (detail.status === 'success') statusClass = 'status-success';
|
|
else if (detail.status === 'skipped') statusClass = 'status-skipped';
|
|
else if (detail.status === 'failed') statusClass = 'status-failed';
|
|
|
|
html += `
|
|
<div class="status-item ${statusClass}">
|
|
<strong>${detail.key}:</strong> ${detail.status} - ${detail.message}
|
|
${detail.saved_as ? ` (保存为: ${detail.saved_as})` : ''}
|
|
</div>
|
|
`;
|
|
});
|
|
}
|
|
|
|
resultDiv.innerHTML = html;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |