feat: 添加 API Key 发布功能

- 新增 ApiKey 模型,支持 API 密钥认证
- 添加 require_api_key 装饰器实现 API 认证
- 实现 5 个站点管理 API 接口 (GET/POST/PUT/DELETE)
- 添加后台 API Key 管理界面
- 添加数据库迁移脚本

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jowe
2026-03-23 22:50:03 +08:00
parent bcc6a7d874
commit 5cef0b94fd
5 changed files with 373 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
{% extends 'admin/model/create.html' %}
{% block tail %}
{{ super() }}
<script>
document.addEventListener('DOMContentLoaded', function() {
// 创建成功后显示 API Key
{% if created_at and model and model.key %}
setTimeout(function() {
alert('API Key 已创建:\n\n{{ model.key }}\n\n请妥善保存此密钥只会显示一次');
}, 500);
{% endif %}
});
</script>
{% endblock %}

View File

@@ -0,0 +1,17 @@
{% extends 'admin/model/list.html' %}
{% block tail %}
{{ super() }}
<style>
.api-key-cell {
font-family: monospace;
font-size: 12px;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
}
.api-key-masked {
color: #6c757d;
}
</style>
{% endblock %}