zai / app /templates /components /token_list.html
sanbo110's picture
update sth at 2025-10-16 14:55:36
47258ea
<!-- Token 列表表格 -->
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Token</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">类型</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">健康度</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">状态</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">使用统计</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">创建时间</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
{% for token in tokens %}
{% include "components/token_row.html" %}
{% endfor %}
</tbody>
</table>
{% if not tokens %}
<div class="text-center py-12 text-gray-500">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4" />
</svg>
<p class="mt-2 font-medium">暂无 Token</p>
<p class="mt-1 text-sm">点击右上角"添加 Token"按钮开始添加</p>
</div>
{% endif %}
</div>
<!-- Token 数量统计(更新页面标题) -->
<script>
(function() {
const tokenCount = {{ tokens|length }};
const countElement = document.getElementById('token-count');
if (countElement) {
countElement.textContent = `(共 ${tokenCount} 个)`;
}
})();
</script>
<!-- 复制到剪贴板函数 -->
<script>
function copyToClipboard(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(() => {
// 显示临时提示
const notification = document.createElement('div');
notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded shadow-lg z-50';
notification.textContent = '✓ Token 已复制到剪贴板';
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 2000);
}).catch(err => {
console.error('复制失败:', err);
alert('复制失败,请手动复制');
});
} else {
// 降级方案:使用 execCommand
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
alert('Token 已复制到剪贴板');
} catch (err) {
alert('复制失败,请手动复制');
}
document.body.removeChild(textArea);
}
}
</script>