XNSim/XNSimHtml/components/help-component.js
2025-04-28 12:25:20 +08:00

350 lines
14 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class HelpComponent extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
this.setupEventListeners();
}
render() {
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
height: 100%;
overflow: auto;
padding: 16px;
box-sizing: border-box;
}
.help-container {
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
padding: 16px;
height: 100%;
box-sizing: border-box;
display: flex;
}
.help-sidebar {
width: 240px;
border-right: 1px solid #e0e0e0;
padding-right: 16px;
overflow-y: auto;
}
.help-content {
flex: 1;
padding-left: 24px;
overflow-y: auto;
}
.search-box {
display: flex;
margin-bottom: 16px;
position: relative;
}
.search-input {
width: 100%;
padding: 8px 12px;
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 14px;
outline: none;
transition: all 0.3s;
}
.search-input:focus {
border-color: #7986E7;
box-shadow: 0 0 0 2px rgba(121, 134, 231, 0.2);
}
.help-category {
margin-bottom: 16px;
}
.category-title {
font-size: 16px;
font-weight: bold;
color: #333;
margin-bottom: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
}
.category-title::after {
content: '';
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #666;
transition: transform 0.3s;
}
.category-title.expanded::after {
transform: rotate(180deg);
}
.help-items {
margin-left: 8px;
border-left: 2px solid #f0f0f0;
padding-left: 12px;
display: none;
}
.help-items.expanded {
display: block;
}
.help-item {
padding: 6px 0;
font-size: 14px;
color: #666;
cursor: pointer;
transition: color 0.3s;
}
.help-item:hover {
color: #7986E7;
}
.help-item.active {
color: #8B6DB3;
font-weight: 500;
}
.content-title {
font-size: 24px;
font-weight: bold;
color: #333;
margin-bottom: 16px;
padding-bottom: 8px;
border-bottom: 1px solid #e0e0e0;
}
.content-body {
font-size: 15px;
line-height: 1.6;
color: #333;
}
.content-section {
margin-bottom: 24px;
}
.section-title {
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 12px;
}
.section-content {
font-size: 15px;
line-height: 1.6;
color: #333;
}
.code-block {
background-color: #f5f5f5;
padding: 12px;
border-radius: 4px;
font-family: monospace;
overflow-x: auto;
margin: 12px 0;
}
.note {
background-color: #f0f7ff;
border-left: 4px solid #1890ff;
padding: 12px;
margin: 12px 0;
border-radius: 0 4px 4px 0;
}
.warning {
background-color: #fff7e6;
border-left: 4px solid #faad14;
padding: 12px;
margin: 12px 0;
border-radius: 0 4px 4px 0;
}
.help-footer {
margin-top: 24px;
padding-top: 16px;
border-top: 1px solid #e0e0e0;
display: flex;
justify-content: space-between;
color: #666;
font-size: 14px;
}
.feedback-link {
color: #7986E7;
text-decoration: none;
}
.feedback-link:hover {
text-decoration: underline;
}
</style>
<div class="help-container">
<div class="help-sidebar">
<div class="search-box">
<input type="text" class="search-input" placeholder="搜索帮助文档..." />
</div>
<div class="help-category">
<div class="category-title expanded">入门指南</div>
<div class="help-items expanded">
<div class="help-item active">系统概述</div>
<div class="help-item">快速开始</div>
<div class="help-item">基本概念</div>
<div class="help-item">用户界面</div>
</div>
</div>
<div class="help-category">
<div class="category-title">功能指南</div>
<div class="help-items">
<div class="help-item">创建模型</div>
<div class="help-item">运行仿真</div>
<div class="help-item">数据分析</div>
<div class="help-item">监控与调试</div>
<div class="help-item">参数配置</div>
</div>
</div>
<div class="help-category">
<div class="category-title">高级功能</div>
<div class="help-items">
<div class="help-item">API接口</div>
<div class="help-item">自定义扩展</div>
<div class="help-item">脚本编程</div>
<div class="help-item">性能优化</div>
</div>
</div>
<div class="help-category">
<div class="category-title">常见问题</div>
<div class="help-items">
<div class="help-item">账户与权限</div>
<div class="help-item">连接问题</div>
<div class="help-item">数据导入导出</div>
<div class="help-item">错误诊断</div>
</div>
</div>
</div>
<div class="help-content">
<div class="content-title">系统概述</div>
<div class="content-body">
<div class="content-section">
<div class="section-title">XNSim系统简介</div>
<div class="section-content">
XNSim是一个功能强大的仿真系统专为复杂网络仿真设计提供高性能、高可靠性的仿真环境。系统支持多种仿真模型可满足不同领域的仿真需求包括但不限于网络通信、交通系统、社交网络等。
<div class="note">
XNSim设计理念是简化复杂系统的仿真过程通过直观的用户界面和强大的后台引擎使用户能够专注于模型构建与结果分析而不是繁琐的技术细节。
</div>
</div>
</div>
<div class="content-section">
<div class="section-title">主要功能</div>
<div class="section-content">
<ul>
<li><strong>模型构建</strong>:提供直观的界面创建和编辑仿真模型</li>
<li><strong>参数配置</strong>:灵活设置仿真参数和环境变量</li>
<li><strong>运行控制</strong>:支持单次运行、批量运行和定时运行</li>
<li><strong>实时监控</strong>:监控仿真进程和关键指标</li>
<li><strong>数据收集</strong>:自动采集和存储仿真数据</li>
<li><strong>结果分析</strong>:提供多种可视化和分析工具</li>
<li><strong>API接口</strong>:支持与第三方系统集成</li>
</ul>
</div>
</div>
<div class="content-section">
<div class="section-title">系统架构</div>
<div class="section-content">
XNSim采用现代化的微服务架构由以下几个主要组件构成
<ul>
<li><strong>用户界面层</strong>提供Web界面支持用户交互</li>
<li><strong>业务逻辑层</strong>:处理用户请求,协调各个子系统</li>
<li><strong>仿真引擎</strong>:核心计算组件,执行仿真逻辑</li>
<li><strong>数据存储层</strong>:管理配置数据和仿真结果</li>
<li><strong>API网关</strong>:提供统一的对外接口</li>
</ul>
<div class="warning">
系统要求至少8GB内存和4核CPU才能获得最佳性能。对于大规模仿真建议使用16GB或更高配置。
</div>
</div>
</div>
</div>
<div class="help-footer">
<div>最后更新: 2023-10-15</div>
<a href="#" class="feedback-link">提交反馈</a>
</div>
</div>
</div>
`;
}
setupEventListeners() {
// 设置分类展开/折叠功能
const categoryTitles = this.shadowRoot.querySelectorAll('.category-title');
categoryTitles.forEach(title => {
title.addEventListener('click', () => {
title.classList.toggle('expanded');
const items = title.nextElementSibling;
items.classList.toggle('expanded');
});
});
// 设置帮助项点击事件
const helpItems = this.shadowRoot.querySelectorAll('.help-item');
helpItems.forEach(item => {
item.addEventListener('click', () => {
// 移除所有活动状态
helpItems.forEach(i => i.classList.remove('active'));
// 添加活动状态到当前项
item.classList.add('active');
// 加载对应的帮助内容(实际项目中应该调用加载内容的方法)
this.loadHelpContent(item.textContent);
});
});
// 设置搜索功能
const searchInput = this.shadowRoot.querySelector('.search-input');
searchInput.addEventListener('input', () => {
this.searchHelp(searchInput.value);
});
}
loadHelpContent(topic) {
console.log(`加载帮助内容: ${topic}`);
// 在此处添加实际加载帮助内容的逻辑
}
searchHelp(keyword) {
console.log(`搜索帮助: ${keyword}`);
// 在此处添加实际搜索帮助内容的逻辑
}
}
customElements.define('help-component', HelpComponent);