<!DOCTYPE html>
|
<html lang="zh-CN">
|
<head>
|
<meta charset="UTF-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<style>
|
* {
|
margin: 0;
|
padding: 0;
|
box-sizing: border-box;
|
}
|
|
body {
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
background: linear-gradient(135deg, #ffffff, #f8f9fa);
|
padding: 20px;
|
}
|
|
h3 {
|
font-size: 18px;
|
background: linear-gradient(135deg, #0066cc, #00c6ff);
|
-webkit-background-clip: text;
|
-webkit-text-fill-color: transparent;
|
background-clip: text;
|
margin-bottom: 20px;
|
cursor: pointer;
|
font-weight: 700;
|
padding-bottom: 15px;
|
border-bottom: 2px solid #e0e0e0;
|
position: relative;
|
}
|
|
h3::after {
|
content: '';
|
position: absolute;
|
bottom: -2px;
|
left: 0;
|
width: 40px;
|
height: 2px;
|
background: linear-gradient(90deg, #0066cc, #00c6ff);
|
}
|
|
.sidebar-menu {
|
list-style: none;
|
}
|
|
/* 一级菜单项 */
|
.sidebar-menu > li {
|
padding: 0;
|
margin-bottom: 5px;
|
position: relative;
|
border-radius: 8px;
|
overflow: hidden;
|
}
|
|
/* 菜单头部 */
|
.menu-header {
|
padding: 12px 15px;
|
color: #555;
|
font-size: 14px;
|
transition: all 0.3s ease;
|
position: relative;
|
overflow: hidden;
|
font-weight: 600;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
/* 菜单文字 */
|
.menu-text {
|
flex: 1;
|
user-select: none;
|
}
|
|
/* 菜单头部内容容器 */
|
.menu-header > * {
|
user-select: none;
|
}
|
|
.menu-header:hover {
|
background: linear-gradient(135deg, #e8f4ff, #d4e9ff);
|
box-shadow: 0 2px 8px rgba(0, 102, 204, 0.1);
|
}
|
|
.sidebar-menu > li:hover::before {
|
transform: scaleY(1);
|
}
|
|
.sidebar-menu > li.active .menu-header {
|
background: linear-gradient(135deg, #0066cc, #0052a3);
|
color: #fff;
|
box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
|
}
|
|
.sidebar-menu > li::before {
|
content: '';
|
position: absolute;
|
left: 0;
|
top: 0;
|
height: 100%;
|
width: 3px;
|
background: linear-gradient(180deg, #0066cc, #00c6ff);
|
transform: scaleY(0);
|
transition: transform 0.3s ease;
|
}
|
|
.sidebar-menu > li:hover {
|
background: linear-gradient(135deg, #e8f4ff, #d4e9ff);
|
box-shadow: 0 2px 8px rgba(0, 102, 204, 0.1);
|
}
|
|
.sidebar-menu > li:hover::before {
|
transform: scaleY(1);
|
}
|
|
.sidebar-menu > li.active {
|
background: linear-gradient(135deg, #0066cc, #0052a3);
|
color: #fff;
|
box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
|
}
|
|
/* 二级菜单容器 */
|
.submenu {
|
list-style: none;
|
margin-top: 5px;
|
margin-left: 10px;
|
margin-bottom: 10px;
|
display: none;
|
}
|
|
/* 展开的二级菜单 */
|
.submenu.expanded {
|
display: block;
|
}
|
|
/* 二级菜单项 */
|
.submenu li {
|
padding: 8px 15px;
|
cursor: pointer;
|
color: #666;
|
font-size: 13px;
|
border-radius: 6px;
|
margin-bottom: 3px;
|
transition: all 0.3s ease;
|
position: relative;
|
}
|
|
.submenu li:hover {
|
background: rgba(0, 102, 204, 0.08);
|
padding-left: 20px;
|
}
|
|
.submenu li.active {
|
background: rgba(0, 102, 204, 0.15);
|
color: #0066cc;
|
font-weight: 500;
|
}
|
|
/* 菜单链接 */
|
.sidebar-menu a {
|
color: inherit;
|
text-decoration: none;
|
display: block;
|
transition: color 0.3s ease;
|
}
|
|
/* 展开/折叠图标 */
|
.menu-toggle {
|
cursor: pointer;
|
font-size: 12px;
|
transition: transform 0.3s ease;
|
padding: 4px 8px;
|
border-radius: 4px;
|
user-select: none;
|
}
|
|
.menu-toggle:hover {
|
background: rgba(0, 102, 204, 0.1);
|
}
|
|
.menu-toggle.expanded {
|
transform: rotate(90deg);
|
}
|
|
/* 滚动条美化 */
|
::-webkit-scrollbar {
|
width: 6px;
|
}
|
|
::-webkit-scrollbar-track {
|
background: #f1f1f1;
|
border-radius: 3px;
|
}
|
|
::-webkit-scrollbar-thumb {
|
background: linear-gradient(135deg, #667eea, #764ba2);
|
border-radius: 3px;
|
}
|
|
::-webkit-scrollbar-thumb:hover {
|
background: linear-gradient(135deg, #764ba2, #667eea);
|
}
|
</style>
|
</head>
|
<body>
|
<h3>RCS接口文档</h3>
|
<ul class="sidebar-menu" id="sidebar-menu-container">
|
<!-- 概览类 -->
|
<li>
|
<div class="menu-header">
|
<span class="menu-text">概览</span>
|
<span class="menu-toggle expanded" onclick="toggleMenu(this)">▶</span>
|
</div>
|
<ul class="submenu expanded">
|
<li><a href="#api-overview" class="submenu-link" data-section="api-overview" onclick="navigateToSection(this); return false;">接口概览</a></li>
|
<li><a href="#error-codes" class="submenu-link" data-section="error-codes" onclick="navigateToSection(this); return false;">错误码说明</a></li>
|
</ul>
|
</li>
|
|
<!-- 任务管理类 -->
|
<li>
|
<div class="menu-header">
|
<span class="menu-text">任务管理</span>
|
<span class="menu-toggle" onclick="toggleMenu(this)">▶</span>
|
</div>
|
<ul class="submenu expanded" id="menu-task-management">
|
<!-- 动态生成 -->
|
</ul>
|
</li>
|
</ul>
|
|
<script>
|
// 添加防抖变量
|
let lastToggleTime = 0;
|
const toggleDebounceTime = 200; // 200毫秒防抖
|
|
// 切换二级菜单展开/折叠
|
function toggleMenu(element) {
|
// 防止快速连续点击
|
const currentTime = new Date().getTime();
|
if (currentTime - lastToggleTime < toggleDebounceTime) {
|
return;
|
}
|
lastToggleTime = currentTime;
|
|
// 只处理直接点击菜单图标的情况
|
const menuItem = element.closest('li');
|
if (menuItem) {
|
const submenu = menuItem.querySelector('.submenu');
|
const menuToggle = menuItem.querySelector('.menu-toggle');
|
|
if (submenu) {
|
submenu.classList.toggle('expanded');
|
}
|
|
if (menuToggle) {
|
menuToggle.classList.toggle('expanded');
|
}
|
}
|
}
|
|
// 滚动到指定章节
|
function scrollToSection(sectionId) {
|
window.parent.postMessage({
|
type: 'scrollToSection',
|
sectionId: sectionId
|
}, '*');
|
}
|
|
// 导航到指定章节
|
function navigateToSection(element) {
|
const sectionId = element.getAttribute('data-section');
|
if (sectionId) {
|
scrollToSection(sectionId);
|
}
|
}
|
|
// 加载API配置文件并生成菜单
|
function loadApiMenu() {
|
try {
|
// 直接定义API配置数据,避免CORS错误
|
const apiConfigs = [
|
{
|
"apiId": "api-task-create",
|
"name": "生成任务单",
|
"description": "创建搬运任务",
|
"isCommon": true,
|
"method": "POST",
|
"url": "/api/open/bus/submit",
|
"menu": {
|
"category": "任务管理",
|
"order": 1
|
}
|
},
|
{
|
"apiId": "api-task-cancel",
|
"name": "取消任务",
|
"description": "取消搬运任务",
|
"isCommon": false,
|
"method": "POST",
|
"url": "/api/open/bus/cancel",
|
"menu": {
|
"category": "任务管理",
|
"order": 2
|
}
|
},
|
{
|
"apiId": "api-task-allocate",
|
"name": "申请入库接口",
|
"description": "申请任务入库",
|
"isCommon": true,
|
"method": "POST",
|
"url": "/api/open/task/allocate",
|
"menu": {
|
"category": "任务管理",
|
"order": 3
|
}
|
},
|
{
|
"apiId": "api-task-notice",
|
"name": "任务状态通知",
|
"description": "通知任务状态变更",
|
"isCommon": false,
|
"method": "POST",
|
"url": "/api/open/bus/notice",
|
"menu": {
|
"category": "任务管理",
|
"order": 4
|
}
|
},
|
{
|
"apiId": "api-task-priority",
|
"name": "任务优先级调整",
|
"description": "调整任务优先级",
|
"isCommon": false,
|
"method": "POST",
|
"url": "/api/open/bus/priority",
|
"menu": {
|
"category": "任务管理",
|
"order": 5
|
}
|
}
|
];
|
|
// 生成任务管理菜单
|
const taskManagementMenu = document.getElementById('menu-task-management');
|
if (taskManagementMenu) {
|
taskManagementMenu.innerHTML = '';
|
apiConfigs.forEach(config => {
|
const li = document.createElement('li');
|
const a = document.createElement('a');
|
a.href = '#' + config.apiId;
|
a.className = 'submenu-link';
|
a.setAttribute('data-section', config.apiId);
|
a.setAttribute('onclick', 'navigateToSection(this); return false;');
|
a.textContent = config.name + (config.isCommon ? '*' : '');
|
li.appendChild(a);
|
taskManagementMenu.appendChild(li);
|
});
|
}
|
|
} catch (error) {
|
console.error('Failed to load API configs:', error);
|
}
|
}
|
|
// 页面加载完成后加载菜单
|
window.addEventListener('DOMContentLoaded', function() {
|
loadApiMenu();
|
});
|
</script>
|
</body>
|
</html>
|