1496 lines
92 KiB
HTML
1496 lines
92 KiB
HTML
{% extends "base_tailwind.html" %}
|
||
|
||
{% block title %}API 接口测试 - {{ brand_name }}{% endblock %}
|
||
|
||
{% block extra_css %}
|
||
<style>
|
||
@keyframes fadeSlideIn {
|
||
from { opacity: 0; transform: translateY(8px); }
|
||
to { opacity: 1; transform: translateY(0); }
|
||
}
|
||
.row-animate { animation: fadeSlideIn 0.3s ease both; }
|
||
.api-card { transition: all 0.2s ease; }
|
||
.api-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
|
||
.dark .api-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
|
||
.method-badge { font-size: 0.65rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; letter-spacing: 0.3px; }
|
||
.method-get { background: #dbeafe; color: #1d4ed8; }
|
||
.method-post { background: #dcfce7; color: #16a34a; }
|
||
.dark .method-get { background: #1e3a5f; color: #93c5fd; }
|
||
.dark .method-post { background: #14532d; color: #86efac; }
|
||
.response-panel { max-height: 400px; overflow: auto; }
|
||
.response-panel pre { white-space: pre-wrap; word-break: break-word; font-size: 0.75rem; }
|
||
.param-input { font-size: 0.8rem; padding: 3px 8px; border-radius: 6px; border: 1px solid #e5e7eb; width: 100%; }
|
||
.dark .param-input { background: #1f2937; border-color: #374151; color: #e5e7eb; }
|
||
</style>
|
||
{% endblock %}
|
||
|
||
{% block content %}
|
||
<div>
|
||
<div class="flex items-center gap-3 mb-6 list-item-enter" style="animation-delay: 0ms;">
|
||
<div>
|
||
<h2 class="text-2xl font-bold flex items-center gap-2">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||
<polyline points="16 3 21 3 21 8"/><line x1="4" y1="20" x2="21" y2="3"/>
|
||
<polyline points="21 16 21 21 16 21"/><line x1="15" y1="15" x2="21" y2="21"/>
|
||
<line x1="4" y1="4" x2="9" y2="9"/>
|
||
</svg>
|
||
API 接口测试
|
||
</h2>
|
||
<p class="text-sm text-gray-500 dark:text-gray-400 mt-1">浏览并测试所有后端代理接口 · <a href="/api-examples" class="text-blue-600 dark:text-blue-400 hover:underline">查看调用示例</a></p>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 统计卡片 -->
|
||
<div id="statsRow" class="grid grid-cols-2 md:grid-cols-4 gap-3 mb-4 hidden list-item-enter" style="animation-delay: 50ms;">
|
||
<div class="glass rounded-xl p-4 text-center"><div class="text-2xl font-bold" id="statTotal">0</div><div class="text-xs text-gray-500 mt-1">总接口数</div></div>
|
||
<div class="glass rounded-xl p-4 text-center"><div class="text-2xl font-bold text-green-600" id="statTested">0</div><div class="text-xs text-gray-500 mt-1">已测试</div></div>
|
||
<div class="glass rounded-xl p-4 text-center"><div class="text-2xl font-bold text-blue-600" id="statGet">0</div><div class="text-xs text-gray-500 mt-1">GET</div></div>
|
||
<div class="glass rounded-xl p-4 text-center"><div class="text-2xl font-bold text-orange-600" id="statPost">0</div><div class="text-xs text-gray-500 mt-1">POST</div></div>
|
||
</div>
|
||
|
||
<!-- API 分类 -->
|
||
<div id="apiGroups" class="space-y-4 list-item-enter" style="animation-delay: 100ms;"></div>
|
||
|
||
<!-- 无数据 -->
|
||
<div id="emptyState" class="glass rounded-2xl p-12 text-center hidden">
|
||
<p class="text-gray-500 text-lg">暂无 API 数据</p>
|
||
</div>
|
||
</div>
|
||
{% endblock %}
|
||
|
||
{% block extra_js %}
|
||
<script>
|
||
// ─── SVG 图标常量 ────────────────────────────────────
|
||
const ICONS = {
|
||
key: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><circle cx="7.5" cy="15.5" r="5.5"/><path d="m21 2-9.6 9.6"/><path d="m15.5 7.5 3 3L22 7l-3-3Z"/></svg>',
|
||
book: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"/></svg>',
|
||
openBook: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg>',
|
||
grad: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z"/><path d="M22 10v6"/><path d="M6 12.5V16a6 6 0 0 0 12 0v-3.5"/></svg>',
|
||
school: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="m4 6 8-4 8 4"/><path d="m18 10 4 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-8l4-2"/><path d="M14 22v-4a2 2 0 0 0-4 0v4"/><path d="M18 5v17"/><path d="M6 5v17"/><circle cx="12" cy="9" r="2"/></svg>',
|
||
books: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/><path d="M6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>',
|
||
user: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>',
|
||
gear: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z"/><path d="M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"/></svg>',
|
||
bulb: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1.5-1.5 2-3.5 1.5-5.5S15.5 3 13 3s-5 1-5.5 3c-.5 2 .5 3.5 1.5 5.5.8.8 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>',
|
||
inBox: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M22 8.5a2.5 2.5 0 0 0-2.5-2.5H4.5A2.5 2.5 0 0 0 2 8.5v7a2.5 2.5 0 0 0 2.5 2.5h15a2.5 2.5 0 0 0 2.5-2.5Z"/><path d="M12 2v6"/><path d="m8 8 4-4 4 4"/></svg>',
|
||
outBox: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M22 8.5a2.5 2.5 0 0 0-2.5-2.5H4.5A2.5 2.5 0 0 0 2 8.5v7a2.5 2.5 0 0 0 2.5 2.5h15a2.5 2.5 0 0 0 2.5-2.5Z"/><path d="M12 14v6"/><path d="m8 16 4 4 4-4"/></svg>',
|
||
lock: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>',
|
||
rocket: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"/><path d="m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"/><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/></svg>',
|
||
copy: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
||
python: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><path d="M12 10V2a1 1 0 0 0-1-1H8a5 5 0 0 0-5 5v1a1 1 0 0 0 1 1h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a2 2 0 0 0-2 2v3a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-3a1 1 0 0 1 1-1h7a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1Z"/><path d="M12 14v8a1 1 0 0 0 1 1h3a5 5 0 0 0 5-5v-1a1 1 0 0 0-1-1h-3a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1h3a2 2 0 0 0 2-2v-3a1 1 0 0 0-1-1h-3a1 1 0 0 0-1 1v3a1 1 0 0 1-1 1H6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1Z"/></svg>',
|
||
check: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block -mt-0.5 mr-1"><polyline points="20 6 9 17 4 12"/></svg>'
|
||
};
|
||
|
||
// ─── API 定义(含输入/输出字段注释)───────────────────
|
||
const API_GROUPS = [
|
||
{
|
||
name: ICONS.key + '认证与账号',
|
||
apis: [
|
||
{
|
||
method: 'POST', url: '/api/login',
|
||
desc: '登录获取 session cookie',
|
||
params: [
|
||
{ key:'username', label:'用户名', type:'string', required:true, ph:'网站登录用户名' },
|
||
{ key:'password', label:'密码', type:'string', required:true, ph:'网站登录密码' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'登录成功/用户名或密码错误', type:'string' },
|
||
],
|
||
note: '登录后浏览器自动携带 session cookie,后续 API 无需再传凭证'
|
||
},
|
||
|
||
{
|
||
method: 'POST', url: '/api/user/change_password',
|
||
desc: '修改登录密码',
|
||
params: [
|
||
{ key:'old_password', label:'旧密码', type:'string', required:true, ph:'当前密码' },
|
||
{ key:'new_password', label:'新密码', type:'string', required:true, ph:'新密码(至少6位)' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'修改成功/旧密码错误', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/user/jwxt/config',
|
||
desc: '配置/修改教务系统账号',
|
||
params: [
|
||
{ key:'jwxt_username', label:'教务用户名', type:'string', required:true, ph:'学号' },
|
||
{ key:'jwxt_password', label:'教务密码', type:'string', required:true, ph:'教务系统密码' },
|
||
{ key:'jwxt_name', label:'姓名', type:'string', required:false, ph:'真实姓名(可选)' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'配置结果', type:'string' },
|
||
{ key:'user', desc:'更新后的用户对象', type:'object' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.user + '用户信息与Session',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/user/info',
|
||
desc: '当前登录用户信息', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'user', desc:'用户对象', type:'object' },
|
||
{ key:'user.id', desc:'用户ID', type:'int' },
|
||
{ key:'user.username', desc:'用户名', type:'string' },
|
||
{ key:'user.jwxt_name', desc:'教务系统姓名', type:'string' },
|
||
{ key:'user.is_admin', desc:'是否管理员', type:'bool' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/user/session/status',
|
||
desc: '教务Session状态', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'is_valid', desc:'Session是否有效', type:'bool' },
|
||
{ key:'status', desc:'状态(valid/invalid/no_account)', type:'string' },
|
||
{ key:'jwxt_username', desc:'教务系统用户名', type:'string' },
|
||
{ key:'updated_at', desc:'最后更新时间', type:'string' },
|
||
{ key:'error_msg', desc:'错误信息(无效时)', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/user/session/refresh',
|
||
desc: '手动刷新教务Session',
|
||
params: [
|
||
{ key:'jwxt_password', label:'教务密码(更新用)', type:'string', required:false, ph:'如需更新密码时填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'status', desc:'状态(valid/refreshed/failed)', type:'string' },
|
||
{ key:'message', desc:'刷新结果', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/system/status',
|
||
desc: '系统运行状态(无需登录)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'status', desc:'运行状态(running)', type:'string' },
|
||
{ key:'timestamp', desc:'服务器时间', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/ping',
|
||
desc: 'Session 健康检查(自动刷新过期session)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'refreshed', desc:'是否触发了session刷新', type:'bool' },
|
||
{ key:'message', desc:'状态描述', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/menu',
|
||
desc: '教务系统菜单树', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'menu[]', desc:'菜单树列表', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/semesters',
|
||
desc: '获取学年和学期下拉选项(从教务HTML解析)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'years[]', desc:'学年列表', type:'array' },
|
||
{ key:'years[].value', desc:'学年值(如 2025)', type:'string' },
|
||
{ key:'years[].label', desc:'学年标签(如 2025-2026)', type:'string' },
|
||
{ key:'terms[]', desc:'学期列表', type:'array' },
|
||
{ key:'terms[].value', desc:'学期码(3/12)', type:'string' },
|
||
{ key:'terms[].label', desc:'学期名(第一学期/第二学期)', type:'string' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.openBook + '课表',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/timetable/semester',
|
||
desc: '获取学期信息(学年/学期/周次列表)',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025,不传则自动推算' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3=第一学期 或 12=第二学期' },
|
||
],
|
||
returns: [
|
||
{ key:'data.xnm', desc:'当前学年', type:'string' },
|
||
{ key:'data.xqm', desc:'当前学期', type:'string' },
|
||
{ key:'data.xqh_id', desc:'校区ID', type:'string' },
|
||
{ key:'data.current_week', desc:'当前周次', type:'int' },
|
||
{ key:'data.weeks[]', desc:'周次列表', type:'array' },
|
||
{ key:'data.weeks[].zs', desc:'周次编号', type:'string' },
|
||
{ key:'data.weeks[].zcrq', desc:'周日期范围', type:'string' },
|
||
{ key:'data.xnm_options[]', desc:'可用学年选项列表', type:'array' },
|
||
{ key:'data.xqm_options[]', desc:'可用学期选项列表', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/timetable',
|
||
desc: '获取课表数据',
|
||
params: [
|
||
{ key:'kblx', label:'课表类型', type:'string', required:false, ph:'1=按周, 2=全学期(默认)' },
|
||
{ key:'week', label:'周次', type:'int', required:false, ph:'kblx=1 时必填' },
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'不传则自动推算' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'不传则自动推算' },
|
||
],
|
||
returns: [
|
||
{ key:'data.kbList[]', desc:'课程列表', type:'array' },
|
||
{ key:'kbList[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'kbList[].xm', desc:'授课教师', type:'string' },
|
||
{ key:'kbList[].cdmc', desc:'上课地点', type:'string' },
|
||
{ key:'kbList[].xqj', desc:'星期(1-7)', type:'int' },
|
||
{ key:'kbList[].jcor', desc:'节次范围(如 1-2)', type:'string' },
|
||
{ key:'kbList[].zcd', desc:'周次描述(如 1-16周)', type:'string' },
|
||
{ key:'data.sjkList[]', desc:'实践课列表', type:'array' },
|
||
{ key:'data.xsxx', desc:'学生基本信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/timetable/jc_times',
|
||
desc: '获取节次上下课时间',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'不传则自动推算' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'不传则自动推算' },
|
||
],
|
||
returns: [
|
||
{ key:'data.{节次}', desc:'键为节次编号(1-11)', type:'object' },
|
||
{ key:'data.{n}.start', desc:'上课时间', type:'string(如 08:30)' },
|
||
{ key:'data.{n}.end', desc:'下课时间', type:'string' },
|
||
{ key:'data.{n}.period', desc:'时段(上午/下午/晚上)', type:'string' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.grad + '成绩与学业',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/jwxt/grades',
|
||
desc: '成绩查询 — 返回完整教务系统字段',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期码', type:'string', required:false, ph:'3=第一学期, 12=第二学期' },
|
||
{ key:'semester', label:'学期(旧版)', type:'string', required:false, ph:'如 2025-2026-2(兼容)' },
|
||
{ key:'kcbj', label:'课程标记', type:'string', required:false, ph:'0主修/1辅修/...' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 100' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'total', desc:'总条数', type:'int' },
|
||
{ key:'items[]', desc:'成绩列表', type:'array' },
|
||
{ key:'items[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'items[].kch', desc:'课程代码', type:'string' },
|
||
{ key:'items[].cj', desc:'成绩', type:'string' },
|
||
{ key:'items[].jd', desc:'绩点', type:'string' },
|
||
{ key:'items[].xf', desc:'学分', type:'string' },
|
||
{ key:'items[].xfjd', desc:'学分绩点', type:'string' },
|
||
{ key:'items[].kcxzmc', desc:'课程性质', type:'string' },
|
||
{ key:'items[].ksxz', desc:'成绩性质', type:'string' },
|
||
{ key:'items[].jsxm', desc:'任课教师', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/exams',
|
||
desc: '考试安排查询',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
{ key:'semester', label:'学期(旧版)', type:'string', required:false, ph:'如 2025-2026-2' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'考试列表', type:'array' },
|
||
{ key:'items[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'items[].kssj', desc:'考试时间', type:'string' },
|
||
{ key:'items[].cdmc', desc:'考试地点', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/student-info',
|
||
desc: '学生基本信息', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'info.XM', desc:'姓名', type:'string' },
|
||
{ key:'info.XH', desc:'学号', type:'string' },
|
||
{ key:'info.BJMC', desc:'班级', type:'string' },
|
||
{ key:'info.YXMC', desc:'学院', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/personal-info',
|
||
desc: '个人信息(含照片)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'info', desc:'个人信息对象', type:'object' },
|
||
{ key:'info.photo_base64', desc:'照片(base64)', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/academic-warning',
|
||
desc: '学业预警查询',
|
||
params: [
|
||
{ key:'jg_id', label:'机构ID', type:'string', required:false, ph:'自动填充默认值' },
|
||
{ key:'njdm_id', label:'年级代码', type:'string', required:false, ph:'自动填充默认值' },
|
||
{ key:'zyh_id', label:'专业号ID', type:'string', required:false, ph:'自动填充默认值' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'预警数据', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/academic-warning/params',
|
||
desc: '学业预警页面参数(下拉选项和默认值)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'defaults', desc:'默认参数', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/retake-courses',
|
||
desc: '重修课程查询(默认自动匹配不及格成绩)',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
{ key:'kkbm_id', label:'开课部门ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'kclbdm', label:'课程类别代码', type:'string', required:false, ph:'可选' },
|
||
{ key:'kkxbm', label:'开课校区', type:'string', required:false, ph:'可选' },
|
||
{ key:'show_all', label:'显示全部', type:'string', required:false, ph:'1=显示全部(不匹配), 0=自动匹配(默认)' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 500' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'重修课程列表', type:'array' },
|
||
{ key:'failed_courses[]', desc:'不及格课程列表', type:'array' },
|
||
{ key:'matched', desc:'是否已匹配不及格课程', type:'bool' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/academic-status',
|
||
desc: '查询培养方案完成度(树形结构 + GPA)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'student_name', desc:'学生姓名', type:'string' },
|
||
{ key:'gpa', desc:'平均学分绩点', type:'string' },
|
||
{ key:'stat_time', desc:'统计时间', type:'string' },
|
||
{ key:'nodes[]', desc:'扁平节点列表', type:'array' },
|
||
{ key:'nodes[].id', desc:'节点ID (xfyqjd_id)', type:'string' },
|
||
{ key:'nodes[].name', desc:'节点名称', type:'string' },
|
||
{ key:'nodes[].earned_credits', desc:'已获学分', type:'float' },
|
||
{ key:'nodes[].required_credits', desc:'要求学分', type:'float' },
|
||
{ key:'nodes[].passed', desc:'是否通过', type:'bool' },
|
||
{ key:'tree[]', desc:'树形结构(含 children)', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/academic-status/courses',
|
||
desc: '查询某节点下的课程明细',
|
||
params: [
|
||
{ key:'xfyqjd_id', label:'节点ID', type:'string', required:true, ph:'如 55FB2B96...' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'total', desc:'课程总数', type:'int' },
|
||
{ key:'passed', desc:'通过门数', type:'int' },
|
||
{ key:'courses[]', desc:'课程列表', type:'array' },
|
||
{ key:'courses[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'courses[].xf', desc:'学分', type:'string' },
|
||
{ key:'courses[].cj', desc:'成绩', type:'string' },
|
||
{ key:'courses[].jd', desc:'绩点', type:'float' },
|
||
{ key:'courses[].kczt', desc:'状态码(4已修 1在修 3未修)', type:'int' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.books + '选课',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/courses/tabs',
|
||
desc: '获取所有课程类型标签页', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'tabs[]', desc:'标签页列表', type:'array' },
|
||
{ key:'tabs[].kklxdm', desc:'课程类型代码', type:'string' },
|
||
{ key:'tabs[].kklxmc', desc:'课程类型名称', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/courses/search_full',
|
||
desc: '搜索课程并一次性展开所有教学班(推荐替代 list+jxb_list 两步调用)',
|
||
params: [
|
||
{ key:'keyword', label:'关键词', type:'string', required:false, ph:'课程名称或课程号' },
|
||
{ key:'kklxdm', label:'课程类型代码', type:'string', required:false, ph:'从tabs接口获取' },
|
||
{ key:'xkkz_id', label:'选课控制ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认50' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'courses[]', desc:'课程列表(含展开的教学班)', type:'array' },
|
||
{ key:'courses[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'courses[].jxbs', desc:'教学班列表(已展开)', type:'array' },
|
||
{ key:'total', desc:'总条数', type:'int' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/courses/list',
|
||
desc: '搜索课程(不含教学班)',
|
||
params: [
|
||
{ key:'keyword', label:'关键词', type:'string', required:false, ph:'课程名称或课程号' },
|
||
{ key:'kklxdm', label:'课程类型代码', type:'string', required:false, ph:'从tabs接口获取' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'courses[]', desc:'课程列表', type:'array' },
|
||
{ key:'courses[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'courses[].kch_id', desc:'课程号ID', type:'string' },
|
||
{ key:'courses[].xf', desc:'学分', type:'string' },
|
||
{ key:'courses[].kklxdm', desc:'课程类型代码', type:'string' },
|
||
{ key:'total', desc:'总条数', type:'int' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/courses/jxb_list',
|
||
desc: '展开教学班列表',
|
||
params: [
|
||
{ key:'kch_id', label:'课程号ID', type:'string', required:true, ph:'从课程列表获取' },
|
||
{ key:'kklxdm', label:'课程类型代码', type:'string', required:false, ph:'可选' },
|
||
{ key:'cxbj', label:'重修标记', type:'string', required:false, ph:'0或1' },
|
||
{ key:'fxbj', label:'分班标记', type:'string', required:false, ph:'0或1' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'jxbs[]', desc:'教学班列表', type:'array' },
|
||
{ key:'jxbs[].jxb_id', desc:'教学班ID', type:'string' },
|
||
{ key:'jxbs[].jxb_name', desc:'教学班名称', type:'string' },
|
||
{ key:'jxbs[].skjs', desc:'授课教师', type:'string' },
|
||
{ key:'jxbs[].skdd', desc:'上课地点', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/courses/chosen',
|
||
desc: '已选课程列表', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'courses[]', desc:'已选课程列表', type:'array' },
|
||
{ key:'courses[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'courses[].jxb_id', desc:'教学班ID', type:'string' },
|
||
{ key:'courses[].skjs', desc:'授课教师', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/courses/chosen-heatmap',
|
||
desc: '已选课程空闲热度图', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'html', desc:'热度图HTML表格', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/courses/status',
|
||
desc: '选课状态(是否开放)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'is_open', desc:'选课是否开放', type:'bool' },
|
||
{ key:'message', desc:'状态描述', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/filter-options',
|
||
desc: '课程筛选选项',
|
||
params: [
|
||
{ key:'type', label:'筛选类型', type:'string', required:true, ph:'kkbm/nj/xy/zy/kclb/kcxz/kcgs/kcz/yqu/jxms/sksj/skjc/bh/xq/zyfx' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'options', desc:'选项列表', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/courses/add',
|
||
desc: '选课',
|
||
params: [
|
||
{ key:'jxb_id', label:'教学班ID', type:'string', required:true, ph:'必填' },
|
||
{ key:'do_jxb_id', label:'加密ID', type:'string', required:true, ph:'选课参数中的 do_jxb_id' },
|
||
{ key:'kch_id', label:'课程号ID', type:'string', required:true, ph:'选课参数中的 kch_id' },
|
||
{ key:'kklxdm', label:'课程类型代码', type:'string', required:false, ph:'如 01' },
|
||
{ key:'kcmc', label:'课程名称', type:'string', required:false, ph:'可选' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/courses/drop',
|
||
desc: '退课',
|
||
params: [
|
||
{ key:'jxb_id', label:'教学班ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'do_jxb_id', label:'加密ID', type:'string', required:true, ph:'必填' },
|
||
{ key:'kch_id', label:'课程号ID', type:'string', required:true, ph:'必填' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.gear + '任务管理',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/tasks/list',
|
||
desc: '抢课任务列表',
|
||
params: [
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认1' },
|
||
{ key:'per_page', label:'每页条数', type:'int', required:false, ph:'默认20' },
|
||
{ key:'status', label:'筛选状态', type:'string', required:false, ph:'pending/running/success/failed' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'tasks[]', desc:'任务列表', type:'array' },
|
||
{ key:'tasks[].course_name', desc:'课程名称', type:'string' },
|
||
{ key:'tasks[].status', desc:'状态(pending/running/success/failed)', type:'string' },
|
||
{ key:'tasks[].created_at', desc:'创建时间', type:'string' },
|
||
{ key:'total', desc:'总条数', type:'int' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/tasks/create',
|
||
desc: '创建抢课任务',
|
||
params: [
|
||
{ key:'course_id', label:'课程ID(jxb_id)', type:'string', required:true, ph:'必填' },
|
||
{ key:'course_name', label:'课程名称', type:'string', required:true, ph:'必填' },
|
||
{ key:'do_jxb_id', label:'加密ID', type:'string', required:false, ph:'选课参数' },
|
||
{ key:'kch_id', label:'课程号ID', type:'string', required:false, ph:'选课参数' },
|
||
{ key:'kklxdm', label:'课程类型代码', type:'string', required:false, ph:'选课参数' },
|
||
{ key:'teacher_name', label:'教师姓名', type:'string', required:false, ph:'可选' },
|
||
{ key:'credit', label:'学分', type:'string', required:false, ph:'可选' },
|
||
{ key:'class_info', label:'班级信息', type:'string', required:false, ph:'可选' },
|
||
{ key:'task_type', label:'任务类型', type:'string', required:false, ph:'immediate=立即(默认), scheduled=定时' },
|
||
{ key:'scheduled_time', label:'定时时间', type:'string', required:false, ph:'ISO格式(定时任务必填)' },
|
||
{ key:'max_retries', label:'最大重试次数', type:'int', required:false, ph:'0=无限(默认)' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'task', desc:'任务对象', type:'object' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/tasks/<task_id>',
|
||
desc: '获取任务详情',
|
||
params: [
|
||
{ key:'task_id', label:'任务ID(path)', type:'int', required:true, ph:'URL路径参数' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'task', desc:'任务详情对象', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/tasks/<task_id>/cancel',
|
||
desc: '取消抢课任务',
|
||
params: [
|
||
{ key:'task_id', label:'任务ID(path)', type:'int', required:true, ph:'URL路径参数' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'取消结果', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/logs/list',
|
||
desc: '抢课日志列表(分页)',
|
||
params: [
|
||
{ key:'task_id', label:'任务ID', type:'int', required:false, ph:'可选过滤' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认1' },
|
||
{ key:'per_page', label:'每页条数', type:'int', required:false, ph:'默认50' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'logs[]', desc:'日志列表', type:'array' },
|
||
{ key:'logs[].message', desc:'日志消息', type:'string' },
|
||
{ key:'logs[].level', desc:'日志级别', type:'string' },
|
||
{ key:'logs[].created_at', desc:'创建时间', type:'string' },
|
||
{ key:'total', desc:'总条数', type:'int' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/logs/recent',
|
||
desc: '最近抢课日志(用于实时更新)',
|
||
params: [
|
||
{ key:'task_id', label:'任务ID', type:'int', required:false, ph:'可选过滤' },
|
||
{ key:'after_id', label:'最后日志ID', type:'int', required:false, ph:'返回此ID之后的新日志' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'logs[]', desc:'日志列表', type:'array' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.openBook + '教材',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/jwxt/textbook-details',
|
||
desc: '教材明细查询',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
{ key:'xyzt', label:'选用状态', type:'string', required:false, ph:'1=已选, 0=未选' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 200' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'教材明细列表', type:'array' },
|
||
{ key:'items[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'items[].jcmc', desc:'教材名称', type:'string' },
|
||
{ key:'items[].isbn', desc:'ISBN号', type:'string' },
|
||
{ key:'items[].cbs', desc:'出版社', type:'string' },
|
||
{ key:'items[].jczz', desc:'作者', type:'string' },
|
||
{ key:'items[].price', desc:'定价', type:'string' },
|
||
{ key:'items[].xkzt', desc:'选用状态', type:'string' },
|
||
{ key:'items[].ydzt', desc:'预订状态', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/textbook-orders',
|
||
desc: '教材预订列表查询',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 1500' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'教材预订列表', type:'array' },
|
||
{ key:'items[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'items[].jsxx', desc:'教师信息', type:'string' },
|
||
{ key:'items[].kcxzmc', desc:'课程性质', type:'string' },
|
||
{ key:'items[].jcxx', desc:'教材信息', type:'string' },
|
||
{ key:'items[].zdzt', desc:'征订状态(已订/未订)', type:'string' },
|
||
{ key:'items[].jxb_id', desc:'教学班ID', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/textbook-order',
|
||
desc: '预订或退订教材',
|
||
params: [
|
||
{ key:'jxb_id', label:'教学班ID', type:'string', required:true, ph:'必填' },
|
||
{ key:'action', label:'操作', type:'string', required:true, ph:'order=预订, cancel=退订' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息(预订成功/退订成功)', type:'string' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.school + '教室/教师/教学计划',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/jwxt/classrooms',
|
||
desc: '空闲教室查询',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
{ key:'xqh_id', label:'校区ID', type:'string', required:false, ph:'如 1' },
|
||
{ key:'lh', label:'楼宇', type:'string', required:false, ph:'可选' },
|
||
{ key:'cdlb_id', label:'场地类别ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'cdejlb_id', label:'场地二级类别ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'qszws', label:'最小座位数', type:'string', required:false, ph:'可选' },
|
||
{ key:'jszws', label:'最大座位数', type:'string', required:false, ph:'可选' },
|
||
{ key:'cdmc', label:'场地名称', type:'string', required:false, ph:'模糊查询' },
|
||
{ key:'jyfs', label:'借用方式', type:'string', required:false, ph:'1(默认)' },
|
||
{ key:'zcd', label:'周次', type:'string', required:false, ph:'可选' },
|
||
{ key:'xqj', label:'星期', type:'string', required:false, ph:'1-7' },
|
||
{ key:'jcd', label:'节次', type:'string', required:false, ph:'可选' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 10' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'教室列表', type:'array' },
|
||
{ key:'items[].cdmc', desc:'教室名称', type:'string' },
|
||
{ key:'items[].cdzws', desc:'座位数', type:'int' },
|
||
{ key:'items[].cdlxmc', desc:'教室类型', type:'string' },
|
||
{ key:'items[].xqmc', desc:'校区', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/classroom-schedule',
|
||
desc: '场地课表查询',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
{ key:'xqh_id', label:'校区ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'lh', label:'楼宇', type:'string', required:false, ph:'可选' },
|
||
{ key:'cdbh', label:'场地编号', type:'string', required:false, ph:'可选' },
|
||
{ key:'cdlbid', label:'场地类别ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 100' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'场地课表列表', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/teacher-schedule',
|
||
desc: '教师列表查询',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
{ key:'jgh', label:'教师工号', type:'string', required:false, ph:'精确或模糊' },
|
||
{ key:'jg_id', label:'部门ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'xqh_id', label:'校区ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 1000' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'教师列表', type:'array' },
|
||
{ key:'items[].jgh', desc:'教师工号', type:'string' },
|
||
{ key:'items[].xm', desc:'教师姓名', type:'string' },
|
||
{ key:'items[].zcmc', desc:'职称', type:'string' },
|
||
{ key:'items[].jgmc', desc:'所属部门', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/teacher-schedule-detail',
|
||
desc: '教师课表明细',
|
||
params: [
|
||
{ key:'jgh', label:'教师工号', type:'string', required:true, ph:'必填' },
|
||
{ key:'xm', label:'教师姓名', type:'string', required:false, ph:'用于过滤课表' },
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'如 2025' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'3 或 12' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'kbList[]', desc:'课表列表', type:'array' },
|
||
{ key:'kbList[].kcmc', desc:'课程名称', type:'string' },
|
||
{ key:'kbList[].cdmc', desc:'上课地点', type:'string' },
|
||
{ key:'kbList[].xqj', desc:'星期', type:'int' },
|
||
{ key:'kbList[].skjc', desc:'上课节次', type:'string' },
|
||
{ key:'kbList[].zcd', desc:'周次范围', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/classroom/params',
|
||
desc: '空闲教室查询页面参数(下拉框选项)', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/classroom-filter-options',
|
||
desc: '教室筛选选项(校区/楼宇/类别)',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'可选' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'可选' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'xqh_options', desc:'校区选项', type:'array' },
|
||
{ key:'lh_options', desc:'楼宇选项', type:'array' },
|
||
{ key:'cdlx_options', desc:'教室类别选项', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/classroom-periods',
|
||
desc: '教室节次数据',
|
||
params: [
|
||
{ key:'xnm', label:'学年', type:'string', required:false, ph:'可选' },
|
||
{ key:'xqm', label:'学期', type:'string', required:false, ph:'可选' },
|
||
{ key:'xqh_id', label:'校区ID', type:'string', required:false, ph:'如 1' },
|
||
],
|
||
returns: [ { key:'success', desc:'是否成功', type:'bool' } ]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/teaching-plan',
|
||
desc: '教学执行计划列表',
|
||
params: [
|
||
{ key:'jg_id', label:'机构ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'njdm_id', label:'年级代码', type:'string', required:false, ph:'可选' },
|
||
{ key:'dlbs', label:'代类别', type:'string', required:false, ph:'可选' },
|
||
{ key:'zyh_id', label:'专业号ID', type:'string', required:false, ph:'可选' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 100' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'执行计划列表', type:'array' },
|
||
{ key:'items[].jxzxjhxx_id', desc:'计划ID', type:'string' },
|
||
{ key:'items[].jhxnmc', desc:'学年名称', type:'string' },
|
||
{ key:'items[].zymc', desc:'专业名称', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/teaching-plan/courses',
|
||
desc: '执行计划课程信息',
|
||
params: [
|
||
{ key:'jxzxjhxx_id', label:'执行计划ID', type:'string', required:true, ph:'必填,从teaching-plan获取' },
|
||
{ key:'jyxdxnm', label:'修读学年', type:'string', required:false, ph:'可选' },
|
||
{ key:'jyxdxqm', label:'修读学期', type:'string', required:false, ph:'可选' },
|
||
{ key:'page', label:'页码', type:'int', required:false, ph:'默认 1' },
|
||
{ key:'page_size', label:'每页条数', type:'int', required:false, ph:'默认 100' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'items[]', desc:'课程列表', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/teaching-plan/requirements/<id>',
|
||
desc: '修读要求详情',
|
||
params: [
|
||
{ key:'id', label:'计划ID(path)', type:'string', required:true, ph:'URL路径参数' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'html', desc:'修读要求HTML', type:'string' },
|
||
{ key:'parsed_tree', desc:'解析后的树形结构', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/teaching-plan/preview/<id>',
|
||
desc: '执行计划预览',
|
||
params: [
|
||
{ key:'id', label:'计划ID(path)', type:'string', required:true, ph:'URL路径参数' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'html', desc:'HTML预览', type:'string' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.bulb + '报名申请',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/jwxt/enrollment-change',
|
||
desc: '学籍异动申请 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'学籍异动信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/enrollment-change/submit',
|
||
desc: '学籍异动申请 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/retake-registration',
|
||
desc: '重修报名信息 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'重修报名信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/retake-registration/submit',
|
||
desc: '重修报名 — 提交',
|
||
params: [
|
||
{ key:'kch_id', label:'课程号ID', type:'string', required:true, ph:'必填' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/exam-registration',
|
||
desc: '考级项目报名 — 查询',
|
||
params: [
|
||
{ key:'xmlbfl', label:'项目类别分类', type:'string', required:false, ph:'默认 1001' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'考级报名信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/exam-registration/submit',
|
||
desc: '考级项目报名 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/exam-registration/expired',
|
||
desc: '考级过期项目报名信息 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'过期项目信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/teaching-project',
|
||
desc: '教学项目报名 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'教学项目信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/teaching-project/submit',
|
||
desc: '教学项目报名 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/credit-recognition',
|
||
desc: '成绩学分认定申请 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'学分认定信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/credit-recognition/submit',
|
||
desc: '成绩学分认定申请 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/course-substitution',
|
||
desc: '校内课程替代申请 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'课程替代信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/course-substitution/submit',
|
||
desc: '校内课程替代申请 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/grade-review',
|
||
desc: '成绩复查申请 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'成绩复查信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/grade-review/submit',
|
||
desc: '成绩复查申请 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.user + '信息维护',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/jwxt/personal-info-editable',
|
||
desc: '获取个人信息中可编辑的字段', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'fields', desc:'可编辑字段列表', type:'array' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/personal-info/update',
|
||
desc: '更新个人信息',
|
||
params: [
|
||
{ key:'(动态字段)', label:'可编辑字段', type:'object', required:true, ph:'根据 personal-info-editable 返回的字段填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
{
|
||
name: ICONS.grad + '毕业论文(设计)',
|
||
apis: [
|
||
{
|
||
method: 'GET', url: '/api/jwxt/thesis-topic',
|
||
desc: '毕业论文选题 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'选题信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/thesis-topic/submit',
|
||
desc: '毕业论文选题 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/supervisor-change',
|
||
desc: '更换指导教师申请 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'更换申请信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'POST', url: '/api/jwxt/supervisor-change/submit',
|
||
desc: '更换指导教师申请 — 提交',
|
||
params: [
|
||
{ key:'(动态字段)', label:'表单数据', type:'object', required:true, ph:'根据查询返回的表单结构填写' },
|
||
],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'message', desc:'结果消息', type:'string' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/thesis-process-docs',
|
||
desc: '毕业论文过程资料 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'过程资料信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/thesis-plagiarism-check',
|
||
desc: '毕业论文查重 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'查重信息', type:'object' },
|
||
]
|
||
},
|
||
{
|
||
method: 'GET', url: '/api/jwxt/thesis-grades',
|
||
desc: '毕业论文成绩 — 查询', params: [],
|
||
returns: [
|
||
{ key:'success', desc:'是否成功', type:'bool' },
|
||
{ key:'data', desc:'论文成绩信息', type:'object' },
|
||
]
|
||
},
|
||
]
|
||
},
|
||
|
||
];
|
||
|
||
// ─── 状态统计 ───────────────────────────────────────────
|
||
let testedCount = 0;
|
||
const totalCount = API_GROUPS.reduce((s, g) => s + g.apis.length, 0);
|
||
const getCount = API_GROUPS.reduce((s, g) => s + g.apis.filter(a => a.method === 'GET').length, 0);
|
||
const postCount = totalCount - getCount;
|
||
|
||
// ─── 渲染 ──────────────────────────────────────────────
|
||
function render() {
|
||
const container = document.getElementById('apiGroups');
|
||
container.innerHTML = API_GROUPS.map((group, gi) => `
|
||
<div class="glass rounded-2xl overflow-hidden row-animate" style="animation-delay: ${gi * 60}ms;">
|
||
<div class="px-4 py-2.5 border-b border-gray-100 dark:border-gray-800 flex items-center justify-between">
|
||
<h3 class="text-base font-bold">${group.name}</h3>
|
||
<span class="text-xs text-gray-400">${group.apis.length} 个接口</span>
|
||
</div>
|
||
<div class="divide-y divide-gray-50 dark:divide-gray-800/50">
|
||
${group.apis.map((api, ai) => `
|
||
<div class="api-card px-4 py-2.5" id="api-${gi}-${ai}">
|
||
<div class="flex items-start justify-between gap-3">
|
||
<div class="flex-1 min-w-0">
|
||
<div class="flex items-center gap-2 mb-1">
|
||
<span class="method-badge method-${api.method.toLowerCase()}">${api.method}</span>
|
||
<code class="text-xs font-mono text-gray-600 dark:text-gray-400 truncate">${api.url}</code>
|
||
</div>
|
||
<p class="text-xs text-gray-500 dark:text-gray-400">${api.desc}</p>
|
||
${api.note ? `<p class="text-xs text-amber-600 dark:text-amber-400 mt-1">${ICONS.bulb} ${api.note}</p>` : ''}
|
||
</div>
|
||
<button onclick="toggleTest(${gi}, ${ai})"
|
||
class="px-3 py-1 rounded-lg text-xs font-medium border border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex-shrink-0">
|
||
测试
|
||
</button>
|
||
</div>
|
||
|
||
<!-- 参数和响应区域(默认隐藏) -->
|
||
<div id="panel-${gi}-${ai}" class="hidden mt-3 pt-3 border-t border-gray-100 dark:border-gray-800">
|
||
${api.params.length > 0 ? `
|
||
<div class="mb-3">
|
||
<div class="text-[10px] font-semibold text-gray-500 mb-1.5">${ICONS.inBox} 传入参数</div>
|
||
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2">
|
||
${api.params.map(p => `
|
||
<div>
|
||
<label class="text-[10px] text-gray-400 block mb-0.5">
|
||
<code class="text-blue-600 dark:text-blue-400">${p.key}</code>
|
||
${p.required ? '<span class="text-red-400">*</span>' : ''}
|
||
<span class="text-gray-400">${p.type||'string'}</span>
|
||
</label>
|
||
<input id="param-${gi}-${ai}-${p.key}" placeholder="${p.ph}" class="param-input" title="${p.label}">
|
||
</div>
|
||
`).join('')}
|
||
</div>
|
||
</div>
|
||
` : '<div class="text-xs text-gray-400 mb-2">无需传入参数</div>'}
|
||
|
||
<!-- 认证方式(三选一) -->
|
||
<div class="mb-3 p-2.5 rounded-lg border border-dashed border-amber-200 dark:border-amber-800 bg-amber-50/30 dark:bg-amber-900/10">
|
||
<div class="text-[10px] font-semibold text-amber-600 dark:text-amber-400 mb-1.5">${ICONS.lock} 认证方式(三选一,任填一种即可)</div>
|
||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-2 mb-2">
|
||
<div>
|
||
<label class="text-[10px] text-gray-400 block mb-0.5"><code class="text-amber-600">session</code> <span>string</span></label>
|
||
<input id="auth_sess-${gi}-${ai}" placeholder="Flask session cookie 值" class="param-input font-mono text-[10px]">
|
||
<p class="text-[8px] text-amber-500/60 mt-0.5">登录后从 Cookie 头获取</p>
|
||
</div>
|
||
<div>
|
||
<label class="text-[10px] text-gray-400 block mb-0.5"><code class="text-amber-600">username</code> <span>string</span></label>
|
||
<input id="auth_user-${gi}-${ai}" placeholder="网站登录用户名" class="param-input">
|
||
<p class="text-[8px] text-amber-500/60 mt-0.5">无需预先登录</p>
|
||
</div>
|
||
<div>
|
||
<label class="text-[10px] text-gray-400 block mb-0.5"><code class="text-amber-600">password</code> <span>string</span></label>
|
||
<input id="auth_pass-${gi}-${ai}" type="password" placeholder="网站登录密码" class="param-input">
|
||
</div>
|
||
</div>
|
||
<p class="text-[9px] text-amber-500/70 mt-1">什么都不填则使用当前浏览器 cookie session。GET 请求参数自动放 query,POST 自动放 JSON body。</p>
|
||
</div>
|
||
|
||
${api.returns && api.returns.length > 0 ? `
|
||
<div class="mb-3">
|
||
<div class="text-[10px] font-semibold text-gray-500 mb-1.5">${ICONS.outBox} 传出字段</div>
|
||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 bg-gray-50/50 dark:bg-gray-900/30 rounded-lg p-3">
|
||
${api.returns.map(r => `
|
||
<div class="flex items-baseline gap-1.5 text-[11px]">
|
||
<code class="text-green-700 dark:text-green-400 font-mono shrink-0">${r.key}</code>
|
||
<span class="text-gray-400 text-[10px] shrink-0">${r.type||'any'}</span>
|
||
<span class="text-gray-500 dark:text-gray-400 truncate">${r.desc}</span>
|
||
</div>
|
||
`).join('')}
|
||
</div>
|
||
</div>
|
||
` : ''}
|
||
${api.method === 'POST' ? `
|
||
<div class="mb-2">
|
||
<label class="text-[10px] text-gray-400 block mb-0.5">请求体 (JSON)</label>
|
||
<textarea id="body-${gi}-${ai}" rows="2" class="param-input font-mono" placeholder='{"key": "value"}'></textarea>
|
||
</div>
|
||
` : ''}
|
||
<div class="flex gap-2 mb-2">
|
||
<button onclick="executeTest(${gi}, ${ai})"
|
||
class="px-4 py-1.5 rounded-lg text-xs font-medium bg-black text-white dark:bg-white dark:text-black hover:opacity-80 transition-opacity">
|
||
${ICONS.rocket} 发送请求
|
||
</button>
|
||
<button onclick="copyUrl(this, ${gi}, ${ai})"
|
||
class="px-3 py-1.5 rounded-lg text-xs font-medium border border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors">
|
||
${ICONS.copy} 复制URL
|
||
</button>
|
||
<button onclick="showPython(this, ${gi}, ${ai})"
|
||
class="px-3 py-1.5 rounded-lg text-xs font-medium border border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors">
|
||
${ICONS.python} Python
|
||
</button>
|
||
</div>
|
||
<div id="result-${gi}-${ai}" class="hidden">
|
||
<div class="flex items-center justify-between mb-1">
|
||
<span class="text-[10px] text-gray-400">响应</span>
|
||
<span id="status-${gi}-${ai}" class="text-[10px] font-mono"></span>
|
||
</div>
|
||
<div class="response-panel bg-gray-50 dark:bg-gray-900 rounded-lg p-3 border border-gray-200 dark:border-gray-700">
|
||
<pre id="resp-${gi}-${ai}" class="text-gray-700 dark:text-gray-300"></pre>
|
||
</div>
|
||
</div>
|
||
<!-- Python 代码 -->
|
||
<div id="python-${gi}-${ai}" class="hidden mt-2">
|
||
<div class="text-[10px] text-gray-400 mb-1">${ICONS.python} Python 示例代码</div>
|
||
<div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 border border-gray-200 dark:border-gray-700 overflow-x-auto">
|
||
<pre id="py-${gi}-${ai}" class="text-[10px] text-gray-700 dark:text-gray-300 font-mono whitespace-pre-wrap"></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`).join('')}
|
||
</div>
|
||
</div>
|
||
`).join('');
|
||
|
||
document.getElementById('statTotal').textContent = totalCount;
|
||
document.getElementById('statTested').textContent = '0';
|
||
document.getElementById('statGet').textContent = getCount;
|
||
document.getElementById('statPost').textContent = postCount;
|
||
document.getElementById('statsRow').classList.remove('hidden');
|
||
|
||
// 为所有输入框添加自动更新 Python 代码的事件
|
||
document.querySelectorAll('.param-input, [id^="auth_"]').forEach(el => {
|
||
el.addEventListener('input', function() {
|
||
const id = this.id;
|
||
const m = id.match(/(?:param|auth_sess|auth_user|auth_pass)-(\d+)-(\d+)/);
|
||
if (m) generatePython(parseInt(m[1]), parseInt(m[2]));
|
||
});
|
||
});
|
||
}
|
||
|
||
// ─── 交互 ──────────────────────────────────────────────
|
||
let _openPanel = null;
|
||
|
||
function toggleTest(gi, ai) {
|
||
const panel = document.getElementById(`panel-${gi}-${ai}`);
|
||
if (_openPanel && _openPanel !== panel) {
|
||
_openPanel.classList.add('hidden');
|
||
}
|
||
panel.classList.toggle('hidden');
|
||
const isOpen = !panel.classList.contains('hidden');
|
||
_openPanel = isOpen ? panel : null;
|
||
if (isOpen) {
|
||
generatePython(gi, ai);
|
||
}
|
||
}
|
||
|
||
// ─── Python 示例代码生成 ──────────────────────────
|
||
function generatePython(gi, ai) {
|
||
const api = API_GROUPS[gi].apis[ai];
|
||
const pyDiv = document.getElementById(`python-${gi}-${ai}`);
|
||
const pyPre = document.getElementById(`py-${gi}-${ai}`);
|
||
if (!pyDiv || !pyPre) return;
|
||
|
||
const authSess = document.getElementById(`auth_sess-${gi}-${ai}`)?.value || '';
|
||
const authUser = document.getElementById(`auth_user-${gi}-${ai}`)?.value || '';
|
||
const authPass = document.getElementById(`auth_pass-${gi}-${ai}`)?.value || '';
|
||
|
||
// Read params as key-value pairs
|
||
const paramPairs = [];
|
||
for (const p of (api.params || [])) {
|
||
const val = document.getElementById(`param-${gi}-${ai}-${p.key}`)?.value || '';
|
||
if (val) paramPairs.push({key: p.key, val});
|
||
}
|
||
|
||
const baseUrl = window.location.origin;
|
||
const pathOnly = api.url;
|
||
|
||
function quote(s) { return `'${String(s).replace(/'/g, "\\'")}'`; }
|
||
|
||
function buildParamsDict(pairs) {
|
||
if (pairs.length === 0) return '{}';
|
||
return '{\n' + pairs.map(p => ` ${quote(p.key)}: ${quote(p.val)}`).join(',\n') + '\n }';
|
||
}
|
||
|
||
function buildBodyDict(extra) {
|
||
const all = [...paramPairs];
|
||
if (extra) Object.keys(extra).forEach(k => { if (extra[k]) all.push({key: k, val: extra[k]}); });
|
||
if (all.length === 0) return '{}';
|
||
return '{\n' + all.map(p => ` ${quote(p.key)}: ${quote(p.val)}`).join(',\n') + '\n }';
|
||
}
|
||
|
||
let py = 'import requests\n\n';
|
||
|
||
if (authSess) {
|
||
const sessDict = `{'session': ${quote(authSess)}}`;
|
||
py += `# 方式:session 字段\n`;
|
||
py += `url = ${quote(baseUrl + pathOnly)}\n`;
|
||
if (api.method === 'GET') {
|
||
py += `params = ${buildParamsDict(paramPairs)}\n`;
|
||
py += `params['session'] = ${quote(authSess)}\n`;
|
||
py += `r = requests.get(url, params=params)\n`;
|
||
} else {
|
||
py += `headers = {'Content-Type': 'application/json'}\n`;
|
||
py += `body = ${buildBodyDict({session: authSess})}\n`;
|
||
py += `r = requests.post(url, json=body, headers=headers)\n`;
|
||
}
|
||
py += `print(r.json())\n`;
|
||
} else if (authUser && authPass) {
|
||
py += `# 方式:网站账号密码(无需预先登录)\n`;
|
||
py += `url = ${quote(baseUrl + pathOnly)}\n`;
|
||
if (api.method === 'GET') {
|
||
py += `params = ${buildParamsDict(paramPairs)}\n`;
|
||
py += `params['username'] = ${quote(authUser)}\n`;
|
||
py += `params['password'] = ${quote(authPass)}\n`;
|
||
py += `r = requests.get(url, params=params)\n`;
|
||
} else {
|
||
py += `headers = {'Content-Type': 'application/json'}\n`;
|
||
py += `body = ${buildBodyDict({username: authUser, password: authPass})}\n`;
|
||
py += `r = requests.post(url, json=body, headers=headers)\n`;
|
||
}
|
||
py += `print(r.json())\n`;
|
||
} else {
|
||
py += `# 方式:session cookie(需要先登录)\n`;
|
||
py += `s = requests.Session()\n`;
|
||
py += `s.post(${quote(baseUrl + '/api/login')}, json={'username': 'YOUR_USER', 'password': 'YOUR_PASS'})\n\n`;
|
||
py += `url = ${quote(baseUrl + pathOnly)}\n`;
|
||
if (api.method === 'GET') {
|
||
if (paramPairs.length > 0) {
|
||
py += `params = ${buildParamsDict(paramPairs)}\n`;
|
||
py += `r = s.get(url, params=params)\n`;
|
||
} else {
|
||
py += `r = s.get(url)\n`;
|
||
}
|
||
} else {
|
||
if (paramPairs.length > 0) {
|
||
py += `r = s.post(url, json=${buildParamsDict(paramPairs)})\n`;
|
||
} else {
|
||
py += `r = s.post(url, json={})\n`;
|
||
}
|
||
}
|
||
py += `print(r.json())\n`;
|
||
}
|
||
|
||
pyPre.textContent = py;
|
||
pyDiv.classList.remove('hidden');
|
||
}
|
||
|
||
async function executeTest(gi, ai) {
|
||
const api = API_GROUPS[gi].apis[ai];
|
||
const resultDiv = document.getElementById(`result-${gi}-${ai}`);
|
||
const respPre = document.getElementById(`resp-${gi}-${ai}`);
|
||
const statusSpan = document.getElementById(`status-${gi}-${ai}`);
|
||
|
||
resultDiv.classList.remove('hidden');
|
||
respPre.textContent = '请求中...';
|
||
statusSpan.textContent = '';
|
||
|
||
// 读取认证信息(三选一)
|
||
const authSess = document.getElementById(`auth_sess-${gi}-${ai}`)?.value || '';
|
||
const authUser = document.getElementById(`auth_user-${gi}-${ai}`)?.value || '';
|
||
const authPass = document.getElementById(`auth_pass-${gi}-${ai}`)?.value || '';
|
||
|
||
// 构建 URL
|
||
let url = api.url;
|
||
const params = [];
|
||
for (const p of (api.params || [])) {
|
||
const val = document.getElementById(`param-${gi}-${ai}-${p.key}`)?.value || '';
|
||
if (val) params.push(`${p.key}=${encodeURIComponent(val)}`);
|
||
}
|
||
// GET 请求:认证信息放 query string
|
||
if (api.method === 'GET') {
|
||
if (authSess) params.push(`session=${encodeURIComponent(authSess)}`);
|
||
else if (authUser && authPass) {
|
||
params.push(`username=${encodeURIComponent(authUser)}`);
|
||
params.push(`password=${encodeURIComponent(authPass)}`);
|
||
}
|
||
}
|
||
if (params.length > 0 && api.method === 'GET') url += '?' + params.join('&');
|
||
|
||
try {
|
||
const opts = { credentials: 'same-origin' };
|
||
let body = null;
|
||
if (api.method === 'POST') {
|
||
const bodyEl = document.getElementById(`body-${gi}-${ai}`);
|
||
if (bodyEl && bodyEl.value.trim()) {
|
||
try { body = JSON.parse(bodyEl.value); } catch(e) { body = bodyEl.value; }
|
||
}
|
||
// POST 请求:参数放 JSON body
|
||
if (!body || typeof body !== 'object') body = {};
|
||
// 从 params 中提取 API 参数(非认证参数)
|
||
params.forEach(p => {
|
||
const eq = p.indexOf('=');
|
||
if (eq > 0) {
|
||
const k = decodeURIComponent(p.substring(0, eq));
|
||
const v = decodeURIComponent(p.substring(eq + 1));
|
||
if (!['session','username','password'].includes(k)) {
|
||
body[k] = body[k] || v;
|
||
}
|
||
}
|
||
});
|
||
if (authSess) body.session = authSess;
|
||
else if (authUser && authPass) {
|
||
body.username = authUser;
|
||
body.password = authPass;
|
||
}
|
||
opts.method = 'POST';
|
||
opts.headers = { 'Content-Type': 'application/json' };
|
||
if (body) opts.body = JSON.stringify(body);
|
||
}
|
||
|
||
const start = performance.now();
|
||
const res = await fetch(url, opts);
|
||
const ms = Math.round(performance.now() - start);
|
||
const text = await res.text();
|
||
|
||
statusSpan.textContent = `${res.status} ${res.statusText} (${ms}ms)`;
|
||
statusSpan.className = `text-[10px] font-mono ${res.ok ? 'text-green-600' : 'text-red-500'}`;
|
||
|
||
// 美化 JSON
|
||
try { respPre.textContent = JSON.stringify(JSON.parse(text), null, 2); }
|
||
catch(e) { respPre.textContent = text; }
|
||
|
||
// 刷新 Python 示例(带上实际响应数据中的参数)
|
||
generatePython(gi, ai);
|
||
|
||
testedCount++;
|
||
document.getElementById('statTested').textContent = testedCount;
|
||
} catch (e) {
|
||
statusSpan.textContent = '请求失败';
|
||
statusSpan.className = 'text-[10px] font-mono text-red-500';
|
||
respPre.textContent = `Error: ${e.message}`;
|
||
}
|
||
}
|
||
|
||
function showPython(btn, gi, ai) {
|
||
const pyDiv = document.getElementById(`python-${gi}-${ai}`);
|
||
if (!pyDiv) return;
|
||
generatePython(gi, ai);
|
||
pyDiv.classList.toggle('hidden');
|
||
const hidden = pyDiv.classList.contains('hidden');
|
||
btn.innerHTML = `${ICONS.python} ${hidden ? 'Python' : '隐藏 Python'}`;
|
||
}
|
||
|
||
function copyUrl(btn, gi, ai) {
|
||
const api = API_GROUPS[gi].apis[ai];
|
||
const params = [];
|
||
for (const p of (api.params || [])) {
|
||
const val = document.getElementById(`param-${gi}-${ai}-${p.key}`)?.value || '';
|
||
if (val) params.push(`${p.key}=${encodeURIComponent(val)}`);
|
||
}
|
||
let url = window.location.origin + api.url;
|
||
if (params.length > 0) url += '?' + params.join('&');
|
||
navigator.clipboard.writeText(url).then(() => {
|
||
const orig = btn.innerHTML;
|
||
btn.innerHTML = `${ICONS.check} 已复制`;
|
||
setTimeout(() => btn.innerHTML = orig, 1500);
|
||
});
|
||
}
|
||
|
||
// ─── 初始化 ────────────────────────────────────────────
|
||
document.addEventListener('DOMContentLoaded', render);
|
||
</script>
|
||
{% endblock %}
|