Files
gemini-balance/app/templates/keys_status.html

215 lines
7.0 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>API密钥状态</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container {
max-width: 900px;
width: 90%;
background: white;
padding: 40px;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
transition: all 0.3s ease;
}
.container:hover {
transform: translateY(-5px);
box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}
h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 30px;
font-weight: 700;
}
.key-list {
margin-bottom: 30px;
background: #f8f9fa;
padding: 20px;
border-radius: 10px;
transition: all 0.3s ease;
}
.key-list:hover {
background: #e9ecef;
}
.key-list h2 {
color: #2c3e50;
margin-bottom: 15px;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1.5em;
}
ul {
list-style-type: none;
padding: 0;
}
li {
background: white;
border: 1px solid #e0e0e0;
margin-bottom: 10px;
padding: 12px;
border-radius: 5px;
transition: all 0.2s ease;
display: flex;
justify-content: space-between;
align-items: center;
}
li:hover {
transform: translateX(5px);
box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}
.total {
font-weight: bold;
margin-top: 20px;
text-align: center;
font-size: 1.2em;
color: #2c3e50;
}
.copy-btn {
background-color: #3498db;
color: white;
border: none;
padding: 8px 15px;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
font-weight: bold;
transition: background-color 0.3s ease;
}
.copy-btn:hover {
background-color: #2980b9;
}
#copyStatus {
text-align: center;
margin-top: 20px;
color: #27ae60;
font-weight: bold;
opacity: 0;
transition: opacity 0.3s ease;
}
.fail-count {
color: #e74c3c;
font-size: 0.9em;
margin-left: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>API密钥状态</h1>
<div class="key-list">
<h2>
有效密钥
<button class="copy-btn" onclick="copyKeys('valid')">一键复制</button>
</h2>
<ul id="validKeys">
{% for key, fail_count in valid_keys.items() %}
<li>
<span>{{ key }}</span>
<span class="fail-count">(失败次数: {{ fail_count }})</span>
<button class="copy-btn" onclick="copyKey('{{ key }}')">复制</button>
</li>
{% endfor %}
</ul>
</div>
<div class="key-list">
<h2>
无效密钥
<button class="copy-btn" onclick="copyKeys('invalid')">一键复制</button>
</h2>
<ul id="invalidKeys">
{% for key, fail_count in invalid_keys.items() %}
<li>
<span>{{ key }}</span>
<span class="fail-count">(失败次数: {{ fail_count }})</span>
<button class="copy-btn" onclick="copyKey('{{ key }}')">复制</button>
</li>
{% endfor %}
</ul>
</div>
<div class="total">
总密钥数:{{ total }}
</div>
<div id="copyStatus"></div>
</div>
<script>
function copyToClipboard(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
return navigator.clipboard.writeText(text);
} else {
return new Promise((resolve, reject) => {
const textArea = document.createElement("textarea");
textArea.value = text;
textArea.style.position = "fixed";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
const successful = document.execCommand('copy');
document.body.removeChild(textArea);
if (successful) {
resolve();
} else {
reject(new Error('复制失败'));
}
} catch (err) {
document.body.removeChild(textArea);
reject(err);
}
});
}
}
function copyKeys(type) {
const keys = Array.from(document.querySelectorAll(`#${type}Keys li span:first-child`)).map(span => span.textContent.trim());
const jsonKeys = JSON.stringify(keys);
copyToClipboard(jsonKeys)
.then(() => {
showCopyStatus(`已成功复制 ${type === 'valid' ? '有效' : '无效'} 密钥到剪贴板`);
})
.catch((err) => {
console.error('无法复制文本: ', err);
showCopyStatus('复制失败,请重试');
});
}
function copyKey(key) {
copyToClipboard(key)
.then(() => {
showCopyStatus(`已成功复制密钥到剪贴板`);
})
.catch((err) => {
console.error('无法复制文本: ', err);
showCopyStatus('复制失败,请重试');
});
}
function showCopyStatus(message) {
const statusElement = document.getElementById('copyStatus');
statusElement.textContent = message;
statusElement.style.opacity = 1;
setTimeout(() => {
statusElement.style.opacity = 0;
}, 2000);
}
</script>
</body>
</html>