diff --git a/Doc/XNSim仿真系统软件概要设计说明.docx b/Doc/XNSim仿真系统软件概要设计说明.docx new file mode 100755 index 0000000..89fe45b Binary files /dev/null and b/Doc/XNSim仿真系统软件概要设计说明.docx differ diff --git a/README.md b/README.md deleted file mode 100644 index 61f0373..0000000 --- a/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# XNSim - -XNSim code - -工具: -XNEditor——仿真配置终端 -XNIDLGen——IDL生成工具 -XNWrapper——模型封装工具 -XNRunner——仿真运行终端 -XNMonitor——模型分析、调试、监控工具 -XNPortal——XNSim门户程序 -XNSimHtml——XNSim综合管理页面 -XNSysMonitor——CPU占用监控工具 - -仿真核心: -XNCore——仿真内核 -XNEngine——仿真引擎 - -模型: -XNModels——仿真模型 - -服务: -XNServices——仿真服务 - -Other: -Doc——软件设计文档 -Login——XNSim综合管理页面登录管理 -qdarkstyle——工具软件界面所使用的UI风格 -Release——最终交付包 - diff --git a/Release/database/XNSim.db b/Release/database/XNSim.db index 592f8ed..c7afde6 100644 Binary files a/Release/database/XNSim.db and b/Release/database/XNSim.db differ diff --git a/XNSimPortal/README.md b/XNSimPortal/README.md deleted file mode 100644 index 0cba73a..0000000 --- a/XNSimPortal/README.md +++ /dev/null @@ -1,308 +0,0 @@ -# XNSim 门户网站 - -一个基于 Node.js 的现代化门户系统,集成了 C++ 动态库认证功能,专为 XNSim 项目设计。 - -## 📋 目录 - -- [功能特点](#功能特点) -- [系统架构](#系统架构) -- [环境要求](#环境要求) -- [快速开始](#快速开始) -- [API 文档](#api-文档) -- [权限管理](#权限管理) -- [技术栈](#技术栈) -- [常见问题](#常见问题) - -## ✨ 功能特点 - -### 🔐 认证系统 - -- 美观的响应式登录界面 -- 跨平台动态库支持(Windows/Linux) -- 基于权限级别的用户角色管理 -- 记住登录状态功能 - -### 🔧 接口配置管理 - -- 完整的 CRUD 操作支持 -- Excel 文件批量导入功能 -- 多维度筛选(构型、ATA 章节、结构体名等) -- 分页显示和批量操作 -- 数据验证和错误处理 - -### 📊 系统监控 - -- 实时数据监控 -- 系统日志管理 -- 用户行为追踪 -- 性能指标展示 - -## 🏗️ 系统架构 - -``` -XNSimPortal/ -├── assets/ # 静态资源文件 -├── components/ # 前端组件 -├── routes/ # API 路由 -├── utils/ # 工具函数 -├── server.js # 主服务器文件 -└── main.html # 主页面 -``` - -## 📋 环境要求 - -### 必需软件 - -- **Node.js**: 14.x 或更高版本 -- **SQLite**: 5.7 或更高版本 -- **操作系统**: Windows 10+ / Linux / macOS - -### 环境变量 - -必须设置 `XNCore` 环境变量,指向 XNSim 安装根目录: - -```bash -# Linux/macOS -export XNCore=/path/to/xncore/directory - -# Windows (CMD) -set XNCore=C:\path\to\xncore\directory - -# Windows (PowerShell) -$env:XNCore = "C:\path\to\xncore\directory" -``` - -### 动态库文件 - -确保在 `$XNCore/lib` 目录下存在相应动态库: - -| 操作系统 | 文件名 | 说明 | -| -------- | ------------- | ------------------ | -| Windows | `login.dll` | Windows 动态链接库 | -| Linux | `liblogin.so` | Linux 共享对象库 | - -## 🚀 快速开始 - -### 1. 克隆项目 - -```bash -git clone -cd XNSimPortal -``` - -### 2. 安装依赖 - -```bash -npm install -``` - -### 3. 配置数据库 - -创建 `.env` 文件并配置数据库连接: - -```env -DB_HOST=localhost -DB_USER=your_username -DB_PASSWORD=your_password -DB_NAME=xnsim_db -DB_PORT=3306 -``` - -### 4. 启动服务 - -```bash -npm start -``` - -### 5. 访问应用 - -打开浏览器访问:http://localhost:3000 - -## 📚 API 文档 - -### 认证 API - -#### 用户登录 - -```http -POST /api/login -Content-Type: application/json - -{ - "username": "string", - "password": "string", - "remember": boolean -} -``` - -**响应示例:** - -```json -{ - "success": true, - "message": "登录成功", - "permissionLevel": 3, - "role": "管理员" -} -``` - -### 接口配置 API - -#### 获取接口列表 - -```http -GET /api/interface/list?page=1&limit=10&filter=... -``` - -#### 添加接口 - -```http -POST /api/interface/add -Content-Type: application/json - -{ - "configuration": "string", - "ataChapter": "string", - "structName": "string", - "interfaceName": "string", - "dataType": "string", - "arraySize": "string", - "description": "string" -} -``` - -#### 更新接口 - -```http -PUT /api/interface/update -Content-Type: application/json - -{ - "currentData": {...}, - "originalData": {...} -} -``` - -#### 删除接口 - -```http -DELETE /api/interface/delete?id=123 -``` - -#### 导入接口配置 - -```http -POST /api/interface/import -Content-Type: application/json - -{ - "data": [...] -} -``` - -#### 下载导入模板 - -```http -GET /api/interface/template -``` - -## 🔐 权限管理 - -系统采用五级权限体系: - -| 级别 | 角色 | 权限描述 | -| ---- | ---------- | ---------------- | -| 0 | 访客 | 仅可查看公开信息 | -| 1 | 普通用户 | 基础功能访问权限 | -| 2 | 高级用户 | 扩展功能访问权限 | -| 3 | 管理员 | 系统管理权限 | -| 4 | 超级管理员 | 完全系统控制权限 | - -## 🛠️ 技术栈 - -### 前端 - -- **HTML5** - 语义化标记 -- **CSS3** - 样式和动画 -- **JavaScript ES6+** - 交互逻辑 -- **Web Components** - 组件化开发 - -### 后端 - -- **Node.js** - 运行时环境 -- **Express.js** - Web 框架 -- **MySQL** - 关系型数据库 - -### 核心库 - -- **ffi-napi** - C++ 动态库调用 -- **xlsx** - Excel 文件处理 -- **mysql2** - 数据库驱动 - -## ❓ 常见问题 - -### Q: 动态库加载失败怎么办? - -A: 请检查: - -1. `XNCore` 环境变量是否正确设置 -2. 动态库文件是否存在于 `$XNCore/lib` 目录 -3. 动态库是否包含 `Login_validateUser` 导出函数 - -### Q: 数据库连接失败? - -A: 请确认: - -1. MySQL 服务是否正在运行 -2. `.env` 文件中的数据库配置是否正确 -3. 数据库用户是否有足够权限 - -### Q: 接口配置导入失败? - -A: 请检查: - -1. Excel 文件格式是否符合模板要求 -2. 必填字段是否完整 -3. 数据格式是否符合验证规则 - -## 📝 开发规范 - -### 代码风格 - -- 使用 ES6+ 语法 -- 遵循 JavaScript 标准规范 -- 添加适当的注释和文档 - -### 数据验证 - -- 接口名称必须符合 C++ 命名规范 -- 数组大小必须大于 1 -- 必填字段不能为空 - -## 🔄 更新日志 - -### v0.31.0.250619_alpha (当前版本) - -- ✅ 基础登录认证功能 -- ✅ 接口配置管理 -- ✅ Excel 导入导出 -- ✅ 权限管理系统 - -### 计划功能 - -- 🔄 IDL 文件导入支持 -- 🔄 实时数据监控 -- 🔄 用户行为分析 -- 🔄 API 文档自动生成 - -## 📞 支持 - -如有问题或建议,请通过以下方式联系: - -- 提交 Issue -- 发送邮件至技术支持 -- 查看项目 Wiki - ---- - -**注意**: 本系统需要正确配置 C++ 动态库才能正常工作。确保动态库包含 `Login_validateUser` 函数,该函数接受用户名和密码参数,返回权限级别(负值表示失败)。 diff --git a/XNSimPortal/components/auth-component.js b/XNSimPortal/components/auth-component.js index 9b8e864..b2787fa 100644 --- a/XNSimPortal/components/auth-component.js +++ b/XNSimPortal/components/auth-component.js @@ -485,6 +485,7 @@ class AuthComponent extends HTMLElement { const password = this.shadowRoot.getElementById('loginPassword').value; if (!username || !password) { + console.error('A03032001: 请输入用户名和密码'); showToast('请输入用户名和密码'); return; } @@ -503,11 +504,13 @@ class AuthComponent extends HTMLElement { const confirmPassword = this.shadowRoot.getElementById('regConfirmPassword').value; if (!username || !password) { + console.error('A03032002: 用户名和密码为必填项'); showToast('用户名和密码为必填项'); return; } if (password !== confirmPassword) { + console.error('A03032003: 两次输入的密码不一致'); showToast('两次输入的密码不一致'); return; } diff --git a/XNSimPortal/components/configuration-config.js b/XNSimPortal/components/configuration-config.js index 3fcfeae..261d276 100644 --- a/XNSimPortal/components/configuration-config.js +++ b/XNSimPortal/components/configuration-config.js @@ -571,12 +571,12 @@ class ConfigurationConfig extends HTMLElement { try { const response = await fetch('/api/planes'); if (!response.ok) { - throw new Error('获取机型数据失败'); + throw new Error('B03042001: 获取机型数据失败'); } const planes = await response.json(); this.renderPlanes(planes); } catch (error) { - console.error('加载机型数据失败:', error); + console.error('获取机型数据失败:', error); this.showError('加载机型数据失败,请稍后重试'); } } @@ -590,7 +590,7 @@ class ConfigurationConfig extends HTMLElement { try { const response = await fetch(`/api/configurations?plane=${encodeURIComponent(planeName)}`); if (!response.ok) { - throw new Error('获取构型数据失败'); + throw new Error('B03042002: 获取构型数据失败'); } const configs = await response.json(); this.renderConfigurations(configs, planeName); @@ -805,7 +805,7 @@ class ConfigurationConfig extends HTMLElement { } } } catch (error) { - console.error('获取用户权限失败:', error); + console.error('B03042003: 获取用户权限失败:', error); } } @@ -912,7 +912,7 @@ class ConfigurationConfig extends HTMLElement { const responseData = await response.json(); if (!response.ok) { - throw new Error(responseData.error || '删除构型失败'); + throw new Error(responseData.error || 'B03042004: 删除构型失败'); } // 重新加载构型列表 @@ -1024,7 +1024,7 @@ class ConfigurationConfig extends HTMLElement { ]); if (!modelGroupsResponse.ok) { - throw new Error('获取模型组数据失败'); + throw new Error('B03042005: 获取模型组数据失败'); } const modelGroups = await modelGroupsResponse.json(); @@ -1036,12 +1036,12 @@ class ConfigurationConfig extends HTMLElement { try { const modelsResponse = await fetch(`/api/model-groups/${group.GroupID}/models`); if (!modelsResponse.ok) { - throw new Error(`获取模型组 ${group.GroupName} 的模型失败`); + throw new Error(`B03042006: 获取模型组 ${group.GroupName} 的模型失败`); } const models = await modelsResponse.json(); return { ...group, models }; } catch (error) { - console.error(`获取模型组 ${group.GroupName} 的模型失败:`, error); + console.error(error); return { ...group, models: [] }; } })); @@ -1107,7 +1107,7 @@ class ConfigurationConfig extends HTMLElement { }); if (!resp.ok) { const data = await resp.json(); - throw new Error(data.error || '删除失败'); + throw new Error(data.error || 'B03042007: 删除模型组失败'); } this.showEditor(this.selectedConfiguration, this.selectedPlane, false); } catch (err) { @@ -1130,7 +1130,7 @@ class ConfigurationConfig extends HTMLElement { }); if (!resp.ok) { const data = await resp.json(); - throw new Error(data.error || '删除失败'); + throw new Error(data.error || 'B03042008: 删除模型失败'); } this.showEditor(this.selectedConfiguration, this.selectedPlane, false); } catch (err) { @@ -1146,7 +1146,7 @@ class ConfigurationConfig extends HTMLElement { // 更新服务列表 const pendingServicesList = this.shadowRoot.getElementById('pendingServicesList'); if (!servicesResponse.ok) { - throw new Error('获取服务列表失败'); + throw new Error('B03042009: 获取服务列表失败'); } const services = await servicesResponse.json(); if (services && services.length > 0) { @@ -1176,7 +1176,7 @@ class ConfigurationConfig extends HTMLElement { }); if (!resp.ok) { const data = await resp.json(); - throw new Error(data.error || '删除失败'); + throw new Error(data.error || 'B03042010: 删除服务失败'); } this.showEditor(this.selectedConfiguration, this.selectedPlane, false); } catch (err) { @@ -1280,22 +1280,13 @@ class ConfigurationConfig extends HTMLElement { const responseData = await response.json(); if (!response.ok) { - if (responseData.error === '路径验证失败') { - const errorMessages = responseData.details.map(detail => - `${detail.path === 'workPath' ? '工作路径' : - detail.path === 'modelsPath' ? '模型路径' : '服务路径'}: ${detail.error}` - ).join('\n'); - alert(`路径验证失败:\n${errorMessages}`); - } else { - throw new Error(responseData.error || '保存构型失败'); - } - return; + throw new Error(responseData.error || 'B03042011: 保存构型失败'); } this.selectedConfiguration = responseData; this.showConfigurations(this.selectedPlane); } catch (error) { - console.error('保存构型失败:', error); + console.error(error); alert(error.message || '保存构型失败,请稍后重试'); } } @@ -1487,7 +1478,7 @@ class ConfigurationConfig extends HTMLElement { }); if (!resp.ok) { const data = await resp.json(); - throw new Error(data.error || '添加失败'); + throw new Error(data.error || 'B03042012: 添加模型失败'); } document.body.removeChild(dialog); this.showEditor(this.selectedConfiguration, this.selectedPlane, false); @@ -1601,7 +1592,7 @@ class ConfigurationConfig extends HTMLElement { }); if (!resp.ok) { const data = await resp.json(); - throw new Error(data.error || '保存失败'); + throw new Error(data.error || 'B03042013: 保存模型组失败'); } document.body.removeChild(dialog); this.showEditor(this.selectedConfiguration, this.selectedPlane, false); @@ -1767,7 +1758,7 @@ class ConfigurationConfig extends HTMLElement { }); if (!resp.ok) { const data = await resp.json(); - throw new Error(data.error || '添加失败'); + throw new Error(data.error || 'B03042014: 添加模型组失败'); } document.body.removeChild(dialog); this.showEditor(this.selectedConfiguration, this.selectedPlane, false); @@ -1874,7 +1865,7 @@ class ConfigurationConfig extends HTMLElement { try { const response = await fetch('/api/services'); - if (!response.ok) throw new Error('获取服务列表失败'); + if (!response.ok) throw new Error('B03042015: 获取服务列表失败'); serviceList = await response.json(); serviceSelect.innerHTML = '' + serviceList.map(service => ``).join(''); @@ -1896,7 +1887,7 @@ class ConfigurationConfig extends HTMLElement { try { const response = await fetch(`/api/service-versions/${className}`); - if (!response.ok) throw new Error('获取版本列表失败'); + if (!response.ok) throw new Error('B03042016: 获取版本列表失败'); const versions = await response.json(); versionSelect.innerHTML = '' + versions.map(version => ``).join(''); @@ -1940,7 +1931,7 @@ class ConfigurationConfig extends HTMLElement { if (!response.ok) { const data = await response.json(); - throw new Error(data.error || '添加服务失败'); + throw new Error(data.error || 'B03042017: 添加服务失败'); } document.body.removeChild(dialog); diff --git a/XNSimPortal/components/content-area.js b/XNSimPortal/components/content-area.js index d1fc394..46cc3ca 100644 --- a/XNSimPortal/components/content-area.js +++ b/XNSimPortal/components/content-area.js @@ -61,12 +61,12 @@ class ContentArea extends HTMLElement { try { cachedContent.reactivate(); } catch (err) { - console.error(`激活组件 ${id} 时出错:`, err); + console.error(`B03052001: 激活组件 ${id} 时出错:`, err); } }); } } catch (err) { - console.error(`从缓存加载组件 ${id} 时出错:`, err); + console.error(`B03052002: 从缓存加载组件 ${id} 时出错:`, err); // 缓存加载失败,清除缓存并创建新组件 this.clearCache(id); // 递归调用以创建新组件 diff --git a/XNSimPortal/components/data-collection.js b/XNSimPortal/components/data-collection.js index e5db94b..9438878 100644 --- a/XNSimPortal/components/data-collection.js +++ b/XNSimPortal/components/data-collection.js @@ -60,7 +60,7 @@ class DataCollection extends HTMLElement { try { const { configurationId } = this.getCurrentSelection(); if (!configurationId) { - console.warn('未找到配置ID'); + console.warn('B03062001: 未找到当前构型ID'); this.interfaces = []; return; } @@ -68,7 +68,7 @@ class DataCollection extends HTMLElement { const data = await response.json(); this.interfaces = data; } catch (error) { - console.error('加载接口数据失败:', error); + console.error('B03062002: 加载接口数据失败:', error); this.interfaces = []; } } @@ -88,7 +88,7 @@ class DataCollection extends HTMLElement { try { // 检查监控状态 const monitorRes = await fetch('/api/dds-monitor/status'); - if (!monitorRes.ok) throw new Error('网络错误'); + if (!monitorRes.ok) throw new Error('B03062003: 网络错误'); const monitorData = await monitorRes.json(); if (monitorData.isInitialized) { this.monitorStatus = 1; @@ -99,7 +99,7 @@ class DataCollection extends HTMLElement { // 如果正在采集中,检查采集状态 if (this.collectStatus === 2) { const collectRes = await fetch('/api/data-collect/status'); - if (!collectRes.ok) throw new Error('网络错误'); + if (!collectRes.ok) throw new Error('B03062004: 网络错误'); const collectData = await collectRes.json(); if (collectData.status === 0) { // 采集完成 // 模拟点击停止采集按钮 @@ -183,12 +183,12 @@ class DataCollection extends HTMLElement { }); if (!response.ok) { - throw new Error('删除文件失败'); + throw new Error('B03062005: 删除文件失败'); } const result = await response.json(); if (!result.success) { - throw new Error(result.message || '删除文件失败'); + throw new Error(result.message || 'B03062006: 删除文件失败'); } } @@ -243,7 +243,7 @@ class DataCollection extends HTMLElement { }); if (!response.ok) { - throw new Error('上传失败'); + throw new Error('B03062007: 上传失败'); } const result = await response.json(); @@ -380,7 +380,7 @@ class DataCollection extends HTMLElement { // 检查是否有错误 if (missingInterfaces.length > 0 || invalidInterfaces.length > 0) { - const errorMessages = []; + const errorMessages = ['A03063008: ']; if (missingInterfaces.length > 0) { errorMessages.push(`以下接口在系统中不存在:\n${missingInterfaces.join('\n')}`); } @@ -420,7 +420,7 @@ class DataCollection extends HTMLElement { // 重新渲染组件以显示采集列表 this.render(); } else { - throw new Error(result.message || '上传失败'); + throw new Error(result.message || 'B03062009: 上传失败'); } } catch (error) { console.error('上传文件失败:', error); @@ -881,23 +881,23 @@ class DataCollection extends HTMLElement { }); if (!response.ok) { - throw new Error(`读取文件失败: ${response.status} ${response.statusText}`); + throw new Error(`B03062010: 读取文件失败: ${response.status} ${response.statusText}`); } const result = await response.json(); if (!result.success) { - throw new Error(result.message || '读取文件失败'); + throw new Error(result.message || 'B03062011: 读取文件失败'); } // 解析CSV数据 const csvData = result.data; if (!csvData) { - throw new Error('CSV数据为空'); + throw new Error('A03062012: CSV数据为空'); } const lines = csvData.split('\n'); if (lines.length < 2) { - throw new Error('CSV文件格式错误:数据行数不足'); + throw new Error('A03062013: CSV文件格式错误:数据行数不足'); } // 获取接口名称(第一行)并解析数组索引 @@ -1034,7 +1034,7 @@ class DataCollection extends HTMLElement { // 存储采集数据 this.collectData = collectData; } catch (error) { - console.error('加载采集数据失败:', error); + console.error('B03062014: 加载采集数据失败:', error); alert('加载采集数据失败: ' + error.message); } this.render(); @@ -1042,7 +1042,7 @@ class DataCollection extends HTMLElement { throw new Error(result.message); } } catch (error) { - console.error('停止采集失败:', error); + console.error('B03062015: 停止采集失败:', error); alert('停止采集失败: ' + error.message); } return; @@ -1085,7 +1085,7 @@ class DataCollection extends HTMLElement { throw new Error(result.message); } } catch (error) { - console.error('启动采集失败:', error); + console.error('B03062016: 启动采集失败:', error); alert('启动采集失败: ' + error.message); } } @@ -1203,7 +1203,7 @@ class DataCollection extends HTMLElement { // 创建浮动窗口组件 const floatingWindow = document.createElement('floating-chart-window'); if (!floatingWindow) { - throw new Error('创建浮动窗口组件失败'); + throw new Error('B03062017: 创建浮动窗口组件失败'); } // 添加数据点计数器 @@ -1317,7 +1317,7 @@ class DataCollection extends HTMLElement { link.click(); document.body.removeChild(link); } catch (error) { - console.error('下载文件失败:', error); + console.error('B03062018: 下载文件失败:', error); alert('下载文件失败: ' + error.message); } } diff --git a/XNSimPortal/components/data-monitor.js b/XNSimPortal/components/data-monitor.js index b3a581c..8cd07e7 100644 --- a/XNSimPortal/components/data-monitor.js +++ b/XNSimPortal/components/data-monitor.js @@ -77,7 +77,7 @@ class DataMonitor extends HTMLElement { this.monitorStatus = 0; this.updateMonitorStatus(); } catch (error) { - console.error('初始化组件失败:', error); + console.error('B03072001: 初始化组件失败:', error); this.monitorStatus = 2; this.updateMonitorStatus(); } @@ -145,7 +145,7 @@ class DataMonitor extends HTMLElement { try { const { configurationId } = this.getCurrentSelection(); if (!configurationId) { - console.warn('未找到配置ID'); + console.warn('B03073002: 未找到配置ID'); return; } @@ -155,7 +155,7 @@ class DataMonitor extends HTMLElement { this.filteredInterfaces = this.filterInterfaces(this.searchText); this.render(); } catch (error) { - console.error('加载接口数据失败:', error); + console.error('B03073003: 加载接口数据失败:', error); } } @@ -417,7 +417,7 @@ class DataMonitor extends HTMLElement { if (this.csvState.isInjecting) { const csvStatusResponse = await fetch('/api/data-monitor/csv-inject-status'); if (!csvStatusResponse.ok) { - throw new Error(`获取CSV注入状态失败: ${csvStatusResponse.status} ${csvStatusResponse.statusText}`); + throw new Error(`B03072004: 获取CSV注入状态失败: ${csvStatusResponse.status} ${csvStatusResponse.statusText}`); } const csvStatusData = await csvStatusResponse.json(); // 如果状态为0,触发停止注入 @@ -433,7 +433,7 @@ class DataMonitor extends HTMLElement { // 检查DDS监控状态 const statusResponse = await fetch('/api/dds-monitor/status'); if (!statusResponse.ok) { - throw new Error(`获取DDS监控状态失败: ${statusResponse.status} ${statusResponse.statusText}`); + throw new Error(`B03072005: 获取DDS监控状态失败: ${statusResponse.status} ${statusResponse.statusText}`); } const statusData = await statusResponse.json(); @@ -474,7 +474,7 @@ class DataMonitor extends HTMLElement { }); if (!startResponse.ok) { - throw new Error(`启动数据监控失败: ${structName}`); + throw new Error(`B03072006: 启动数据监控失败: ${structName}`); } // 获取监控数据 @@ -484,17 +484,17 @@ class DataMonitor extends HTMLElement { const infoResponse = await fetch(`/api/data-monitor/info?structName=${encodeURIComponent(structName)}&interfaceName=${encodeURIComponent(interfaceNamesStr)}&bufferSize=${bufferSize}`); if (!infoResponse.ok) { - throw new Error(`获取监控数据失败: ${structName}`); + throw new Error(`B03072007: 获取监控数据失败: ${structName}`); } const responseData = await infoResponse.json(); if (!responseData.success) { - throw new Error(`获取监控数据失败: ${responseData.message || '未知错误'}`); + throw new Error(`B03072008: 获取监控数据失败: ${responseData.message || '未知错误'}`); } if (!responseData.data) { - throw new Error(`获取监控数据失败: 返回数据为空`); + throw new Error(`B03072009: 获取监控数据失败: 返回数据为空`); } // 合并数据 @@ -556,7 +556,7 @@ class DataMonitor extends HTMLElement { ) ); } catch (error) { - console.error('停止后端监控时发生错误:', error); + console.error('B03072010: 停止后端监控时发生错误:', error); } } @@ -594,7 +594,7 @@ class DataMonitor extends HTMLElement { } if (typeof Chart === 'undefined') { - console.log('Chart.js 未加载...'); + console.log('C03073011: Chart.js 未加载...'); } try { @@ -669,7 +669,7 @@ class DataMonitor extends HTMLElement { // 创建浮动窗口组件 const floatingWindow = document.createElement('floating-chart-window'); if (!floatingWindow) { - throw new Error('创建浮动窗口组件失败'); + throw new Error('B03072012: 创建浮动窗口组件失败'); } // 添加数据点计数器 @@ -716,7 +716,7 @@ class DataMonitor extends HTMLElement { floatingWindow.handleDataUpdate(values, interfaceName); } } catch (e) { - console.error('解析数据失败:', e); + console.error('B03072013: 解析数据失败:', e); } } }; @@ -736,7 +736,7 @@ class DataMonitor extends HTMLElement { this.chartWindows.delete(windowId); }); } catch (error) { - console.error('创建图表窗口失败:', error); + console.error('B03072014: 创建图表窗口失败:', error); alert('创建图表窗口失败,请查看控制台了解详情'); } } @@ -1599,7 +1599,7 @@ class DataMonitor extends HTMLElement { ); if (!row) { - console.error('未找到对应的行数据'); + console.error('B03072015: 未找到对应的行数据'); return; } @@ -1638,7 +1638,7 @@ class DataMonitor extends HTMLElement { throw new Error(result.message); } } catch (error) { - console.error('注入失败:', error); + console.error('B03072016: 注入失败:', error); alert(`注入失败: ${error.message}`); } } @@ -1677,7 +1677,7 @@ class DataMonitor extends HTMLElement { const modelStructName = continuousInjectButton.getAttribute('data-struct'); if (!interfaceName || !modelStructName) { - console.error('按钮缺少必要的数据属性'); + console.error('B03072017: 按钮缺少必要的数据属性'); return; } @@ -1687,7 +1687,7 @@ class DataMonitor extends HTMLElement { ); if (!row) { - console.error('未找到对应的行数据:', { interfaceName, modelStructName }); + console.error('B03072018: 未找到对应的行数据:', { interfaceName, modelStructName }); return; } @@ -1708,7 +1708,7 @@ class DataMonitor extends HTMLElement { const result = await response.json(); if (!result.success) { - throw new Error(result.message); + throw new Error('B03073002: ', result.message); } // 更新按钮和输入框状态 diff --git a/XNSimPortal/main.html b/XNSimPortal/main.html index 6adb12c..086551e 100644 --- a/XNSimPortal/main.html +++ b/XNSimPortal/main.html @@ -299,7 +299,7 @@ mainContainer.classList.remove('visible'); } else { // 定时检查发现未登录,显示提示并跳转到登录页面 - showToast('登录已过期,请重新登录'); + showToast('D03014001:登录已过期,请重新登录'); setTimeout(() => { authContainer.classList.add('visible'); mainContainer.classList.remove('visible'); @@ -307,7 +307,7 @@ } } } catch (error) { - console.error('认证检查错误:', error); + console.error('B03012002:认证检查错误:', error); // 只有在非定时检查时才显示登录界面 if (!isInterval) { authContainer.classList.add('visible'); @@ -427,7 +427,7 @@ method: 'POST', credentials: 'include' }).catch(error => { - console.error('登出错误:', error); + console.error('B03012003:登出错误:', error); showToast('登出过程中发生错误'); }); break; @@ -685,10 +685,11 @@ todoComponent.initialize(); } } else { + console.error('B03012004:登录失败:', result.message); showToast(result.message || '登录失败,请检查用户名和密码'); } } catch (error) { - console.error('登录错误:', error); + console.error('B03012005:登录错误:', error); showToast('登录过程中发生错误'); } }); @@ -713,10 +714,11 @@ const loginToggle = authComponent.shadowRoot.getElementById('loginToggle'); loginToggle.click(); } else { + console.error('B03012006:注册失败:', result.message); showToast(result.message || '注册失败,请稍后重试'); } } catch (error) { - console.error('注册错误:', error); + console.error('B03012007:注册错误:', error); showToast('注册过程中发生错误'); } }); diff --git a/XNSimPortal/server.js b/XNSimPortal/server.js index a103e6d..3b21e5e 100644 --- a/XNSimPortal/server.js +++ b/XNSimPortal/server.js @@ -37,7 +37,7 @@ const PORT = process.env.PORT || 3000; // 获取XNCore环境变量 const xnCorePath = process.env.XNCore || ''; if (!xnCorePath) { - console.error('警告: 环境变量XNCore未设置,可能无法找到登录动态库'); + console.error('A03022001: 环境变量XNCore未设置, 无法找到登录动态库'); } // 中间件 @@ -72,19 +72,17 @@ app.get('/', (req, res) => { // 监听进程退出事件 process.on('exit', performCleanup); process.on('SIGINT', () => { - console.log('收到 SIGINT 信号'); performCleanup(); process.exit(0); }); process.on('SIGTERM', () => { - console.log('收到 SIGTERM 信号'); performCleanup(); process.exit(0); }); // 处理未捕获的异常 process.on('uncaughtException', (error) => { - console.error('未捕获的异常:', error); + console.error('B03022002: 未捕获的异常:', error); performCleanup(); process.exit(1); }); @@ -120,5 +118,5 @@ app.get('/interface-config', (req, res) => { // 启动服务器 app.listen(PORT, () => { - console.log(`服务器运行在 http://localhost:${PORT}`); + console.log(`D03024003: 服务器运行在 http://localhost:${PORT}`); }); \ No newline at end of file