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:
15
templates/admin/apikey/create.html
Normal file
15
templates/admin/apikey/create.html
Normal 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 %}
|
||||
17
templates/admin/apikey/list.html
Normal file
17
templates/admin/apikey/list.html
Normal 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 %}
|
||||
Reference in New Issue
Block a user