|
|
<!DOCTYPE html>
|
|
|
<html lang="zh-CN">
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
<title>图片压缩工具</title>
|
|
|
<style>
|
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
|
|
body {
|
|
|
margin: 0;
|
|
|
padding: 28px 20px;
|
|
|
background: #0b0f14;
|
|
|
color: #e5e7eb;
|
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial;
|
|
|
min-height: 100vh;
|
|
|
}
|
|
|
|
|
|
.box {
|
|
|
max-width: 800px;
|
|
|
margin: auto;
|
|
|
background: rgba(255,255,255,0.04);
|
|
|
padding: 26px;
|
|
|
border-radius: 16px;
|
|
|
border: 1px solid rgba(255,255,255,0.08);
|
|
|
}
|
|
|
|
|
|
.card {
|
|
|
background: rgba(255,255,255,0.04);
|
|
|
border: 1px solid rgba(255,255,255,0.08);
|
|
|
border-radius: 14px;
|
|
|
padding: 18px;
|
|
|
margin-bottom: 14px;
|
|
|
}
|
|
|
|
|
|
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: #f3f4f6; }
|
|
|
|
|
|
.tool-label { font-size: 13px; color: #9ca3af; margin-bottom: 8px; display: block; }
|
|
|
|
|
|
input[type="file"] {
|
|
|
width: 100%;
|
|
|
padding: 12px;
|
|
|
background: #111827;
|
|
|
border: 1px solid rgba(255,255,255,0.12);
|
|
|
border-radius: 10px;
|
|
|
color: #e5e7eb;
|
|
|
font-size: 14px;
|
|
|
}
|
|
|
|
|
|
.quality-row {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
gap: 14px;
|
|
|
margin-top: 14px;
|
|
|
}
|
|
|
|
|
|
input[type="range"] {
|
|
|
flex: 1;
|
|
|
accent-color: #2563eb;
|
|
|
}
|
|
|
|
|
|
.quality-badge {
|
|
|
padding: 4px 10px;
|
|
|
border-radius: 8px;
|
|
|
background: rgba(59,130,246,0.15);
|
|
|
border: 1px solid rgba(59,130,246,0.3);
|
|
|
color: #60a5fa;
|
|
|
font-size: 13px;
|
|
|
font-weight: 600;
|
|
|
}
|
|
|
|
|
|
.btn {
|
|
|
display: inline-flex;
|
|
|
align-items: center;
|
|
|
gap: 6px;
|
|
|
padding: 10px 18px;
|
|
|
font-size: 14px;
|
|
|
border-radius: 10px;
|
|
|
border: none;
|
|
|
cursor: pointer;
|
|
|
font-weight: 500;
|
|
|
transition: all 0.2s;
|
|
|
}
|
|
|
|
|
|
.btn-primary { background: #2563eb; color: white; }
|
|
|
.btn-primary:hover { background: #1d4ed8; }
|
|
|
|
|
|
.download-btn {
|
|
|
display: inline-block;
|
|
|
margin-top: 14px;
|
|
|
padding: 10px 16px;
|
|
|
background: #22c55e;
|
|
|
color: #0b0f14;
|
|
|
border-radius: 10px;
|
|
|
text-decoration: none;
|
|
|
font-weight: 600;
|
|
|
font-size: 14px;
|
|
|
}
|
|
|
|
|
|
.download-btn:hover { background: #16a34a; }
|
|
|
|
|
|
.message { margin-top: 12px; font-size: 14px; color: #22c55e; }
|
|
|
.error { color: #f87171; }
|
|
|
|
|
|
.toast {
|
|
|
position: fixed;
|
|
|
right: 20px;
|
|
|
bottom: 20px;
|
|
|
background: rgba(17,24,39,0.95);
|
|
|
color: #e5e7eb;
|
|
|
padding: 10px 16px;
|
|
|
border-radius: 10px;
|
|
|
border: 1px solid rgba(34,197,94,0.3);
|
|
|
font-size: 13px;
|
|
|
opacity: 0;
|
|
|
transform: translateY(10px);
|
|
|
transition: all 0.25s ease;
|
|
|
z-index: 9999;
|
|
|
}
|
|
|
|
|
|
.toast.show { opacity: 1; transform: translateY(0); }
|
|
|
|
|
|
@media (max-width: 600px) {
|
|
|
body { padding: 20px 12px; }
|
|
|
.box { padding: 18px 14px; }
|
|
|
.btn { width: 100%; justify-content: center; }
|
|
|
.quality-row { flex-direction: column; align-items: flex-start; }
|
|
|
}
|
|
|
</style>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="box">
|
|
|
<div class="card">
|
|
|
<div class="card-title">🖼️ 图片压缩工具</div>
|
|
|
<form method="post" enctype="multipart/form-data">
|
|
|
<label class="tool-label">选择图片(JPG/PNG/WEBP)</label>
|
|
|
<input type="file" name="file" accept=".jpg,.jpeg,.png,.webp" required>
|
|
|
|
|
|
<div class="quality-row">
|
|
|
<span class="tool-label" style="margin:0">压缩质量</span>
|
|
|
<input type="range" name="quality" min="30" max="95" value="{{ quality or 85 }}" oninput="document.getElementById('qBadge').innerText = this.value + '%'">
|
|
|
<span class="quality-badge" id="qBadge">{{ quality or 85 }}%</span>
|
|
|
</div>
|
|
|
|
|
|
<br>
|
|
|
<button class="btn btn-primary" type="submit">🗜️ 开始压缩</button>
|
|
|
</form>
|
|
|
|
|
|
{% if message %}
|
|
|
<div class="message {% if '❌' in message %}error{% endif %}">{{ message }}</div>
|
|
|
{% endif %}
|
|
|
|
|
|
{% if download_file %}
|
|
|
<a class="download-btn" href="/tool/image_compress/download/{{ download_file }}">⬇ 下载压缩图片</a>
|
|
|
{% endif %}
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="toast" id="toast"></div>
|
|
|
|
|
|
<script>
|
|
|
function showToast(msg) {
|
|
|
const t = document.getElementById('toast');
|
|
|
t.innerText = msg;
|
|
|
t.classList.add('show');
|
|
|
setTimeout(() => t.classList.remove('show'), 2000);
|
|
|
}
|
|
|
</script>
|
|
|
</body>
|
|
|
</html> |