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.
202 lines
5.7 KiB
202 lines
5.7 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Base64 编解码</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
margin: 0;
|
|
padding: 24px 16px;
|
|
background: #0b0f14;
|
|
color: #e5e7eb;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.box {
|
|
max-width: 860px;
|
|
margin: auto;
|
|
background: rgba(255,255,255,0.04);
|
|
padding: 24px;
|
|
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: 12px;
|
|
color: #f3f4f6;
|
|
}
|
|
|
|
.tool-label {
|
|
font-size: 13px;
|
|
color: #9ca3af;
|
|
margin-bottom: 8px;
|
|
display: block;
|
|
}
|
|
|
|
textarea {
|
|
width: 100%;
|
|
background: #111827;
|
|
border: 1px solid rgba(255,255,255,0.12);
|
|
border-radius: 10px;
|
|
color: #e5e7eb;
|
|
font-size: 14px;
|
|
font-family: "SF Mono", "Fira Code", Consolas, monospace;
|
|
padding: 12px;
|
|
resize: vertical;
|
|
outline: none;
|
|
transition: border-color 0.2s;
|
|
}
|
|
|
|
textarea:focus { border-color: rgba(59,130,246,0.6); }
|
|
textarea::placeholder { color: #6b7280; }
|
|
textarea.result-textarea {
|
|
background: rgba(0,0,0,0.3);
|
|
border-color: rgba(34,197,94,0.3);
|
|
color: #4ade80;
|
|
}
|
|
|
|
.btn-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
|
|
|
|
.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; }
|
|
.btn-secondary { background: rgba(255,255,255,0.08); color: #e5e7eb; border: 1px solid rgba(255,255,255,0.1); }
|
|
.btn-secondary:hover { background: rgba(255,255,255,0.12); }
|
|
|
|
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
|
|
|
|
.copy-btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
padding: 6px 12px;
|
|
font-size: 12px;
|
|
border-radius: 8px;
|
|
background: rgba(34,197,94,0.15);
|
|
color: #22c55e;
|
|
border: 1px solid rgba(34,197,94,0.3);
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.copy-btn:hover { background: rgba(34,197,94,0.25); }
|
|
.copy-btn.copied { background: rgba(34,197,94,0.4); color: #4ade80; }
|
|
|
|
.toast {
|
|
position: fixed;
|
|
right: 16px;
|
|
bottom: 16px;
|
|
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: 16px 12px; }
|
|
.box { padding: 18px 14px; }
|
|
.btn-row { flex-direction: column; }
|
|
.btn { width: 100%; justify-content: center; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="box">
|
|
<div class="card">
|
|
<div class="card-title">🔐 Base64 编解码</div>
|
|
<label class="tool-label">输入内容</label>
|
|
<textarea id="inputText" rows="4" placeholder="输入要编码或解码的文本...">{{ input_text or '' }}</textarea>
|
|
<div class="btn-row">
|
|
<button class="btn btn-primary" onclick="doEncode()">编码 Encode</button>
|
|
<button class="btn btn-secondary" onclick="doDecode()">解码 Decode</button>
|
|
</div>
|
|
</div>
|
|
|
|
{% if result %}
|
|
<div class="card">
|
|
<div class="result-header">
|
|
<span class="tool-label" style="margin:0">处理结果</span>
|
|
<button class="copy-btn" id="copyBtn" onclick="copyResult()">
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
|
|
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
|
|
</svg>
|
|
<span id="copyText">复制</span>
|
|
</button>
|
|
</div>
|
|
<textarea id="resultText" class="result-textarea" rows="4" readonly>{{ result }}</textarea>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="toast" id="toast"></div>
|
|
|
|
<script>
|
|
function doEncode() {
|
|
const text = document.getElementById('inputText').value;
|
|
if (!text.trim()) { showToast('请输入内容'); return; }
|
|
window.location.href = '/tool/base64?action=encode_text&text=' + encodeURIComponent(text);
|
|
}
|
|
|
|
function doDecode() {
|
|
const text = document.getElementById('inputText').value;
|
|
if (!text.trim()) { showToast('请输入内容'); return; }
|
|
window.location.href = '/tool/base64?action=decode_text&text=' + encodeURIComponent(text);
|
|
}
|
|
|
|
function copyResult() {
|
|
const result = document.getElementById('resultText').value;
|
|
if (!result) return;
|
|
navigator.clipboard.writeText(result).then(() => {
|
|
const btn = document.getElementById('copyBtn');
|
|
const text = document.getElementById('copyText');
|
|
btn.classList.add('copied');
|
|
text.textContent = '已复制!';
|
|
showToast('已复制到剪贴板');
|
|
setTimeout(() => { btn.classList.remove('copied'); text.textContent = '复制'; }, 2000);
|
|
}).catch(() => showToast('复制失败,请手动选择复制'));
|
|
}
|
|
|
|
function showToast(msg) {
|
|
const t = document.getElementById('toast');
|
|
t.innerText = msg;
|
|
t.classList.add('show');
|
|
setTimeout(() => t.classList.remove('show'), 2000);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |