127 lines
3.8 KiB
HTML
127 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>API 文档 - OpenResty</title>
|
|
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
|
|
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
|
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
|
|
|
<!-- ✨ 自定义美化样式 -->
|
|
<style>
|
|
/* 全局字体与间距 */
|
|
.swagger-ui {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
|
|
font-size: 14px !important;
|
|
}
|
|
|
|
/* 顶部标题 */
|
|
.swagger-ui .info h1 {
|
|
font-weight: 700 !important;
|
|
font-size: 28px !important;
|
|
color: #2c3e50 !important;
|
|
margin-bottom: 8px !important;
|
|
}
|
|
|
|
/* 操作块容器 */
|
|
.swagger-ui .opblock {
|
|
border-radius: 12px !important;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
|
|
margin-bottom: 20px !important;
|
|
border-left: 0 !important;
|
|
}
|
|
|
|
/* HTTP 方法左侧彩色条 */
|
|
.swagger-ui .opblock-get { border-left: 5px solid #61affe !important; }
|
|
.swagger-ui .opblock-post { border-left: 5px solid #49cc90 !important; }
|
|
.swagger-ui .opblock-put { border-left: 5px solid #fca130 !important; }
|
|
.swagger-ui .opblock-delete { border-left: 5px solid #f93e3e !important; }
|
|
.swagger-ui .opblock-patch { border-left: 5px solid #50e3c2 !important; }
|
|
.swagger-ui .opblock-head { border-left: 5px solid #9012fe !important; }
|
|
|
|
/* 按钮圆角 */
|
|
.swagger-ui .btn {
|
|
border-radius: 6px !important;
|
|
font-weight: 600 !important;
|
|
padding: 6px 16px !important;
|
|
}
|
|
|
|
/* 参数表格 */
|
|
.swagger-ui table thead tr th {
|
|
background-color: #f8f9fa !important;
|
|
font-weight: 600 !important;
|
|
padding: 10px !important;
|
|
}
|
|
.swagger-ui table tbody tr td {
|
|
padding: 10px 8px !important;
|
|
border-bottom: 1px solid #eee !important;
|
|
}
|
|
|
|
/* 响应示例背景 */
|
|
.swagger-ui .microlight {
|
|
background: #f6f8fa !important;
|
|
border-radius: 8px !important;
|
|
padding: 14px !important;
|
|
font-size: 13px !important;
|
|
}
|
|
|
|
/* 搜索框 */
|
|
.swagger-ui .filter-container input {
|
|
border: 1px solid #ddd !important;
|
|
border-radius: 8px !important;
|
|
padding: 8px 12px !important;
|
|
width: 100% !important;
|
|
max-width: 300px !important;
|
|
}
|
|
|
|
/* 服务器列表 */
|
|
.swagger-ui .servers > div {
|
|
margin-bottom: 12px !important;
|
|
}
|
|
|
|
/* 滚动条优化(可选) */
|
|
*::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
*::-webkit-scrollbar-track {
|
|
background: #f1f1f1;
|
|
}
|
|
*::-webkit-scrollbar-thumb {
|
|
background: #c1c1c1;
|
|
border-radius: 4px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="swagger-ui"></div>
|
|
|
|
<script src="./swagger-ui-bundle.js"></script>
|
|
<script src="./swagger-ui-standalone-preset.js"></script>
|
|
|
|
<script>
|
|
window.onload = function() {
|
|
const ui = SwaggerUIBundle({
|
|
url: "/api-docs", // ← 指向你的 OpenAPI JSON
|
|
dom_id: '#swagger-ui',
|
|
deepLinking: true,
|
|
docExpansion: "list", // 默认展开所有接口
|
|
filter: true, // 启用搜索过滤
|
|
displayRequestDuration: true, // 显示请求耗时
|
|
presets: [
|
|
SwaggerUIBundle.presets.apis,
|
|
SwaggerUIStandalonePreset
|
|
],
|
|
plugins: [
|
|
SwaggerUIBundle.plugins.DownloadUrl
|
|
],
|
|
layout: "StandaloneLayout",
|
|
// supportedSubmitMethods: [], // 生产环境取消注释以禁用 "Try it out"
|
|
});
|
|
|
|
window.ui = ui;
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|