feat: 添加 API 密钥菜单和文档链接
- 侧边栏添加 API 密钥菜单项 - API 密钥列表页添加 API 文档链接 - 添加 /docs/ 路由服务文档文件 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
9
app.py
9
app.py
@@ -83,6 +83,15 @@ def create_app(config_name='default'):
|
|||||||
return AdminModel.query.get(int(user_id))
|
return AdminModel.query.get(int(user_id))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# ========== 文档路由 ==========
|
||||||
|
@app.route('/docs/<path:filename>')
|
||||||
|
def serve_doc(filename):
|
||||||
|
"""服务文档文件"""
|
||||||
|
from flask import send_from_directory
|
||||||
|
import os
|
||||||
|
docs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'docs')
|
||||||
|
return send_from_directory(docs_dir, filename)
|
||||||
|
|
||||||
# ========== 前台路由 ==========
|
# ========== 前台路由 ==========
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends 'admin/model/list.html' %}
|
{% extends 'admin/model/list.html' %}
|
||||||
|
|
||||||
{% block tail %}
|
{% block head_css %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<style>
|
<style>
|
||||||
.api-key-cell {
|
.api-key-cell {
|
||||||
@@ -13,5 +13,25 @@
|
|||||||
.api-key-masked {
|
.api-key-masked {
|
||||||
color: #6c757d;
|
color: #6c757d;
|
||||||
}
|
}
|
||||||
|
.api-doc-link {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
.api-doc-link a {
|
||||||
|
color: #007bff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.api-doc-link a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block list_cards %}
|
||||||
|
{{ super() }}
|
||||||
|
<div class="api-doc-link">
|
||||||
|
<a href="{{ url_for('serve_doc', filename='API_DOC.md') }}" target="_blank">
|
||||||
|
<span class="material-symbols-outlined" style="vertical-align: middle;">description</span>
|
||||||
|
查看 API 文档
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -47,6 +47,12 @@
|
|||||||
<span class="nav-text">管理员</span>
|
<span class="nav-text">管理员</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item {% if active_page == 'api_key' %}active{% endif %}">
|
||||||
|
<a href="{{ url_for('api_keys.index_view') }}" class="nav-link">
|
||||||
|
<span class="material-symbols-outlined nav-icon">key</span>
|
||||||
|
<span class="nav-text">API密钥</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user