Compare commits

..
2 Commits
Author SHA1 Message Date
yi e9bff9beb3 Update 2026-06-23 10:40:10
Build and Push Docker Images / Build Backend Image (push) Has been cancelled
Build and Push Docker Images / Build Frontend Image (push) Has been cancelled
Build and Push Docker Images / Notify Build Complete (push) Has been cancelled
2026-06-23 10:40:10 +08:00
yi 864efb7f9d Update 2026-06-23 10:28:39
Build and Push Docker Images / Build Backend Image (push) Has been cancelled
Build and Push Docker Images / Build Frontend Image (push) Has been cancelled
Build and Push Docker Images / Notify Build Complete (push) Has been cancelled
2026-06-23 10:28:39 +08:00
56 changed files with 295 additions and 293 deletions
+4 -4
View File
@@ -4,10 +4,10 @@
# ============================================ # ============================================
# 后端镜像地址(从 ghcr.io 拉取公开镜像) # 后端镜像地址(从 ghcr.io 拉取公开镜像)
BACKEND_IMAGE=ghcr.io/gituib/idc-backend:latest BACKEND_IMAGE=ghcr.io/xinmi/yunrui_asset-backend:latest
# 前端镜像地址(从 ghcr.io 拉取公开镜像) # 前端镜像地址(从 ghcr.io 拉取公开镜像)
FRONTEND_IMAGE=ghcr.io/gituib/idc-frontend:latest FRONTEND_IMAGE=ghcr.io/xinmi/yunrui_asset-frontend:latest
# 指定特定版本(可选,默认 latest) # 指定特定版本(可选,默认 latest)
# BACKEND_VERSION=v1.0.0 # BACKEND_VERSION=v1.0.0
@@ -15,6 +15,6 @@ FRONTEND_IMAGE=ghcr.io/gituib/idc-frontend:latest
# ---- MySQL 容器配置(如启用本地 MySQL ---- # ---- MySQL 容器配置(如启用本地 MySQL ----
# MYSQL_ROOT_PASSWORD=your_root_password # MYSQL_ROOT_PASSWORD=your_root_password
# MYSQL_DATABASE=idc_management # MYSQL_DATABASE=yunrui_management
# MYSQL_USER=idc_user # MYSQL_USER=yunrui_user
# MYSQL_PASSWORD=your_mysql_password # MYSQL_PASSWORD=your_mysql_password
+2 -2
View File
@@ -17,8 +17,8 @@ on:
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
NAMESPACE: ${{ github.repository_owner }} NAMESPACE: ${{ github.repository_owner }}
BACKEND_IMAGE: idc-backend BACKEND_IMAGE: yunrui_asset-backend
FRONTEND_IMAGE: idc-frontend FRONTEND_IMAGE: yunrui_asset-frontend
jobs: jobs:
build-backend: build-backend:
+1 -1
View File
@@ -120,4 +120,4 @@ docs/install-split-plan.md
# ============================================== # ==============================================
deploy/nginx-troubleshooting.md deploy/nginx-troubleshooting.md
docs/trae-creativity-contest-proposal.html docs/trae-creativity-contest-proposal.html
TRAE-创意提案-IDC设备资产管理系统.html TRAE-创意提案-云睿资产管理系统.html
+3 -3
View File
@@ -8,10 +8,10 @@
- **完成时间** - **完成时间**
- **项目信息** - **项目信息**
- 项目名称:云睿资产 - 项目名称:云睿资产
- 项目目录:C:\Users\L1822\xinmi\idc_assest - 项目目录:C:\Users\L1822\xinmi\yunrui_assetet
- Git 地址:https://github.com/gituib/idc_assest - Git 地址:https://code.xinmi.cloud/yyunrui_assett
- 端口范围:12000-12010 - 端口范围:12000-12010
- 状态文档:C:\Users\L1822\xinmi\idc_assest\.work\工作流状态.md - 状态文档:C:\Users\L1822\xinmi\yunrui_assetet\.work\工作流状态.md
## 步骤执行记录 ## 步骤执行记录
+2 -2
View File
@@ -1,7 +1,7 @@
《项目整体分析报告》 《项目整体分析报告》
## 核心功能 ## 核心功能
本项目是一个 IDC 设备管理系统,主要提供机房、机柜、设备、端口、线缆等资产的精细化管理功能,支持工单系统、耗材管理、盘点任务以及 3D 可视化展示。 本项目是一个 云睿资产管理系统,主要提供机房、机柜、设备、端口、线缆等资产的精细化管理功能,支持工单系统、耗材管理、盘点任务以及 3D 可视化展示。
## 技术栈 ## 技术栈
- 编程语言:JavaScript (Node.js v20+) - 编程语言:JavaScript (Node.js v20+)
@@ -16,7 +16,7 @@
- 前端服务 (Frontend):端口 3000,负责用户界面交互及 3D 模型展示。 - 前端服务 (Frontend):端口 3000,负责用户界面交互及 3D 模型展示。
### 外部依赖 ### 外部依赖
- 数据库 (SQLite):本地文件 `idc_management.db` - 数据库 (SQLite):本地文件 `yunrui_management.db`
- 数据库 (MySQL):可选,外部连接。 - 数据库 (MySQL):可选,外部连接。
## 服务依赖关系 ## 服务依赖关系
+1 -1
View File
@@ -2,7 +2,7 @@
## Project Overview ## Project Overview
IDC Device Asset Management System — full-stack app for data center device lifecycle management with 3D visualization. Monorepo: `backend/` (Express + Sequelize), `frontend/` (React + Vite + Ant Design + Three.js). YunRui Asset Management System — full-stack app for data center device lifecycle management with 3D visualization. Monorepo: `backend/` (Express + Sequelize), `frontend/` (React + Vite + Ant Design + Three.js).
## 交互规则 ## 交互规则
+23 -23
View File
@@ -1,6 +1,6 @@
# IDC设备资产系统 - Code Wiki # 云睿资产系统 - Code Wiki
> 版本:2.0.0 | 更新日期:2026-05-07 | 项目地址:[GitHub](https://github.com/gituib/idc_assest) > 版本:2.0.0 | 更新日期:2026-05-07 | 项目地址:[源码仓库](https://code.xinmi.cloud/yunyunrui_asset
--- ---
@@ -24,7 +24,7 @@
### 1.1 项目简介 ### 1.1 项目简介
IDC设备资产系统(IDC Device Management System)是一个现代化的数据中心设备全生命周期管理平台,提供机房、机柜、设备的完整管理能力,并具备3D可视化展示功能。 云睿资产系统(YunRui Asset Management System)是一个现代化的数据中心设备全生命周期管理平台,提供机房、机柜、设备的完整管理能力,并具备3D可视化展示功能。
### 1.2 技术栈概览 ### 1.2 技术栈概览
@@ -118,7 +118,7 @@ IDC设备资产系统(IDC Device Management System)是一个现代化的数
│ ┌─────────────────┐ ┌─────────────────┐ │ │ ┌─────────────────┐ ┌─────────────────┐ │
│ │ SQLite │ │ MySQL │ │ │ │ SQLite │ │ MySQL │ │
│ │ (开发环境) │◄────────────────►│ (生产环境) │ │ │ │ (开发环境) │◄────────────────►│ (生产环境) │ │
│ │ idc_management.db│ │ MySQL 8.0+ │ │ │ │ yunrui_management.db│ │ MySQL 8.0+ │ │
│ └─────────────────┘ └─────────────────┘ │ │ └─────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘ └─────────────────────────────────────────────────────────────────────────┘
``` ```
@@ -592,7 +592,7 @@ if (DB_TYPE === 'mysql') {
} else { } else {
sequelize = new Sequelize({ sequelize = new Sequelize({
dialect: 'sqlite', dialect: 'sqlite',
storage: process.env.DB_PATH || './idc_management.db' storage: process.env.DB_PATH || './yunrui_management.db'
}); });
} }
``` ```
@@ -1235,7 +1235,7 @@ const backupDatabase = async (options = {}) => {
const filepath = path.join(BACKUP_DIR, filename); const filepath = path.join(BACKUP_DIR, filename);
await fs.copy( await fs.copy(
process.env.DB_PATH || './idc_management.db', process.env.DB_PATH || './yunrui_management.db',
filepath filepath
); );
@@ -1493,7 +1493,7 @@ router.post('/import-preview', upload.single('csvFile'), async (req, res) => {
```bash ```bash
# 前端环境配置 # 前端环境配置
VITE_API_BASE_URL=http://localhost:8000/api VITE_API_BASE_URL=http://localhost:8000/api
VITE_APP_TITLE=IDC设备管理系统 VITE_APP_TITLE=云睿资产管理系统
VITE_APP_VERSION=2.0.0 VITE_APP_VERSION=2.0.0
``` ```
@@ -1506,12 +1506,12 @@ PORT=8000
# 数据库配置 # 数据库配置
DB_TYPE=sqlite # sqlite 或 mysql DB_TYPE=sqlite # sqlite 或 mysql
DB_PATH=./idc_management.db # SQLite数据库路径 DB_PATH=./yunrui_management.db # SQLite数据库路径
# MySQL配置 (当DB_TYPE=mysql时) # MySQL配置 (当DB_TYPE=mysql时)
MYSQL_HOST=localhost MYSQL_HOST=localhost
MYSQL_PORT=3306 MYSQL_PORT=3306
MYSQL_DATABASE=idc_management MYSQL_DATABASE=yunrui_management
MYSQL_USERNAME=root MYSQL_USERNAME=root
MYSQL_PASSWORD=your_password MYSQL_PASSWORD=your_password
@@ -1573,11 +1573,11 @@ npm run build
# 2. 使用PM2启动后端 # 2. 使用PM2启动后端
cd ../backend cd ../backend
pm2 start server.js --name idc-backend pm2 start server.js --name yunrui_asset-backend
# 3. 使用Nginx反向代理 # 3. 使用Nginx反向代理
# 或使用PM2 serve提供静态文件 # 或使用PM2 serve提供静态文件
pm2 serve ./frontend/dist 3000 --name idc-frontend pm2 serve ./frontend/dist 3000 --name yunrui_asset-frontend
``` ```
--- ---
@@ -1596,23 +1596,23 @@ sudo apt install mysql-server
# 2. 创建数据库 # 2. 创建数据库
mysql -u root -p mysql -u root -p
CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'idc_user'@'localhost' IDENTIFIED BY 'your_password'; CREATE USER 'yunrui_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON idc_management.* TO 'idc_user'@'localhost'; GRANT ALL PRIVILEGES ON yunrui_management.* TO 'yunrui_user'@'localhost';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
``` ```
#### 10.1.2 Nginx配置 #### 10.1.2 Nginx配置
```nginx ```nginx
# /etc/nginx/sites-available/idc # /etc/nginx/sites-available/yunrui_asset
server { server {
listen 80; listen 80;
server_name your_domain.com; server_name your_domain.com;
# 前端静态文件 # 前端静态文件
root /var/www/idc/frontend/dist; root /var/www/yunrui_asset/frontend/dist;
index index.html; index index.html;
# Gzip压缩 # Gzip压缩
@@ -1636,7 +1636,7 @@ server {
# 上传文件 # 上传文件
location /uploads { location /uploads {
alias /var/www/idc/backend/uploads; alias /var/www/yunrui_asset/backend/uploads;
autoindex on; autoindex on;
} }
@@ -1666,12 +1666,12 @@ npm install -g pm2
# 启动后端服务 # 启动后端服务
cd backend cd backend
pm2 start server.js --name idc-backend \ pm2 start server.js --name yunrui_asset-backend \
--env production \ --env production \
--max-memory-restart 1G --max-memory-restart 1G
# 配置负载均衡 (多核CPU) # 配置负载均衡 (多核CPU)
pm2 start server.js -i max --name idc-backend pm2 start server.js -i max --name yunrui_asset-backend
# 保存进程列表 # 保存进程列表
pm2 save pm2 save
@@ -1723,7 +1723,7 @@ services:
db: db:
image: mysql:8.0 image: mysql:8.0
environment: environment:
MYSQL_DATABASE: idc_management MYSQL_DATABASE: yunrui_management
MYSQL_ROOT_PASSWORD: root_password MYSQL_ROOT_PASSWORD: root_password
volumes: volumes:
- mysql_data:/var/lib/mysql - mysql_data:/var/lib/mysql
@@ -1819,7 +1819,7 @@ volumes:
│ ┌─────────────────────────────┐ ┌─────────────────────────────┐ │ │ ┌─────────────────────────────┐ ┌─────────────────────────────┐ │
│ │ SQLite │ │ MySQL │ │ │ │ SQLite │ │ MySQL │ │
│ │ (开发环境) │◄──►│ (生产环境) │ │ │ │ (开发环境) │◄──►│ (生产环境) │ │
│ │ idc_management.db │ │ MySQL 8.0+ │ │ │ │ yunrui_management.db │ │ MySQL 8.0+ │ │
│ └─────────────────────────────┘ └─────────────────────────────┘ │ │ └─────────────────────────────┘ └─────────────────────────────┘ │
│ │ │ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │ │ ┌─────────────────────────────────────────────────────────────────────────┐ │
@@ -2160,7 +2160,7 @@ volumes:
│ │ │ filename: "backup_20260507_120000.sql", │ │ │ │ │ │ filename: "backup_20260507_120000.sql", │ │ │
│ │ │ size: 1048576, │ │ │ │ │ │ size: 1048576, │ │ │
│ │ │ createdAt: "2026-05-07T12:00:00Z", │ │ │ │ │ │ createdAt: "2026-05-07T12:00:00Z", │ │ │
│ │ │ database: "idc_management", │ │ │ │ │ │ database: "yunrui_management", │ │ │
│ │ │ tables: ["devices", "racks", "tickets", ...], │ │ │ │ │ │ tables: ["devices", "racks", "tickets", ...], │ │ │
│ │ │ status: "completed" │ │ │ │ │ │ status: "completed" │ │ │
│ │ │ } │ │ │ │ │ │ } │ │ │
@@ -2200,7 +2200,7 @@ volumes:
│ │ mysql -u user -p dbname < backup_xxx.sql │ │ │ │ mysql -u user -p dbname < backup_xxx.sql │ │
│ │ │ │ │ │ │ │
│ │ SQLite: │ │ │ │ SQLite: │ │
│ │ cp backup_xxx.db idc_management.db │ │ │ │ cp backup_xxx.db yunrui_management.db │ │
│ │ │ │ │ │ │ │
│ └──────────────────────────┬───────────────────────────────────────┘ │ │ └──────────────────────────┬───────────────────────────────────────┘ │
│ │ │ │ │ │
+32 -29
View File
@@ -1,6 +1,6 @@
# IDC 设备资产管理系统 # 云睿资产管理系统
**维护团队**IDC 设备资产管理开源社区 **维护团队**云睿资产开源社区
**版本**2.1.1 | **更新**2026-06-22 **版本**2.1.1 | **更新**2026-06-22
面向数据中心(IDC)运维与资产管理场景,提供机房、机柜、设备全生命周期管理,支持 3D 可视化、工单流转、耗材库存、资产盘点与 RBAC 权限控制。 面向数据中心(IDC)运维与资产管理场景,提供机房、机柜、设备全生命周期管理,支持 3D 可视化、工单流转、耗材库存、资产盘点与 RBAC 权限控制。
@@ -42,8 +42,8 @@
```bash ```bash
# 克隆项目 # 克隆项目
git clone https://github.com/gituib/idc_assest.git git clone https://code.xinmi.cloud/yunrui_asset.git
cd idc_assest cd yunrui_asset
# 配置 JWT 密钥(生产环境必填) # 配置 JWT 密钥(生产环境必填)
# PowerShell 生成示例: # PowerShell 生成示例:
@@ -54,7 +54,7 @@ set JWT_SECRET=你的强随机密钥
docker compose -f docker-compose.full.yml up -d --build docker compose -f docker-compose.full.yml up -d --build
# 写入示例数据(可选,含演示账号与机房/设备/工单) # 写入示例数据(可选,含演示账号与机房/设备/工单)
docker exec idc_assest-backend node scripts/seed-example-data.js docker exec yunrui_asset-backend node scripts/seed-example-data.js
``` ```
| 服务 | 默认地址 | 说明 | | 服务 | 默认地址 | 说明 |
@@ -63,7 +63,7 @@ docker exec idc_assest-backend node scripts/seed-example-data.js
| 后端 API | http://localhost:12001 | 容器内端口 8000 | | 后端 API | http://localhost:12001 | 容器内端口 8000 |
| API 文档 | http://localhost:12000/api-docs | Swagger 交互文档 | | API 文档 | http://localhost:12000/api-docs | Swagger 交互文档 |
| 健康检查 | http://localhost:12001/health | 后端存活探测 | | 健康检查 | http://localhost:12001/health | 后端存活探测 |
| MySQL | localhost:12006 | 库名 `idc_management` | | MySQL | localhost:12006 | 库名 `yunrui_management` |
| 角色 | 用户名 | 密码 | 获取方式 | | 角色 | 用户名 | 密码 | 获取方式 |
|------|--------|------|----------| |------|--------|------|----------|
@@ -75,15 +75,15 @@ docker exec idc_assest-backend node scripts/seed-example-data.js
**Docker 预构建镜像**`docker-compose.prod.yml`,从仓库拉取,无需本地 build): **Docker 预构建镜像**`docker-compose.prod.yml`,从仓库拉取,无需本地 build):
``` ```
ghcr.io/gituib/idc-backend:latest ghcr.io/xinmi/yunrui_asset-backend:latest
ghcr.io/gituib/idc-frontend:latest ghcr.io/xinmi/yunrui_asset-frontend:latest
``` ```
### 方式二:本地开发 ### 方式二:本地开发
```bash ```bash
git clone https://github.com/gituib/idc_assest.git git clone https://code.xinmi.cloud/yunrui_asset.git
cd idc_assest cd yunrui_asset
npm run install:all npm run install:all
cp backend/.env.example backend/.env cp backend/.env.example backend/.env
cd backend && node scripts/init-database.js && cd .. cd backend && node scripts/init-database.js && cd ..
@@ -99,7 +99,7 @@ npm start
### 项目结构 ### 项目结构
``` ```
idc_assest/ yunrui_asset/
├── frontend/ # React 前端(Vite ├── frontend/ # React 前端(Vite
├── backend/ # Express 后端(models / routes / scripts ├── backend/ # Express 后端(models / routes / scripts
├── deploy/ # PM2、Nginx 部署配置 ├── deploy/ # PM2、Nginx 部署配置
@@ -110,6 +110,8 @@ idc_assest/
└── README.md # 本操作手册(权威文档) └── README.md # 本操作手册(权威文档)
``` ```
**源码地址**https://code.xinmi.cloud/yunrui_asset
--- ---
## 操作手册 ## 操作手册
@@ -118,7 +120,7 @@ idc_assest/
#### 1.1 产品简介 #### 1.1 产品简介
IDC 设备资产管理系统(界面品牌名:**云睿资产**)用于统一管理多机房、多机柜下的服务器、网络、存储等设备,覆盖设备上架、端口接线、故障工单、耗材出入库、资产盘点、数据备份与操作审计等场景,并通过 3D 机柜视图与机房平面图辅助空间规划。 云睿资产管理系统(界面品牌名:**云睿资产**)用于统一管理多机房、多机柜下的服务器、网络、存储等设备,覆盖设备上架、端口接线、故障工单、耗材出入库、资产盘点、数据备份与操作审计等场景,并通过 3D 机柜视图与机房平面图辅助空间规划。
#### 1.2 核心能力 #### 1.2 核心能力
@@ -198,7 +200,7 @@ docker compose -f docker-compose.full.yml up -d --build
docker compose -f docker-compose.full.yml ps docker compose -f docker-compose.full.yml ps
# 查看后端日志 # 查看后端日志
docker logs -f idc_assest-backend docker logs -f yunrui_asset-backend
# 停止 # 停止
docker compose -f docker-compose.full.yml down docker compose -f docker-compose.full.yml down
@@ -211,11 +213,11 @@ docker compose -f docker-compose.full.yml down
| `FRONTEND_PORT` | `12000` | 前端映射端口 | | `FRONTEND_PORT` | `12000` | 前端映射端口 |
| `BACKEND_PORT` | `12001` | 后端映射端口 | | `BACKEND_PORT` | `12001` | 后端映射端口 |
| `MYSQL_PORT` | `12006` | MySQL 映射端口 | | `MYSQL_PORT` | `12006` | MySQL 映射端口 |
| `MYSQL_DATABASE` | `idc_management` | 数据库名 | | `MYSQL_DATABASE` | `yunrui_management` | 数据库名 |
| `MYSQL_ROOT_PASSWORD` | `xinmi_password` | MySQL root 密码 | | `MYSQL_ROOT_PASSWORD` | `xinmi_password` | MySQL root 密码 |
| `JWT_SECRET` | (无默认) | **生产必填** | | `JWT_SECRET` | (无默认) | **生产必填** |
数据持久化:MySQL 数据卷 `idc_assest-mysql-data`;上传文件映射 `backend/uploads`;日志映射 `backend/logs`;备份映射 `backend/backups` 数据持久化:MySQL 数据卷 `yunrui_asset-mysql-data`;上传文件映射 `backend/uploads`;日志映射 `backend/logs`;备份映射 `backend/backups`
#### 3.2 Docker 预构建镜像(`docker-compose.prod.yml` #### 3.2 Docker 预构建镜像(`docker-compose.prod.yml`
@@ -232,10 +234,10 @@ docker compose -f docker-compose.prod.yml up -d
#### 3.3 Linux 一键安装 #### 3.3 Linux 一键安装
```bash ```bash
git clone https://gitee.com/zhang96110/idc_assest.git git clone https://code.xinmi.cloud/yunrui_asset.git
cd idc_assest cd yunrui_asset
./install.sh ./install.sh
# 或远程一键:curl -fsSL https://gitee.com/zhang96110/idc_assest/raw/main/install.sh | bash # 或远程一键:curl -fsSL https://code.xinmi.cloud/yunrui_asset/raw/branch/main/install.sh | bash
``` ```
`install.sh` 自动检测发行版、安装 Node.js 20.x,并调用 `install.js` 完成依赖安装、数据库初始化与 Nginx/PM2 配置。 `install.sh` 自动检测发行版、安装 Node.js 20.x,并调用 `install.js` 完成依赖安装、数据库初始化与 Nginx/PM2 配置。
@@ -243,8 +245,8 @@ cd idc_assest
#### 3.4 Windows / 手动安装 #### 3.4 Windows / 手动安装
```powershell ```powershell
git clone https://gitee.com/zhang96110/idc_assest.git git clone https://code.xinmi.cloud/yunrui_asset.git
cd idc_assest cd yunrui_asset
node install.js node install.js
# 或:npm run deploy # 或:npm run deploy
``` ```
@@ -313,7 +315,7 @@ node uninstall.js # 交互式卸载
```bash ```bash
# Docker 环境 # Docker 环境
docker exec idc_assest-backend node scripts/seed-example-data.js docker exec yunrui_asset-backend node scripts/seed-example-data.js
# 本地开发(backend 目录,需配置数据库连接) # 本地开发(backend 目录,需配置数据库连接)
cd backend && npm run seed cd backend && npm run seed
@@ -570,8 +572,8 @@ curl http://localhost:12000/health
| 环境 | 命令 | | 环境 | 命令 |
|------|------| |------|------|
| Docker | `docker logs -f idc_assest-backend` | | Docker | `docker logs -f yunrui_asset-backend` |
| PM2 | `pm2 logs idc-backend` | | PM2 | `pm2 logs yunrui_asset-backend` |
| 文件 | `tail -f backend/logs/*.log` | | 文件 | `tail -f backend/logs/*.log` |
日志级别通过 `backend/.env``LOG_LEVEL` 控制(`error` / `warn` / `info` / `debug`)。 日志级别通过 `backend/.env``LOG_LEVEL` 控制(`error` / `warn` / `info` / `debug`)。
@@ -583,7 +585,7 @@ curl http://localhost:12000/health
docker compose -f docker-compose.full.yml restart backend frontend docker compose -f docker-compose.full.yml restart backend frontend
# PM2 # PM2
pm2 restart idc-backend pm2 restart yunrui_asset-backend
sudo nginx -s reload sudo nginx -s reload
``` ```
@@ -622,7 +624,7 @@ cd backend && npm run seed
| 现象 | 可能原因 | 处理 | | 现象 | 可能原因 | 处理 |
|------|----------|------| |------|----------|------|
| backend 启动失败 | MySQL 未就绪或 `JWT_SECRET` 未设 | 等待 MySQL;设置 `JWT_SECRET` 后重启 | | backend 启动失败 | MySQL 未就绪或 `JWT_SECRET` 未设 | 等待 MySQL;设置 `JWT_SECRET` 后重启 |
| 502 / API 无响应 | 后端容器异常 | `docker logs idc_assest-backend` | | 502 / API 无响应 | 后端容器异常 | `docker logs yunrui_asset-backend` |
| 中文乱码 | MySQL 字符集 | 确保库为 `utf8mb4` | | 中文乱码 | MySQL 字符集 | 确保库为 `utf8mb4` |
#### 10.3 本地开发 #### 10.3 本地开发
@@ -640,7 +642,7 @@ cd backend && npm run seed
| U 位冲突 | 同一机柜 U 位已被占用 | 调整设备起始 U 位或高度 | | U 位冲突 | 同一机柜 U 位已被占用 | 调整设备起始 U 位或高度 |
| 3D 页面空白 | 浏览器不支持 WebGL | 更换浏览器或更新显卡驱动 | | 3D 页面空白 | 浏览器不支持 WebGL | 更换浏览器或更新显卡驱动 |
| 上传失败 | 文件超过大小限制 | 默认最大 30 MB(`MAX_FILE_SIZE_MB` | | 上传失败 | 文件超过大小限制 | 默认最大 30 MB(`MAX_FILE_SIZE_MB` |
| 无示例数据 | 未执行种子脚本 | `docker exec idc_assest-backend node scripts/seed-example-data.js` | | 无示例数据 | 未执行种子脚本 | `docker exec yunrui_asset-backend node scripts/seed-example-data.js` |
--- ---
@@ -653,10 +655,10 @@ cd backend && npm run seed
| `PORT` | `8000` | 后端监听端口 | | `PORT` | `8000` | 后端监听端口 |
| `NODE_ENV` | `development` | 运行环境 | | `NODE_ENV` | `development` | 运行环境 |
| `DB_TYPE` | `sqlite` | `sqlite``mysql` | | `DB_TYPE` | `sqlite` | `sqlite``mysql` |
| `DB_PATH` | `./idc_management.db` | SQLite 文件路径 | | `DB_PATH` | `./yunrui_management.db` | SQLite 文件路径 |
| `MYSQL_HOST` | `localhost` | MySQL 主机(Docker 内为 `mysql` | | `MYSQL_HOST` | `localhost` | MySQL 主机(Docker 内为 `mysql` |
| `MYSQL_PORT` | `3306` | MySQL 端口 | | `MYSQL_PORT` | `3306` | MySQL 端口 |
| `MYSQL_DATABASE` | `idc_management` | 数据库名 | | `MYSQL_DATABASE` | `yunrui_management` | 数据库名 |
| `MYSQL_USERNAME` | `root` | 数据库用户 | | `MYSQL_USERNAME` | `root` | 数据库用户 |
| `MYSQL_PASSWORD` | (空) | 数据库密码 | | `MYSQL_PASSWORD` | (空) | 数据库密码 |
| `JWT_SECRET` | 开发自动生成 | **生产必填** | | `JWT_SECRET` | 开发自动生成 | **生产必填** |
@@ -684,6 +686,7 @@ cd backend && npm run seed
| API 详细文档 | [docs/api/README.md](docs/api/README.md) | | API 详细文档 | [docs/api/README.md](docs/api/README.md) |
| Docker 部署补充 | [docs/docker-deployment-guide.md](docs/docker-deployment-guide.md) | | Docker 部署补充 | [docs/docker-deployment-guide.md](docs/docker-deployment-guide.md) |
| 用户指南(历史) | [docs/USER_GUIDE.md](docs/USER_GUIDE.md) | | 用户指南(历史) | [docs/USER_GUIDE.md](docs/USER_GUIDE.md) |
| 问题反馈 | https://code.xinmi.cloud/yunrui_asset/issues |
--- ---
@@ -715,5 +718,5 @@ git push origin feature/your-feature
--- ---
**IDC 设备资产管理开源社区** **云睿资产开源社区**
文档版本:2.1.1 | 2026-06-22 文档版本:2.1.1 | 2026-06-22
+4 -4
View File
@@ -1,4 +1,4 @@
# IDC设备管理系统 - 环境配置 # 云睿资产管理系统 - 环境配置
# 生成时间: 2026-02-26T05:07:19.876Z # 生成时间: 2026-02-26T05:07:19.876Z
# ============================================== # ==============================================
@@ -19,16 +19,16 @@ NODE_ENV=development
DB_TYPE=sqlite DB_TYPE=sqlite
# SQLite 配置(当 DB_TYPE=sqlite 时使用) # SQLite 配置(当 DB_TYPE=sqlite 时使用)
DB_PATH=./idc_management.db DB_PATH=./yunrui_management.db
# MySQL 配置(当 DB_TYPE=mysql 时使用) # MySQL 配置(当 DB_TYPE=mysql 时使用)
# 注意:使用 MySQL 前请确保 MySQL 服务已安装并创建相应的数据库 # 注意:使用 MySQL 前请确保 MySQL 服务已安装并创建相应的数据库
# 数据库创建命令:CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; # 数据库创建命令:CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
MYSQL_HOST=localhost MYSQL_HOST=localhost
MYSQL_PORT=3306 MYSQL_PORT=3306
MYSQL_USERNAME=root MYSQL_USERNAME=root
MYSQL_PASSWORD= MYSQL_PASSWORD=
MYSQL_DATABASE=idc_management MYSQL_DATABASE=yunrui_management
# ============================================== # ==============================================
# 安全配置 # 安全配置
+1 -1
View File
@@ -1,5 +1,5 @@
# ============================================ # ============================================
# IDC 设备管理系统 - 后端 Dockerfile # 云睿资产管理系统 - 后端 Dockerfile
# 基于 Node.js 20 Alpine 构建 # 基于 Node.js 20 Alpine 构建
# ============================================ # ============================================
+2 -2
View File
@@ -17,7 +17,7 @@ const sqlLogger = (msg) => logger.debug(msg);
if (DB_TYPE === 'mysql') { if (DB_TYPE === 'mysql') {
// MySQL 配置 // MySQL 配置
sequelize = new Sequelize( sequelize = new Sequelize(
process.env.MYSQL_DATABASE || 'idc_management', process.env.MYSQL_DATABASE || 'yunrui_management',
process.env.MYSQL_USERNAME || 'root', process.env.MYSQL_USERNAME || 'root',
process.env.MYSQL_PASSWORD || '', process.env.MYSQL_PASSWORD || '',
{ {
@@ -38,7 +38,7 @@ if (DB_TYPE === 'mysql') {
} else { } else {
sequelize = new Sequelize({ sequelize = new Sequelize({
dialect: 'sqlite', dialect: 'sqlite',
storage: process.env.DB_PATH || './idc_management.db', storage: process.env.DB_PATH || './yunrui_management.db',
logging: sqlLogger, logging: sqlLogger,
pool: { pool: {
max: 5, max: 5,
+1 -1
View File
@@ -84,7 +84,7 @@ function ensureJwtSecret() {
fs.writeFileSync(ENV_FILE_PATH, updatedContent, 'utf-8'); fs.writeFileSync(ENV_FILE_PATH, updatedContent, 'utf-8');
console.log('✓ JWT_SECRET 已自动生成并保存到 .env 文件'); console.log('✓ JWT_SECRET 已自动生成并保存到 .env 文件');
} else { } else {
const defaultContent = `# IDC设备管理系统 - 环境配置 const defaultContent = `# 云睿资产管理系统 - 环境配置
# 自动生成时间: ${new Date().toISOString()} # 自动生成时间: ${new Date().toISOString()}
JWT_SECRET=${newSecret} JWT_SECRET=${newSecret}
+2 -2
View File
@@ -1,11 +1,11 @@
{ {
"name": "idc-backend", "name": "yunrui-backend",
"version": "2.0.0", "version": "2.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "idc-backend", "name": "yunrui-backend",
"version": "2.0.0", "version": "2.0.0",
"dependencies": { "dependencies": {
"all": "^0.0.0", "all": "^0.0.0",
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "idc-backend", "name": "yunrui_asset-backend",
"version": "2.1.1", "version": "2.1.1",
"description": "IDC设备管理系统后端", "description": "云睿资产管理系统后端",
"scripts": { "scripts": {
"start": "node server.js", "start": "node server.js",
"dev": "nodemon server.js", "dev": "nodemon server.js",
+5 -5
View File
@@ -31,7 +31,7 @@ const initDefaultSettings = async () => {
// 基本设置 - 站点信息 // 基本设置 - 站点信息
{ {
settingKey: 'site_name', settingKey: 'site_name',
settingValue: JSON.stringify('机柜管理系统'), settingValue: JSON.stringify('云睿资产管理系统'),
settingType: 'string', settingType: 'string',
category: 'general', category: 'general',
description: '网站名称', description: '网站名称',
@@ -133,7 +133,7 @@ const initDefaultSettings = async () => {
}, },
{ {
settingKey: 'system_description', settingKey: 'system_description',
settingValue: JSON.stringify('机柜管理系统 - 专业的数据中心设备管理解决方案'), settingValue: JSON.stringify('云睿资产管理系统 - 专业的数据中心设备管理解决方案'),
settingType: 'string', settingType: 'string',
category: 'about', category: 'about',
description: '系统描述', description: '系统描述',
@@ -374,7 +374,7 @@ router.post('/reset/:key', async (req, res) => {
} }
const defaultValues = { const defaultValues = {
site_name: '机柜管理系统', site_name: '云睿资产管理系统',
site_logo: '', site_logo: '',
idle_timeout: 30, idle_timeout: 30,
max_login_attempts: 5, max_login_attempts: 5,
@@ -385,7 +385,7 @@ router.post('/reset/:key', async (req, res) => {
contact_email: '', contact_email: '',
contact_phone: '', contact_phone: '',
company_address: '', company_address: '',
system_description: '机柜管理系统 - 专业的数据中心设备管理解决方案', system_description: '云睿资产管理系统 - 专业的数据中心设备管理解决方案',
}; };
const defaultValue = defaultValues[key]; const defaultValue = defaultValues[key];
@@ -682,7 +682,7 @@ router.get('/system/info', async (req, res) => {
res.json({ res.json({
system: { system: {
name: '机柜管理系统', name: '云睿资产管理系统',
version: APP_VERSION, version: APP_VERSION,
uptime: process.uptime(), uptime: process.uptime(),
nodeVersion: process.version, nodeVersion: process.version,
+1 -1
View File
@@ -5,7 +5,7 @@ const Device = require('../models/Device');
async function migrate() { async function migrate() {
console.log('========================================'); console.log('========================================');
console.log(' IDC管理系统 - 数据库迁移脚本 v2.0 '); console.log(' 云睿资产管理系统 - 数据库迁移脚本 v2.0 ');
console.log('========================================'); console.log('========================================');
console.log(''); console.log('');
+1 -1
View File
@@ -62,7 +62,7 @@ for (let i = 0; i < args.length; i++) {
async function runBackup() { async function runBackup() {
console.log('========================================'); console.log('========================================');
console.log(' IDC设备管理系统 - 数据备份工具'); console.log(' 云睿资产管理系统 - 数据备份工具');
console.log('========================================\n'); console.log('========================================\n');
try { try {
+2 -2
View File
@@ -46,7 +46,7 @@ const defaultSettings = [
// 全局配置 // 全局配置
{ {
settingKey: 'site_name', settingKey: 'site_name',
settingValue: JSON.stringify('机柜管理系统'), settingValue: JSON.stringify('云睿资产管理系统'),
settingType: 'string', settingType: 'string',
category: 'general', category: 'general',
description: '网站名称', description: '网站名称',
@@ -210,7 +210,7 @@ const defaultSettings = [
}, },
{ {
settingKey: 'system_description', settingKey: 'system_description',
settingValue: JSON.stringify('机柜管理系统 - 专业的数据中心设备管理解决方案'), settingValue: JSON.stringify('云睿资产管理系统 - 专业的数据中心设备管理解决方案'),
settingType: 'string', settingType: 'string',
category: 'about', category: 'about',
description: '系统描述', description: '系统描述',
+2 -2
View File
@@ -1,5 +1,5 @@
/** /**
* IDC管理系统 - 数据库迁移汇总脚本 * 云睿资产管理系统 - 数据库迁移汇总脚本
* 按顺序执行所有数据库迁移 * 按顺序执行所有数据库迁移
* 支持幂等执行(重复执行不会出错) * 支持幂等执行(重复执行不会出错)
* 支持 SQLite 和 MySQL * 支持 SQLite 和 MySQL
@@ -142,7 +142,7 @@ const migrations = [
async function runMigrations() { async function runMigrations() {
console.log('========================================'); console.log('========================================');
console.log(' IDC管理系统 - 数据库迁移汇总脚本 '); console.log(' 云睿资产管理系统 - 数据库迁移汇总脚本 ');
console.log('========================================'); console.log('========================================');
console.log(`数据库类型: ${DB_TYPE}`); console.log(`数据库类型: ${DB_TYPE}`);
console.log(`迁移数量: ${migrations.length}`); console.log(`迁移数量: ${migrations.length}`);
+1 -1
View File
@@ -72,7 +72,7 @@ if (!options.file) {
async function runRestore() { async function runRestore() {
console.log('========================================'); console.log('========================================');
console.log(' IDC设备管理系统 - 数据恢复工具'); console.log(' 云睿资产管理系统 - 数据恢复工具');
console.log('========================================\n'); console.log('========================================\n');
const backupFile = path.resolve(options.file); const backupFile = path.resolve(options.file);
+2 -2
View File
@@ -1,9 +1,9 @@
/** /**
* 示例数据种子脚本 * 示例数据种子脚本
* 为 IDC 设备资产管理系统写入演示数据(幂等,可重复执行) * 为 云睿资产管理系统写入演示数据(幂等,可重复执行)
* *
* 本地:node scripts/seed-example-data.js * 本地:node scripts/seed-example-data.js
* Dockerdocker exec idc_assest-backend node scripts/seed-example-data.js * Dockerdocker exec yunrui_asset-backend node scripts/seed-example-data.js
*/ */
require('dotenv').config({ path: require('path').join(__dirname, '..', '.env') }); require('dotenv').config({ path: require('path').join(__dirname, '..', '.env') });
+2 -2
View File
@@ -336,7 +336,7 @@ app.use(
swaggerUi.serve, swaggerUi.serve,
swaggerUi.setup(specs, { swaggerUi.setup(specs, {
customCss: customCSS, customCss: customCSS,
customSiteTitle: 'IDC设备管理系统 API文档', customSiteTitle: '云睿资产管理系统 API文档',
swaggerOptions: { swaggerOptions: {
persistAuthorization: true, persistAuthorization: true,
displayRequestDuration: true, displayRequestDuration: true,
@@ -358,7 +358,7 @@ app.get('/api-docs.json', (req, res) => {
app.get('/api', (req, res) => { app.get('/api', (req, res) => {
res.json({ res.json({
name: 'IDC设备管理系统 API', name: '云睿资产管理系统 API',
version: '1.0.0', version: '1.0.0',
description: '数据中心设备管理平台后端服务', description: '数据中心设备管理平台后端服务',
endpoints: { endpoints: {
+2 -2
View File
@@ -2,7 +2,7 @@ const swaggerJsdoc = require('swagger-jsdoc');
const customCSS = ` const customCSS = `
/* ======================================== /* ========================================
IDC设备管理系统 - Swagger UI 翠竹绿风格定制 云睿资产管理系统 - Swagger UI 翠竹绿风格定制
======================================== */ ======================================== */
/* 隐藏默认顶部栏 */ /* 隐藏默认顶部栏 */
@@ -511,7 +511,7 @@ const options = {
definition: { definition: {
openapi: '3.0.0', openapi: '3.0.0',
info: { info: {
title: 'IDC设备管理系统 API', title: '云睿资产管理系统 API',
version: '1.0.0', version: '1.0.0',
description: '数据中心设备管理平台后端服务 API 文档', description: '数据中心设备管理平台后端服务 API 文档',
contact: { contact: {
+3 -3
View File
@@ -1,9 +1,9 @@
openapi: 3.0.0 openapi: 3.0.0
info: info:
title: IDC设备管理系统 API title: 云睿资产管理系统 API
version: 1.0.0 version: 1.0.0
description: | description: |
IDC设备管理系统后端API文档 云睿资产管理系统后端API文档
## 认证说明 ## 认证说明
除健康检查接口外,所有接口都需要在请求头中携带JWT Token: 除健康检查接口外,所有接口都需要在请求头中携带JWT Token:
@@ -107,7 +107,7 @@ paths:
example: ok example: ok
message: message:
type: string type: string
example: IDC设备管理系统后端服务正常运行 example: 云睿资产管理系统后端服务正常运行
/api-docs: /api-docs:
get: get:
+1 -1
View File
@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IDC设备管理系统 API文档</title> <title>云睿资产管理系统 API文档</title>
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.10.5/swagger-ui.css"> <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.10.5/swagger-ui.css">
<style> <style>
.swagger-ui .topbar { display: none } .swagger-ui .topbar { display: none }
+1 -1
View File
@@ -150,7 +150,7 @@ const performHealthCheck = async () => {
status: overallStatus, status: overallStatus,
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
service: { service: {
name: 'IDC设备管理系统', name: '云睿资产管理系统',
version: '1.0.0', version: '1.0.0',
}, },
checks: allChecks, checks: allChecks,
+2 -2
View File
@@ -110,7 +110,7 @@ async function uploadViaWebDAV(config, localFilePath, remotePath) {
password: config.password, password: config.password,
authType: config.authType || 'password', authType: config.authType || 'password',
headers: { headers: {
'User-Agent': 'IDC-Backup-Client/1.0', 'User-Agent': 'YunRui-Backup-Client/1.0',
}, },
}); });
@@ -262,7 +262,7 @@ async function testRemoteConnection(config) {
console.log(`测试远端连接 [${config.protocol}]...`); console.log(`测试远端连接 [${config.protocol}]...`);
try { try {
const testContent = `IDC Backup Connection Test - ${new Date().toISOString()}`; const testContent = `YunRui Backup Connection Test - ${new Date().toISOString()}`;
const testFile = path.join(require('os').tmpdir(), `backup-test-${Date.now()}.txt`); const testFile = path.join(require('os').tmpdir(), `backup-test-${Date.now()}.txt`);
fs.writeFileSync(testFile, testContent); fs.writeFileSync(testFile, testContent);
+10 -10
View File
@@ -1,5 +1,5 @@
# ============================================ # ============================================
# IDC 设备管理系统 - 开发环境配置 # 云睿资产管理系统 - 开发环境配置
# 使用 build 指令本地构建镜像 # 使用 build 指令本地构建镜像
# ============================================ # ============================================
@@ -11,7 +11,7 @@ services:
build: build:
context: ./backend context: ./backend
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: idc-backend-dev container_name: yunrui_asset-backend-dev
volumes: volumes:
# 配置映射(核心) # 配置映射(核心)
- ./backend/.env:/app/.env - ./backend/.env:/app/.env
@@ -27,7 +27,7 @@ services:
# 连接 docker-compose 内的 MySQL 时,注释掉下方 MYSQL_HOST 的注释 # 连接 docker-compose 内的 MySQL 时,注释掉下方 MYSQL_HOST 的注释
# 连接远程 MySQL 时,保持 .env 中的配置即可 # 连接远程 MySQL 时,保持 .env 中的配置即可
networks: networks:
- idc-network - yunrui_asset-network
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/health"] test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/health"]
@@ -41,11 +41,11 @@ services:
build: build:
context: ./frontend context: ./frontend
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: idc-frontend-dev container_name: yunrui_asset-frontend-dev
ports: ports:
- "80:80" - "80:80"
networks: networks:
- idc-network - yunrui_asset-network
depends_on: depends_on:
- backend - backend
restart: unless-stopped restart: unless-stopped
@@ -54,18 +54,18 @@ services:
# 如需使用本地 MySQL 容器,取消下方注释 # 如需使用本地 MySQL 容器,取消下方注释
# mysql: # mysql:
# image: mysql:8.0 # image: mysql:8.0
# container_name: idc-mysql-dev # container_name: yunrui_asset-mysql-dev
# volumes: # volumes:
# - mysql_data:/var/lib/mysql # - mysql_data:/var/lib/mysql
# environment: # environment:
# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root123} # MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root123}
# MYSQL_DATABASE: idc_management # MYSQL_DATABASE: yunrui_management
# MYSQL_USER: idc_user # MYSQL_USER: yunrui_user
# MYSQL_PASSWORD: ${MYSQL_PASSWORD:-idc_pass} # MYSQL_PASSWORD: ${MYSQL_PASSWORD:-idc_pass}
# ports: # ports:
# - "3306:3306" # - "3306:3306"
# networks: # networks:
# - idc-network # - yunrui_asset-network
# restart: unless-stopped # restart: unless-stopped
# healthcheck: # healthcheck:
# test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] # test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
@@ -74,7 +74,7 @@ services:
# retries: 5 # retries: 5
networks: networks:
idc-network: yunrui_asset-network:
driver: bridge driver: bridge
# volumes: # volumes:
+11 -11
View File
@@ -4,23 +4,23 @@ services:
# ---------- MySQL 数据库 ---------- # ---------- MySQL 数据库 ----------
mysql: mysql:
image: mysql:8.0 image: mysql:8.0
container_name: idc_assest-mysql container_name: yunrui_asset-mysql
volumes: volumes:
- idc_assest-mysql-data:/var/lib/mysql - yunrui_asset-mysql-data:/var/lib/mysql
environment: environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-xinmi_password} MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-xinmi_password}
MYSQL_DATABASE: ${MYSQL_DATABASE:-idc_management} MYSQL_DATABASE: ${MYSQL_DATABASE:-yunrui_management}
ports: ports:
- "${MYSQL_PORT:-12006}:3306" - "${MYSQL_PORT:-12006}:3306"
networks: networks:
- idc_assest-network - yunrui_asset-network
# ---------- 后端服务 ---------- # ---------- 后端服务 ----------
backend: backend:
build: build:
context: ./backend context: ./backend
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: idc_assest-backend container_name: yunrui_asset-backend
volumes: volumes:
- ./backend/uploads:/app/uploads - ./backend/uploads:/app/uploads
- ./backend/logs:/app/logs - ./backend/logs:/app/logs
@@ -31,7 +31,7 @@ services:
- DB_TYPE=mysql - DB_TYPE=mysql
- MYSQL_HOST=mysql - MYSQL_HOST=mysql
- MYSQL_PORT=3306 - MYSQL_PORT=3306
- MYSQL_DATABASE=${MYSQL_DATABASE:-idc_management} - MYSQL_DATABASE=${MYSQL_DATABASE:-yunrui_management}
- MYSQL_USERNAME=root - MYSQL_USERNAME=root
- MYSQL_PASSWORD=${MYSQL_ROOT_PASSWORD:-xinmi_password} - MYSQL_PASSWORD=${MYSQL_ROOT_PASSWORD:-xinmi_password}
- JWT_SECRET=${JWT_SECRET} - JWT_SECRET=${JWT_SECRET}
@@ -41,24 +41,24 @@ services:
depends_on: depends_on:
- mysql - mysql
networks: networks:
- idc_assest-network - yunrui_asset-network
# ---------- 前端服务 ---------- # ---------- 前端服务 ----------
frontend: frontend:
build: build:
context: ./frontend context: ./frontend
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: idc_assest-frontend container_name: yunrui_asset-frontend
ports: ports:
- "${FRONTEND_PORT:-12000}:80" - "${FRONTEND_PORT:-12000}:80"
depends_on: depends_on:
- backend - backend
networks: networks:
- idc_assest-network - yunrui_asset-network
volumes: volumes:
idc_assest-mysql-data: yunrui_asset-mysql-data:
networks: networks:
idc_assest-network: yunrui_asset-network:
driver: bridge driver: bridge
+12 -12
View File
@@ -1,5 +1,5 @@
# ============================================ # ============================================
# IDC 设备管理系统 - 生产环境配置 # 云睿资产管理系统 - 生产环境配置
# 从镜像仓库拉取预构建镜像,无 build 指令 # 从镜像仓库拉取预构建镜像,无 build 指令
# 默认从 ghcr.io 拉取,可通过 BACKEND/FRONTEND_IMAGE 环境变量切换 # 默认从 ghcr.io 拉取,可通过 BACKEND/FRONTEND_IMAGE 环境变量切换
# ============================================ # ============================================
@@ -10,8 +10,8 @@ services:
# ---------- 后端服务 ---------- # ---------- 后端服务 ----------
backend: backend:
# 从 ghcr.io 拉取公开镜像,可通过 BACKEND_IMAGE 环境变量覆盖 # 从 ghcr.io 拉取公开镜像,可通过 BACKEND_IMAGE 环境变量覆盖
image: ${BACKEND_IMAGE:-ghcr.io/gituib/idc-backend:latest} image: ${BACKEND_IMAGE:-ghcr.io/xinmi/yunrui_asset-backend:latest}
container_name: idc-backend container_name: yunrui_asset-backend
volumes: volumes:
# 配置映射(核心) # 配置映射(核心)
- ./backend/.env:/app/.env - ./backend/.env:/app/.env
@@ -27,7 +27,7 @@ services:
# 生产环境使用 Docker 内 MySQL 时,MYSQL_HOST 需设为 mysql # 生产环境使用 Docker 内 MySQL 时,MYSQL_HOST 需设为 mysql
# 使用远程 MySQL 时,保持 .env 中的配置 # 使用远程 MySQL 时,保持 .env 中的配置
networks: networks:
- idc-network - yunrui_asset-network
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/health"] test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/health"]
@@ -39,13 +39,13 @@ services:
# ---------- 前端(Nginx)服务 ---------- # ---------- 前端(Nginx)服务 ----------
frontend: frontend:
# 从 ghcr.io 拉取公开镜像,可通过 FRONTEND_IMAGE 环境变量覆盖 # 从 ghcr.io 拉取公开镜像,可通过 FRONTEND_IMAGE 环境变量覆盖
image: ${FRONTEND_IMAGE:-ghcr.io/gituib/idc-frontend:latest} image: ${FRONTEND_IMAGE:-ghcr.io/xinmi/yunrui_asset-frontend:latest}
pull_policy: always pull_policy: always
container_name: idc-frontend container_name: yunrui_asset-frontend
ports: ports:
- "80:80" - "80:80"
networks: networks:
- idc-network - yunrui_asset-network
depends_on: depends_on:
- backend - backend
restart: unless-stopped restart: unless-stopped
@@ -54,16 +54,16 @@ services:
# 如需使用本地 MySQL 容器,取消下方注释 # 如需使用本地 MySQL 容器,取消下方注释
# mysql: # mysql:
# image: mysql:8.0 # image: mysql:8.0
# container_name: idc-mysql # container_name: yunrui_asset-mysql
# volumes: # volumes:
# - mysql_data:/var/lib/mysql # - mysql_data:/var/lib/mysql
# environment: # environment:
# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} # MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
# MYSQL_DATABASE: ${MYSQL_DATABASE:-idc_management} # MYSQL_DATABASE: ${MYSQL_DATABASE:-yunrui_management}
# MYSQL_USER: ${MYSQL_USER:-idc_user} # MYSQL_USER: ${MYSQL_USER:-yunrui_user}
# MYSQL_PASSWORD: ${MYSQL_PASSWORD} # MYSQL_PASSWORD: ${MYSQL_PASSWORD}
# networks: # networks:
# - idc-network # - yunrui_asset-network
# restart: unless-stopped # restart: unless-stopped
# healthcheck: # healthcheck:
# test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] # test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
@@ -72,7 +72,7 @@ services:
# retries: 5 # retries: 5
networks: networks:
idc-network: yunrui_asset-network:
driver: bridge driver: bridge
# volumes: # volumes:
+6 -6
View File
@@ -4,20 +4,20 @@ services:
# MySQL 数据库 (可选,默认为 SQLite) # MySQL 数据库 (可选,默认为 SQLite)
mysql: mysql:
image: mysql:8.0 image: mysql:8.0
container_name: idc_assest-mysql container_name: yunrui_assetet-mysql
volumes: volumes:
- idc_assest-mysql-data:/var/lib/mysql - yunrui_assetet-mysql-data:/var/lib/mysql
environment: environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-xinmi_password} MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-xinmi_password}
MYSQL_DATABASE: ${MYSQL_DATABASE:-idc_management} MYSQL_DATABASE: ${MYSQL_DATABASE:-yunrui_management}
ports: ports:
- "${MYSQL_PORT:-12006}:3306" - "${MYSQL_PORT:-12006}:3306"
networks: networks:
- idc_assest-network - yunrui_assetet-network
volumes: volumes:
idc_assest-mysql-data: yunrui_assetet-mysql-data:
networks: networks:
idc_assest-network: yunrui_assetet-network:
driver: bridge driver: bridge
+4 -5
View File
@@ -1,4 +1,4 @@
# IDC设备资产系统 - 用户使用指南 # 云睿资产系统 - 用户使用指南
## 目录 ## 目录
@@ -24,7 +24,7 @@
### 系统简介 ### 系统简介
IDC设备资产系统是一款现代化的数据中心(IDC)设备管理平台,提供机房、机柜、设备的全生命周期管理,具备3D可视化展示功能。系统采用前后端分离架构,前端基于React + Ant Design构建,后端使用Node.js + Express开发。 云睿资产系统是一款现代化的数据中心(IDC)设备管理平台,提供机房、机柜、设备的全生命周期管理,具备3D可视化展示功能。系统采用前后端分离架构,前端基于React + Ant Design构建,后端使用Node.js + Express开发。
### 核心功能 ### 核心功能
@@ -929,9 +929,8 @@ A: 已关闭的工单无法重新打开,如有新问题请新建工单。
- **功能建议**:提交 Issue 并标注 `feature-request` - **功能建议**:提交 Issue 并标注 `feature-request`
**代码仓库:** **代码仓库:**
- Gitee: https://gitee.com/zhang96110/idc_assest - 源码仓库: https://code.xinmi.cloud/yunruyunrui_asset
- GitHub: https://github.com/gituib/idc_assest yunrui_asset
--- ---
**文档版本**v2.0.0 **文档版本**v2.0.0
+4 -4
View File
@@ -1,6 +1,6 @@
# API接口文档 # API接口文档
本文档描述IDC设备管理系统的后端API接口,遵循RESTful设计规范。 本文档描述云睿资产管理系统的后端API接口,遵循RESTful设计规范。
--- ---
@@ -1861,10 +1861,10 @@ GET /api/system-settings
{ {
"success": true, "success": true,
"data": { "data": {
"siteName": "IDC设备管理系统", "siteName": "云睿资产管理系统",
"siteLogo": "/uploads/logo.png", "siteLogo": "/uploads/logo.png",
"siteDescription": "专业的数据中心设备管理平台", "siteDescription": "专业的数据中心设备管理平台",
"copyright": "© 2024 IDC Management", "copyright": "© 2024 YunRui Asset Management",
"version": "1.0.0" "version": "1.0.0"
}, },
"message": "操作成功" "message": "操作成功"
@@ -2150,7 +2150,7 @@ GET /health
```json ```json
{ {
"status": "ok", "status": "ok",
"message": "IDC设备管理系统后端服务正常运行" "message": "云睿资产管理系统后端服务正常运行"
} }
``` ```
+50 -50
View File
@@ -1,4 +1,4 @@
# IDC 设备管理系统 - Docker 部署教程 # 云睿资产管理系统 - Docker 部署教程
> 适用场景:新服务器上首次部署 > 适用场景:新服务器上首次部署
> >
@@ -84,17 +84,17 @@ docker compose version
```bash ```bash
# 创建部署根目录和所有持久化目录 # 创建部署根目录和所有持久化目录
mkdir -p /opt/idc_assest/backend/{uploads,logs,backups,temp} mkdir -p /opt/yunrui_assetet/backend/{uploads,logs,backups,temp}
cd /opt/idc_assest cd /opt/yunrui_assetet
# 查看目录结构 # 查看目录结构
tree /opt/idc_assest -L 2 tree /opt/yunrui_assetet -L 2
``` ```
预期输出: 预期输出:
``` ```
/opt/idc_assest /opt/yunrui_assetet
└── backend └── backend
├── uploads/ ├── uploads/
├── logs/ ├── logs/
@@ -105,9 +105,9 @@ tree /opt/idc_assest -L 2
### 3.2 创建 docker-compose.yml ### 3.2 创建 docker-compose.yml
```bash ```bash
cat > /opt/idc_assest/docker-compose.yml << 'YAMLEOF' cat > /opt/yunrui_assetet/docker-compose.yml << 'YAMLEOF'
# ============================================ # ============================================
# IDC 设备管理系统 - 生产环境配置 # 云睿资产管理系统 - 生产环境配置
# 从镜像仓库拉取预构建镜像,无 build 指令 # 从镜像仓库拉取预构建镜像,无 build 指令
# 默认从 ghcr.io 拉取,可通过 BACKEND/FRONTEND_IMAGE 环境变量切换 # 默认从 ghcr.io 拉取,可通过 BACKEND/FRONTEND_IMAGE 环境变量切换
# ============================================ # ============================================
@@ -115,8 +115,8 @@ cat > /opt/idc_assest/docker-compose.yml << 'YAMLEOF'
services: services:
# ---------- 后端服务 ---------- # ---------- 后端服务 ----------
backend: backend:
image: ${BACKEND_IMAGE:-ghcr.io/gituib/idc-backend:latest} image: ${BACKEND_IMAGE:-ghcr.io/xinmi/yunrui_asset-backend:latest}
container_name: idc-backend container_name: yunrui_asset-backend
volumes: volumes:
- ./backend/.env:/app/.env - ./backend/.env:/app/.env
- ./backend/uploads:/app/uploads - ./backend/uploads:/app/uploads
@@ -128,7 +128,7 @@ services:
environment: environment:
- NODE_ENV=production - NODE_ENV=production
networks: networks:
- idc-network - yunrui_asset-network
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/health"] test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/health"]
@@ -139,13 +139,13 @@ services:
# ---------- 前端(Nginx)服务 ---------- # ---------- 前端(Nginx)服务 ----------
frontend: frontend:
image: ${FRONTEND_IMAGE:-ghcr.io/gituib/idc-frontend:latest} image: ${FRONTEND_IMAGE:-ghcr.io/xinmi/yunrui_asset-frontend:latest}
pull_policy: always pull_policy: always
container_name: idc-frontend container_name: yunrui_asset-frontend
ports: ports:
- "80:80" - "80:80"
networks: networks:
- idc-network - yunrui_asset-network
depends_on: depends_on:
- backend - backend
restart: unless-stopped restart: unless-stopped
@@ -153,16 +153,16 @@ services:
# ---------- MySQL 数据库 ---------- # ---------- MySQL 数据库 ----------
mysql: mysql:
image: mysql:8.0 image: mysql:8.0
container_name: idc-mysql container_name: yunrui_asset-mysql
volumes: volumes:
- mysql_data:/var/lib/mysql - mysql_data:/var/lib/mysql
environment: environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE:-idc_management} MYSQL_DATABASE: ${MYSQL_DATABASE:-yunrui_management}
MYSQL_USER: ${MYSQL_USER:-idc_user} MYSQL_USER: ${MYSQL_USER:-yunrui_user}
MYSQL_PASSWORD: ${MYSQL_PASSWORD} MYSQL_PASSWORD: ${MYSQL_PASSWORD}
networks: networks:
- idc-network - yunrui_asset-network
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
@@ -171,7 +171,7 @@ services:
retries: 5 retries: 5
networks: networks:
idc-network: yunrui_asset-network:
driver: bridge driver: bridge
volumes: volumes:
@@ -186,12 +186,12 @@ YAMLEOF
> 这个文件是给 Docker Compose 读取的,用于配置 MySQL 容器本身的账号密码。 > 这个文件是给 Docker Compose 读取的,用于配置 MySQL 容器本身的账号密码。
```bash ```bash
cd /opt/idc_assest cd /opt/yunrui_assetet
cat > .env << 'EOF' cat > .env << 'EOF'
MYSQL_ROOT_PASSWORD=这里填MySQL root密码 MYSQL_ROOT_PASSWORD=这里填MySQL root密码
MYSQL_USER=idc_user MYSQL_USER=yunrui_user
MYSQL_PASSWORD=这里填MySQL用户密码(与 backend/.env 中 MYSQL_PASSWORD 一致) MYSQL_PASSWORD=这里填MySQL用户密码(与 backend/.env 中 MYSQL_PASSWORD 一致)
MYSQL_DATABASE=idc_management MYSQL_DATABASE=yunrui_management
EOF EOF
``` ```
@@ -200,7 +200,7 @@ EOF
> **重要**:这个文件是后端 Node.js 应用读取的,配置数据库连接、JWT 等业务参数。不要与项目根目录的 `.env` 混淆。 > **重要**:这个文件是后端 Node.js 应用读取的,配置数据库连接、JWT 等业务参数。不要与项目根目录的 `.env` 混淆。
```bash ```bash
cd /opt/idc_assest/backend cd /opt/yunrui_assetet/backend
# 先生成 JWT 密钥(确保已执行 4.1 节的命令) # 先生成 JWT 密钥(确保已执行 4.1 节的命令)
# JWT_SECRET=$(openssl rand -base64 64) # JWT_SECRET=$(openssl rand -base64 64)
@@ -220,9 +220,9 @@ NODE_ENV=production
DB_TYPE=mysql DB_TYPE=mysql
MYSQL_HOST=mysql # Docker 服务名,不是 localhost MYSQL_HOST=mysql # Docker 服务名,不是 localhost
MYSQL_PORT=3306 MYSQL_PORT=3306
MYSQL_USERNAME=idc_user MYSQL_USERNAME=yunrui_user
MYSQL_PASSWORD=这里改成MySQL用户密码 MYSQL_PASSWORD=这里改成MySQL用户密码
MYSQL_DATABASE=idc_management MYSQL_DATABASE=yunrui_management
# 方式二:使用远程 MySQL(已有数据库的情况) # 方式二:使用远程 MySQL(已有数据库的情况)
# DB_TYPE=mysql # DB_TYPE=mysql
@@ -267,7 +267,7 @@ EOF
创建完成后,部署目录的文件结构应为: 创建完成后,部署目录的文件结构应为:
``` ```
/opt/idc_assest/ /opt/yunrui_assetet/
├── docker-compose.yml # Docker Compose 配置 ├── docker-compose.yml # Docker Compose 配置
├── .env # Docker Compose 环境变量(MySQL 账号密码) ├── .env # Docker Compose 环境变量(MySQL 账号密码)
└── backend/ └── backend/
@@ -302,28 +302,28 @@ JWT_SECRET=$(openssl rand -base64 64)
| 配置项 | 文件位置 | 说明 | | 配置项 | 文件位置 | 说明 |
| ------------------------- | ------------------------------ | ----------------- | | ------------------------- | ------------------------------ | ----------------- |
| `MYSQL_USER=idc_user` | `/opt/idc_assest/.env` | 指定 MySQL 容器创建的用户名 | | `MYSQL_USER=yunrui_user` | `/oyunrui_assetasset/.env` | 指定 MySQL 容器创建的用户名 |
| `MYSQL_USERNAME=idc_user` | `/opt/idc_assest/backend/.env` | 后端连接数据库用的用户名 | | `MYSQL_USERNAME=yunrui_user` | `/oyunrui_assetasset/backend/.env` | 后端连接数据库用的用户名 |
| `MYSQL_PASSWORD=xxx` | 两个文件各有一处 | 密码必须相同 | | `MYSQL_PASSWORD=xxx` | 两个文件各有一处 | 密码必须相同 |
可以用以下命令快速对比两个文件中的用户和密码是否一致: 可以用以下命令快速对比两个文件中的用户和密码是否一致:
```bash ```bash
cd /opt/idc_assest cd /opt/yunrui_assetet
echo "=== 根目录 .env ===" && grep -E "MYSQL_USER|MYSQL_PASSWORD" .env echo "=== 根目录 .env ===" && grep -E "MYSQL_USER|MYSQL_PASSWORD" .env
echo "" echo ""
echo "=== backend/.env ===" && grep -E "MYSQL_USERNAME|MYSQL_PASSWORD" backend/.env echo "=== backend/.env ===" && grep -E "MYSQL_USERNAME|MYSQL_PASSWORD" backend/.env
``` ```
预期输出(用户名为 `idc_user`,密码两处相同即表示一致): 预期输出(用户名为 `yunrui_user`,密码两处相同即表示一致):
``` ```
=== 根目录 .env === === 根目录 .env ===
MYSQL_USER=idc_user MYSQL_USER=yunrui_user
MYSQL_PASSWORD=MyPassw0rd! MYSQL_PASSWORD=MyPassw0rd!
=== backend/.env === === backend/.env ===
MYSQL_USERNAME=idc_user MYSQL_USERNAME=yunrui_user
MYSQL_PASSWORD=MyPassw0rd! MYSQL_PASSWORD=MyPassw0rd!
``` ```
@@ -331,14 +331,14 @@ MYSQL_PASSWORD=MyPassw0rd!
> 如果已有远程 MySQL 实例,不想在 Docker 中运行 MySQL 容器,请执行以下操作: > 如果已有远程 MySQL 实例,不想在 Docker 中运行 MySQL 容器,请执行以下操作:
**步骤 1**:编辑 `/opt/idc_assest/docker-compose.yml`,注释掉 `mysql` 服务部分: **步骤 1**:编辑 `/opt/yunrui_assetet/docker-compose.yml`,注释掉 `mysql` 服务部分:
```bash ```bash
# 用 sed 注释 mysql 服务(从 services: 末尾到文件末尾) # 用 sed 注释 mysql 服务(从 services: 末尾到文件末尾)
# 或者手动编辑,将 mysql: 到文件末尾的内容用 # 注释掉 # 或者手动编辑,将 mysql: 到文件末尾的内容用 # 注释掉
``` ```
**步骤 2**:修改 `/opt/idc_assest/backend/.env`,配置远程数据库地址: **步骤 2**:修改 `/opt/yunrui_assetet/backend/.env`,配置远程数据库地址:
```ini ```ini
DB_TYPE=mysql DB_TYPE=mysql
@@ -356,7 +356,7 @@ MYSQL_DATABASE=数据库名
### 5.1 首次拉取镜像 ### 5.1 首次拉取镜像
```bash ```bash
cd /opt/idc_assest cd /opt/yunrui_assetet
docker compose -f docker-compose.yml pull docker compose -f docker-compose.yml pull
``` ```
@@ -376,9 +376,9 @@ docker compose -f docker-compose.yml ps
docker compose -f docker-compose.yml logs -f docker compose -f docker-compose.yml logs -f
# 单独查看某个容器的日志 # 单独查看某个容器的日志
docker logs idc-backend docker logs yunrui_asset-backend
docker logs idc-frontend docker logs yunrui_asset-frontend
docker logs idc-mysql docker logs yunrui_asset-mysql
``` ```
### 5.4 等待初始化完成 ### 5.4 等待初始化完成
@@ -392,7 +392,7 @@ docker logs idc-mysql
可以通过日志查看初始化进度: 可以通过日志查看初始化进度:
```bash ```bash
docker logs -f idc-backend docker logs -f yunrui_asset-backend
``` ```
当日志出现以下内容时,说明启动完成: 当日志出现以下内容时,说明启动完成:
@@ -416,9 +416,9 @@ docker compose -f docker-compose.yml ps
``` ```
NAME IMAGE STATUS PORTS NAME IMAGE STATUS PORTS
idc-frontend ghcr.io/.../idc-frontend:latest Up :80->80/tcp yunrui_asset-frontend ghcr.io/.../yunrui_asset-frontend:latest Up :80->80/tcp
idc-backend ghcr.io/.../idc-backend:latest Up (healthy) 8000/tcp yunrui_asset-backend ghcr.io/.../yunrui_asset-backend:latest Up (healthy) 8000/tcp
idc-mysql mysql:8.0 Up 3306/tcp yunrui_asset-mysql mysql:8.0 Up 3306/tcp
``` ```
### 6.2 访问系统 ### 6.2 访问系统
@@ -472,7 +472,7 @@ docker compose -f docker-compose.yml down -v
```bash ```bash
# MySQL 本地容器方式 # MySQL 本地容器方式
docker exec idc-mysql mysqldump -u root -p idc_management > backup_$(date +%Y%m%d).sql docker exec yunrui_asset-mysql mysqldump -u root -p yunrui_management > backup_$(date +%Y%m%d).sql
# 如果开启了自动备份,后端自身也会定期备份到 backend/backups/ 目录 # 如果开启了自动备份,后端自身也会定期备份到 backend/backups/ 目录
``` ```
@@ -480,7 +480,7 @@ docker exec idc-mysql mysqldump -u root -p idc_management > backup_$(date +%Y%m%
### 7.3 查看容器资源占用 ### 7.3 查看容器资源占用
```bash ```bash
docker stats idc-backend idc-frontend idc-mysql docker stats yunrui_asset-backend yunrui_asset-frontend yunrui_asset-mysql
``` ```
### 7.4 更新服务配置 ### 7.4 更新服务配置
@@ -522,7 +522,7 @@ docker image prune -a
```bash ```bash
# 查看退出容器的日志 # 查看退出容器的日志
docker logs idc-backend docker logs yunrui_asset-backend
# 常见错误: # 常见错误:
# - JWT_SECRET 未配置 → 在 backend/.env 中设置 JWT_SECRET # - JWT_SECRET 未配置 → 在 backend/.env 中设置 JWT_SECRET
@@ -560,8 +560,8 @@ ping ghcr.io
检查 `backend/uploads/` 目录是否存在且权限正确: 检查 `backend/uploads/` 目录是否存在且权限正确:
```bash ```bash
ls -la /opt/idc_assest/backend/uploads/ ls -la /opt/yunrui_assetet/backend/uploads/
chmod 755 /opt/idc_assest/backend/uploads/ chmod 755 /opt/yunrui_assetet/backend/uploads/
``` ```
### 9.6 后端连不上 MySQL 容器 ### 9.6 后端连不上 MySQL 容器
@@ -570,10 +570,10 @@ chmod 755 /opt/idc_assest/backend/uploads/
```bash ```bash
# 1. 检查 MySQL 容器状态 # 1. 检查 MySQL 容器状态
docker ps | grep idc-mysql docker ps | grep yunrui_asset-mysql
# 2. 检查 backend/.env 中 MYSQL_HOST 是否是 mysql(服务名),不是 localhost # 2. 检查 backend/.env 中 MYSQL_HOST 是否是 mysql(服务名),不是 localhost
grep MYSQL_HOST /opt/idc_assest/backend/.env grep MYSQL_HOST /opt/yunrui_assetet/backend/.env
# 3. 验证 MySQL 用户密码是否一致 # 3. 验证 MySQL 用户密码是否一致
# backend/.env 中 MYSQL_USERNAME / MYSQL_PASSWORD # backend/.env 中 MYSQL_USERNAME / MYSQL_PASSWORD
@@ -581,7 +581,7 @@ grep MYSQL_HOST /opt/idc_assest/backend/.env
# 两者必须匹配 # 两者必须匹配
# 4. 进入 MySQL 容器验证 # 4. 进入 MySQL 容器验证
docker exec -it idc-mysql mysql -u idc_user -p docker exec -it yunrui_asset-mysql mysql -u yunrui_user -p
``` ```
### 9.7 如何在已有部署基础上添加新配置 ### 9.7 如何在已有部署基础上添加新配置
@@ -590,7 +590,7 @@ docker exec -it idc-mysql mysql -u idc_user -p
```bash ```bash
# 1. 编辑 backend/.env 补充配置 # 1. 编辑 backend/.env 补充配置
vim /opt/idc_assest/backend/.env vim /opt/yunrui_assetet/backend/.env
# 2. 重启后端容器 # 2. 重启后端容器
docker compose -f docker-compose.yml restart backend docker compose -f docker-compose.yml restart backend
+7 -7
View File
@@ -52,8 +52,8 @@
GitHub Actions GitHub Actions
├── 构建 idc-backend:latest 镜像 ├── 构建 yunrui_asset-backend:latest 镜像
├── 构建 idc-frontend:latest 镜像(Nginx + 前端静态文件) ├── 构建 yunrui_asset-frontend:latest 镜像(Nginx + 前端静态文件)
├── 推送到镜像仓库(Docker Hub / 阿里云 / GitHub Container Registry ├── 推送到镜像仓库(Docker Hub / 阿里云 / GitHub Container Registry
@@ -74,11 +74,11 @@
```yaml ```yaml
services: services:
backend: backend:
image: yourname/idc-backend:latest image: yourname/yunrui_asset-backend:latest
# 没有 build 指令,直接从仓库拉取 # 没有 build 指令,直接从仓库拉取
frontend: frontend:
image: yourname/idc-frontend:latest image: yourname/yunrui_asset-frontend:latest
# 同上,服务器不需要装 Node.js # 同上,服务器不需要装 Node.js
mysql: mysql:
@@ -134,8 +134,8 @@ BACKEND_VERSION=v1.2.0 FRONTEND_VERSION=v1.2.0 docker compose up -d
### 5.1 镜像仓库:阿里云容器镜像服务 ### 5.1 镜像仓库:阿里云容器镜像服务
阿里云控制台开通容器镜像服务后: 阿里云控制台开通容器镜像服务后:
1. 创建命名空间(如 `idc-assest` 1. 创建命名空间(如 `yunrui-asset`
2. 创建镜像仓库:`idc-backend``idc-frontend` 2. 创建镜像仓库:`yunrui_asset-backend``yunrui_asset-frontend`
3. 设置访问凭证(用户名 + 密码) 3. 设置访问凭证(用户名 + 密码)
### 5.2 GitHub Secrets 配置 ### 5.2 GitHub Secrets 配置
@@ -171,7 +171,7 @@ BACKEND_VERSION=v1.2.0 FRONTEND_VERSION=v1.2.0 docker compose up -d
管理员 SSH 到生产服务器 管理员 SSH 到生产服务器
cd /opt/idc_assest cd /opt/yunrui_assetet
docker compose -f docker-compose.prod.yml pull docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d docker compose -f docker-compose.prod.yml up -d
``` ```
+1 -1
View File
@@ -1,5 +1,5 @@
# ============================================ # ============================================
# IDC 设备管理系统 - 前端(NginxDockerfile # 云睿资产管理系统 - 前端(NginxDockerfile
# 第一阶段:构建前端静态文件 # 第一阶段:构建前端静态文件
# 第二阶段:Nginx 运行 # 第二阶段:Nginx 运行
# ============================================ # ============================================
+1 -1
View File
@@ -1,5 +1,5 @@
# ============================================ # ============================================
# IDC 设备管理系统 - Nginx 配置 # 云睿资产管理系统 - Nginx 配置
# 功能:serve 前端静态文件 + 反向代理 API # 功能:serve 前端静态文件 + 反向代理 API
# ============================================ # ============================================
+2 -2
View File
@@ -1,11 +1,11 @@
{ {
"name": "idc-frontend", "name": "yunrui-frontend",
"version": "2.1.0", "version": "2.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "idc-frontend", "name": "yunrui-frontend",
"version": "2.1.0", "version": "2.1.0",
"dependencies": { "dependencies": {
"@ant-design/icons": "^6.1.0", "@ant-design/icons": "^6.1.0",
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "idc-frontend", "name": "yunrui_asset-frontend",
"version": "2.1.1", "version": "2.1.1",
"description": "IDC设备管理系统前端", "description": "云睿资产管理系统前端",
"scripts": { "scripts": {
"start": "vite", "start": "vite",
"dev": "vite", "dev": "vite",
+1 -1
View File
@@ -495,7 +495,7 @@ const AppLayout = ({ children }) => {
{!collapsed && ( {!collapsed && (
<div style={{ padding: '0 8px 8px 8px' }}> <div style={{ padding: '0 8px 8px 8px' }}>
<a <a
href="http://www.xinmi.cloud/" href="https://code.xinmi.cloud/yunrui_asset"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
style={{ style={{
+1 -1
View File
@@ -119,7 +119,7 @@ const About = () => {
type="primary" type="primary"
block block
icon={<LinkOutlined />} icon={<LinkOutlined />}
href="http://www.xinmi.cloud/" href="https://code.xinmi.cloud/yunrui_asset"
target="_blank" target="_blank"
> >
访问新觅源码库 访问新觅源码库
+1 -1
View File
@@ -1,6 +1,6 @@
/* ============================================ /* ============================================
Login Page - Light Corporate Design Login Page - Light Corporate Design
Design System: IDC Data Center Management Design System: YunRui Asset Management
Style: Clean Modern Corporate + Data Center Viz Style: Clean Modern Corporate + Data Center Viz
Palette: Teal (#14b8a6) / Blue (#3b82f6) / Purple (#8b5cf6) Palette: Teal (#14b8a6) / Blue (#3b82f6) / Purple (#8b5cf6)
============================================ */ ============================================ */
+1 -1
View File
@@ -458,7 +458,7 @@ const SystemSettings = () => {
</Col> </Col>
<Col xs={24} sm={18} md={19}> <Col xs={24} sm={18} md={19}>
<Title level={3} style={{ color: '#fff', margin: 0, marginBottom: 6, fontSize: '22px' }}> <Title level={3} style={{ color: '#fff', margin: 0, marginBottom: 6, fontSize: '22px' }}>
机柜管理系统 云睿资产管理系统
</Title> </Title>
<Space size={12} wrap style={{ color: 'rgba(255,255,255,0.9)' }}> <Space size={12} wrap style={{ color: 'rgba(255,255,255,0.9)' }}>
<span style={{ fontSize: 14 }}>版本 {settings.app_version?.value || '1.0.0'}</span> <span style={{ fontSize: 14 }}>版本 {settings.app_version?.value || '1.0.0'}</span>
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
/** /**
* IDC设备管理系统 - 安装部署脚本入口 * 云睿资产管理系统 - 安装部署脚本入口
* *
* 实际逻辑已拆分到 install/ 目录下的各个模块 * 实际逻辑已拆分到 install/ 目录下的各个模块
* 此文件仅作为入口,加载并执行 install/index.js * 此文件仅作为入口,加载并执行 install/index.js
+3 -3
View File
@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# ============================================================================ # ============================================================================
# IDC设备管理系统 - Linux 安装引导脚本 # 云睿资产管理系统 - Linux 安装引导脚本
# ============================================================================ # ============================================================================
# #
# 功能:检测并安装 Node.js,然后运行 install.js # 功能:检测并安装 Node.js,然后运行 install.js
@@ -58,7 +58,7 @@ show_banner() {
echo -e "" echo -e ""
echo -e " ${CYAN}${line}${RESET}" echo -e " ${CYAN}${line}${RESET}"
echo -e " ${CYAN}${BRIGHT}${WHITE} IDC 设备管理系统 - Linux 安装引导脚本 ${CYAN}${RESET}" echo -e " ${CYAN}${BRIGHT}${WHITE} 云睿资产管理系统 - Linux 安装引导脚本 ${CYAN}${RESET}"
echo -e " ${CYAN}${DIM} Linux Bootstrap Installation Script ${CYAN}${RESET}" echo -e " ${CYAN}${DIM} Linux Bootstrap Installation Script ${CYAN}${RESET}"
echo -e " ${CYAN}║ v${SCRIPT_VERSION} ${CYAN}${RESET}" echo -e " ${CYAN}║ v${SCRIPT_VERSION} ${CYAN}${RESET}"
echo -e " ${CYAN}${line}${RESET}" echo -e " ${CYAN}${line}${RESET}"
@@ -237,7 +237,7 @@ show_manual_install_guide() {
echo -e " ${PIPE} ${CYAN}node -v${RESET} # 应显示 v20.x.x" echo -e " ${PIPE} ${CYAN}node -v${RESET} # 应显示 v20.x.x"
echo -e " ${PIPE} ${CYAN}npm -v${RESET} # 应显示 10.x.x" echo -e " ${PIPE} ${CYAN}npm -v${RESET} # 应显示 10.x.x"
log_divider log_divider
log_info "安装完成后,请重新运行此脚本继续安装 IDC 设备管理系统" log_info "安装完成后,请重新运行此脚本继续安装 云睿资产管理系统"
} }
check_and_install_dependencies() { check_and_install_dependencies() {
+1 -1
View File
@@ -81,7 +81,7 @@ function parseArgs() {
function showHelp() { function showHelp() {
console.log(` console.log(`
${colors.bright}IDC设备管理系统 - 安装部署脚本 v${SCRIPT_VERSION}${colors.reset} ${colors.bright}云睿资产管理系统 - 安装部署脚本 v${SCRIPT_VERSION}${colors.reset}
用法: node install.js [选项] 用法: node install.js [选项]
+10 -10
View File
@@ -29,7 +29,7 @@ async function configureDatabase(cmdArgs) {
config.dbConfig.port = process.env.MYSQL_PORT || '3306'; config.dbConfig.port = process.env.MYSQL_PORT || '3306';
config.dbConfig.username = process.env.MYSQL_USER || 'root'; config.dbConfig.username = process.env.MYSQL_USER || 'root';
config.dbConfig.password = process.env.MYSQL_PASSWORD || ''; config.dbConfig.password = process.env.MYSQL_PASSWORD || '';
config.dbConfig.database = process.env.MYSQL_DATABASE || 'idc_management'; config.dbConfig.database = process.env.MYSQL_DATABASE || 'yunrui_management';
log.info(`MySQL 配置: ${config.dbConfig.host}:${config.dbConfig.port}/${config.dbConfig.database}`); log.info(`MySQL 配置: ${config.dbConfig.host}:${config.dbConfig.port}/${config.dbConfig.database}`);
} else { } else {
const mysqlOption = await select('MySQL 配置方式:', [ const mysqlOption = await select('MySQL 配置方式:', [
@@ -74,13 +74,13 @@ async function configureDatabase(cmdArgs) {
async function configureExistingMySQL() { async function configureExistingMySQL() {
console.log('\n' + colors.yellow + '请确保 MySQL 服务已启动并创建了数据库' + colors.reset); console.log('\n' + colors.yellow + '请确保 MySQL 服务已启动并创建了数据库' + colors.reset);
console.log(colors.gray + '创建数据库命令: CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset + '\n'); console.log(colors.gray + '创建数据库命令: CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset + '\n');
config.dbConfig.host = await ask('MySQL 主机地址', config.dbConfig.host || 'localhost'); config.dbConfig.host = await ask('MySQL 主机地址', config.dbConfig.host || 'localhost');
config.dbConfig.port = await ask('MySQL 端口', config.dbConfig.port || '3306'); config.dbConfig.port = await ask('MySQL 端口', config.dbConfig.port || '3306');
config.dbConfig.username = await ask('MySQL 用户名', config.dbConfig.username || 'root'); config.dbConfig.username = await ask('MySQL 用户名', config.dbConfig.username || 'root');
config.dbConfig.password = await askPassword('MySQL 密码'); config.dbConfig.password = await askPassword('MySQL 密码');
config.dbConfig.database = await ask('数据库名称', config.dbConfig.database || 'idc_management'); config.dbConfig.database = await ask('数据库名称', config.dbConfig.database || 'yunrui_management');
} }
async function installMySQL() { async function installMySQL() {
@@ -94,7 +94,7 @@ async function installMySQL() {
console.log(' 1. 下载 MySQL: https://dev.mysql.com/downloads/mysql/'); console.log(' 1. 下载 MySQL: https://dev.mysql.com/downloads/mysql/');
console.log(' 2. 或使用 XAMPP/WAMP 等集成环境'); console.log(' 2. 或使用 XAMPP/WAMP 等集成环境');
console.log(' 3. 安装后创建数据库:'); console.log(' 3. 安装后创建数据库:');
console.log(colors.gray + ' CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset); console.log(colors.gray + ' CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset);
return { success: false }; return { success: false };
} }
@@ -135,7 +135,7 @@ async function installMySQL() {
config.dbConfig.port = '3306'; config.dbConfig.port = '3306';
config.dbConfig.username = 'root'; config.dbConfig.username = 'root';
config.dbConfig.password = mysqlRootPassword; config.dbConfig.password = mysqlRootPassword;
config.dbConfig.database = 'idc_management'; config.dbConfig.database = 'yunrui_management';
log.subStep('创建数据库...'); log.subStep('创建数据库...');
await createMySQLDatabase(mysqlRootPassword); await createMySQLDatabase(mysqlRootPassword);
@@ -148,7 +148,7 @@ async function installMySQL() {
port: '3306', port: '3306',
username: 'root', username: 'root',
password: mysqlRootPassword, password: mysqlRootPassword,
database: 'idc_management' database: 'yunrui_management'
} }
}; };
} catch (error) { } catch (error) {
@@ -191,14 +191,14 @@ async function installMySQLRHEL(rootPassword) {
async function createMySQLDatabase(rootPassword) { async function createMySQLDatabase(rootPassword) {
log.subStep('创建数据库...'); log.subStep('创建数据库...');
const createDbSql = 'CREATE DATABASE IF NOT EXISTS idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'; const createDbSql = 'CREATE DATABASE IF NOT EXISTS yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;';
try { try {
execSync(`mysql -u root -p'${rootPassword}' -e "${createDbSql}"`, { execSync(`mysql -u root -p'${rootPassword}' -e "${createDbSql}"`, {
shell: '/bin/bash', shell: '/bin/bash',
stdio: ['pipe', 'pipe', 'pipe'] stdio: ['pipe', 'pipe', 'pipe']
}); });
log.success('数据库 idc_management 创建成功'); log.success('数据库 yunrui_management 创建成功');
return; return;
} catch (error) { } catch (error) {
const errorMsg = error.stderr ? error.stderr.toString() : error.message; const errorMsg = error.stderr ? error.stderr.toString() : error.message;
@@ -210,7 +210,7 @@ async function createMySQLDatabase(rootPassword) {
shell: '/bin/bash', shell: '/bin/bash',
stdio: ['pipe', 'pipe', 'pipe'] stdio: ['pipe', 'pipe', 'pipe']
}); });
log.success('数据库 idc_management 创建成功'); log.success('数据库 yunrui_management 创建成功');
return; return;
} catch (e2) { } catch (e2) {
log.warning(`无密码连接也失败: ${e2.message}`); log.warning(`无密码连接也失败: ${e2.message}`);
@@ -220,7 +220,7 @@ async function createMySQLDatabase(rootPassword) {
log.warning(`数据库自动创建失败: ${errorMsg.trim()}`); log.warning(`数据库自动创建失败: ${errorMsg.trim()}`);
log.info('请手动创建数据库:'); log.info('请手动创建数据库:');
console.log(colors.cyan + ' mysql -u root -p' + colors.reset); console.log(colors.cyan + ' mysql -u root -p' + colors.reset);
console.log(colors.cyan + ' CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset); console.log(colors.cyan + ' CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset);
} }
} }
+8 -8
View File
@@ -11,7 +11,7 @@ function generateBackendEnv() {
try { try {
const jwtSecret = generateSecretKey(64); const jwtSecret = generateSecretKey(64);
let envContent = `# IDC设备管理系统 - 环境配置 let envContent = `# 云睿资产管理系统 - 环境配置
# 生成时间: ${new Date().toISOString()} # 生成时间: ${new Date().toISOString()}
# ============================================== # ==============================================
@@ -42,7 +42,7 @@ DB_TYPE=${config.dbType}
if (config.dbType === 'sqlite') { if (config.dbType === 'sqlite') {
envContent += ` envContent += `
# SQLite 配置 # SQLite 配置
DB_PATH=./idc_management.db DB_PATH=./yunrui_management.db
`; `;
} else { } else {
envContent += ` envContent += `
@@ -85,7 +85,7 @@ function generatePM2Config() {
const pm2Config = { const pm2Config = {
apps: [{ apps: [{
name: 'idc-backend', name: 'yunrui_asset-backend',
script: './server.js', script: './server.js',
cwd: path.join(__dirname, '..', 'backend'), cwd: path.join(__dirname, '..', 'backend'),
instances: 1, instances: 1,
@@ -106,7 +106,7 @@ function generatePM2Config() {
if (config.frontendDeploy === 'pm2') { if (config.frontendDeploy === 'pm2') {
pm2Config.apps.push({ pm2Config.apps.push({
name: 'idc-frontend', name: 'yunrui_asset-frontend',
script: 'serve', script: 'serve',
cwd: path.join(__dirname, '..', 'frontend'), cwd: path.join(__dirname, '..', 'frontend'),
args: `-s dist -l ${config.frontendPort}`, args: `-s dist -l ${config.frontendPort}`,
@@ -145,12 +145,12 @@ function generateNginxConfig() {
if (isWindows) { if (isWindows) {
frontendPath = path.join(__dirname, '..', 'frontend', 'dist').replace(/\\/g, '/'); frontendPath = path.join(__dirname, '..', 'frontend', 'dist').replace(/\\/g, '/');
} else { } else {
frontendPath = '/var/www/idc'; frontendPath = '/var/www/yunrui_asset';
} }
config.nginxRoot = frontendPath; config.nginxRoot = frontendPath;
const nginxConfig = `# IDC设备管理系统 - Nginx配置 const nginxConfig = `# 云睿资产管理系统 - Nginx配置
# 生成时间: ${new Date().toISOString()} # 生成时间: ${new Date().toISOString()}
server { server {
@@ -210,8 +210,8 @@ server {
} }
`; `;
fs.writeFileSync(path.join(deployDir, 'nginx-idc.conf'), nginxConfig); fs.writeFileSync(path.join(deployDir, 'nginx-yunrui.conf'), nginxConfig);
log.success('Nginx 配置文件已生成 (deploy/nginx-idc.conf)'); log.success('Nginx 配置文件已生成 (deploy/nginx-yunrui.conf)');
if (isWindows) { if (isWindows) {
log.info('Windows Nginx 配置路径示例:'); log.info('Windows Nginx 配置路径示例:');
+4 -4
View File
@@ -35,9 +35,9 @@ function printSummary() {
log.section('服务管理命令'); log.section('服务管理命令');
console.log(` ${ICONS.pipe} ${colors.cyan}pm2 status${colors.reset} 查看服务状态`); console.log(` ${ICONS.pipe} ${colors.cyan}pm2 status${colors.reset} 查看服务状态`);
console.log(` ${ICONS.pipe} ${colors.cyan}pm2 logs idc-backend${colors.reset} 查看后端日志`); console.log(` ${ICONS.pipe} ${colors.cyan}pm2 logs yunrui_asset-backend${colors.reset} 查看后端日志`);
console.log(` ${ICONS.pipe} ${colors.cyan}pm2 restart idc-backend${colors.reset} 重启后端`); console.log(` ${ICONS.pipe} ${colors.cyan}pm2 restart yunrui_asset-backend${colors.reset} 重启后端`);
console.log(` ${ICONS.pipe} ${colors.cyan}pm2 stop idc-backend${colors.reset} 停止后端`); console.log(` ${ICONS.pipe} ${colors.cyan}pm2 stop yunrui_asset-backend${colors.reset} 停止后端`);
log.divider(); log.divider();
@@ -70,7 +70,7 @@ async function main() {
initLogFile(LOG_DIR); initLogFile(LOG_DIR);
log.banner( log.banner(
'IDC 设备管理系统', '云睿资产管理系统',
'安装部署脚本', '安装部署脚本',
SCRIPT_VERSION SCRIPT_VERSION
); );
+10 -10
View File
@@ -180,25 +180,25 @@ async function startServices() {
log.info('停止已有服务...'); log.info('停止已有服务...');
const stopCmd = process.platform === 'win32' const stopCmd = process.platform === 'win32'
? 'pm2 stop idc-backend idc-frontend 2>nul || exit 0' ? 'pm2 stop yunrui_asset-backend yunrui_asset-frontend 2>nul || exit 0'
: 'pm2 stop idc-backend idc-frontend 2>/dev/null || true'; : 'pm2 stop yunrui_asset-backend yunrui_asset-frontend 2>/dev/null || true';
runCommand(stopCmd, { silent: true }); runCommand(stopCmd, { silent: true });
log.info('启动后端服务...'); log.info('启动后端服务...');
const backendResult = runCommand( const backendResult = runCommand(
`pm2 start server.js --name "idc-backend" --env ${config.nodeEnv}`, `pm2 start server.js --name "yunrui_asset-backend" --env ${config.nodeEnv}`,
{ cwd: path.join(__dirname, '..', 'backend') } { cwd: path.join(__dirname, '..', 'backend') }
); );
if (backendResult.success) { if (backendResult.success) {
log.success(`后端服务已启动 (端口: ${config.backendPort})`); log.success(`后端服务已启动 (端口: ${config.backendPort})`);
rollbackSteps.push(() => { rollbackSteps.push(() => {
runCommand('pm2 stop idc-backend', { silent: true }); runCommand('pm2 stop yunrui_asset-backend', { silent: true });
runCommand('pm2 delete idc-backend', { silent: true }); runCommand('pm2 delete yunrui_asset-backend', { silent: true });
}); });
} else { } else {
log.error('后端服务启动失败'); log.error('后端服务启动失败');
log.info('请检查后端日志: pm2 logs idc-backend'); log.info('请检查后端日志: pm2 logs yunrui_asset-backend');
throw new Error('Backend service start failed'); throw new Error('Backend service start failed');
} }
@@ -208,19 +208,19 @@ async function startServices() {
log.info('启动前端服务...'); log.info('启动前端服务...');
const frontendResult = runCommand( const frontendResult = runCommand(
`pm2 start serve --name "idc-frontend" -- -s dist -l ${config.frontendPort}`, `pm2 start serve --name "yunrui_asset-frontend" -- -s dist -l ${config.frontendPort}`,
{ cwd: path.join(__dirname, '..', 'frontend') } { cwd: path.join(__dirname, '..', 'frontend') }
); );
if (frontendResult.success) { if (frontendResult.success) {
log.success(`前端服务已启动 (端口: ${config.frontendPort})`); log.success(`前端服务已启动 (端口: ${config.frontendPort})`);
rollbackSteps.push(() => { rollbackSteps.push(() => {
runCommand('pm2 stop idc-frontend', { silent: true }); runCommand('pm2 stop yunrui_asset-frontend', { silent: true });
runCommand('pm2 delete idc-frontend', { silent: true }); runCommand('pm2 delete yunrui_asset-frontend', { silent: true });
}); });
} else { } else {
log.error('前端服务启动失败'); log.error('前端服务启动失败');
log.info('请检查前端日志: pm2 logs idc-frontend'); log.info('请检查前端日志: pm2 logs yunrui_asset-frontend');
throw new Error('Frontend service start failed'); throw new Error('Frontend service start failed');
} }
} }
+5 -5
View File
@@ -200,8 +200,8 @@ async function autoConfigureNginx() {
if (!installed) { if (!installed) {
log.error('Nginx 自动安装失败'); log.error('Nginx 自动安装失败');
log.info('请手动安装 Nginx 后执行:'); log.info('请手动安装 Nginx 后执行:');
console.log(` ${colors.cyan}sudo cp deploy/nginx-idc.conf /etc/nginx/sites-available/idc${colors.reset}`); console.log(` ${colors.cyan}sudo cp deploy/nginx-yunrui.conf /etc/nginx/sites-available/yunrui_asset${colors.reset}`);
console.log(` ${colors.cyan}sudo ln -sf /etc/nginx/sites-available/idc /etc/nginx/sites-enabled/idc${colors.reset}`); console.log(` ${colors.cyan}sudo ln -sf /etc/nginx/sites-available/yunrui_asset /etc/nginx/sites-enabled/yunrui_asset${colors.reset}`);
console.log(` ${colors.cyan}sudo nginx -t && sudo systemctl restart nginx${colors.reset}`); console.log(` ${colors.cyan}sudo nginx -t && sudo systemctl restart nginx${colors.reset}`);
return; return;
} }
@@ -222,7 +222,7 @@ async function autoConfigureNginx() {
wwwDir = '/www/wwwroot/idc'; wwwDir = '/www/wwwroot/idc';
log.info('检测到宝塔面板 Nginx 环境'); log.info('检测到宝塔面板 Nginx 环境');
} else { } else {
wwwDir = '/var/www/idc'; wwwDir = '/var/www/yunrui_asset';
} }
const distDir = path.join(__dirname, '..', 'frontend', 'dist'); const distDir = path.join(__dirname, '..', 'frontend', 'dist');
@@ -244,7 +244,7 @@ async function autoConfigureNginx() {
config.nginxRoot = wwwDir; config.nginxRoot = wwwDir;
const configSource = path.join(__dirname, '..', 'deploy', 'nginx-idc.conf'); const configSource = path.join(__dirname, '..', 'deploy', 'nginx-yunrui.conf');
if (!fs.existsSync(configSource)) { if (!fs.existsSync(configSource)) {
log.error('Nginx 配置文件不存在,请先运行安装脚本'); log.error('Nginx 配置文件不存在,请先运行安装脚本');
@@ -282,7 +282,7 @@ async function autoConfigureNginx() {
if (useSitesAvailable) { if (useSitesAvailable) {
log.info('创建站点软链接...'); log.info('创建站点软链接...');
runCommand(`${sudoPrefix}ln -sf "${configDest}" /etc/nginx/sites-enabled/idc.conf`); runCommand(`${sudoPrefix}ln -sf "${configDest}" /etc/nginx/sites-enabled/yunrui_asset.conf`);
if (fs.existsSync('/etc/nginx/sites-enabled/default')) { if (fs.existsSync('/etc/nginx/sites-enabled/default')) {
log.info('删除默认站点配置...'); log.info('删除默认站点配置...');
+1 -1
View File
@@ -32,7 +32,7 @@ async function rollback() {
const configFiles = [ const configFiles = [
path.join(__dirname, '..', 'backend', '.env'), path.join(__dirname, '..', 'backend', '.env'),
path.join(__dirname, '..', 'ecosystem.config.js'), path.join(__dirname, '..', 'ecosystem.config.js'),
path.join(__dirname, '..', 'deploy', 'nginx-idc.conf'), path.join(__dirname, '..', 'deploy', 'nginx-yunrui.conf'),
]; ];
for (const file of configFiles) { for (const file of configFiles) {
+2 -2
View File
@@ -1,11 +1,11 @@
{ {
"name": "idc-device-management", "name": "yunrui-asset-management",
"version": "2.1.0", "version": "2.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "idc-device-management", "name": "yunrui-asset-management",
"version": "2.1.0", "version": "2.1.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "idc-device-management", "name": "yunrui-asset-management",
"version": "2.1.1", "version": "2.1.1",
"description": "IDC设备管理系统", "description": "云睿资产管理系统",
"scripts": { "scripts": {
"start": "concurrently \"npm run start:backend\" \"npm run start:frontend\"", "start": "concurrently \"npm run start:backend\" \"npm run start:frontend\"",
"start:backend": "cd backend && npm run dev", "start:backend": "cd backend && npm run dev",
+21 -21
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env node #!/usr/bin/env node
/** /**
* IDC设备管理系统 - 卸载脚本 v2.0.0 * 云睿资产管理系统 - 卸载脚本 v2.0.0
* *
* 功能说明 * 功能说明
* - 停止并删除 PM2 管理的后端和前端服务 * - 停止并删除 PM2 管理的后端和前端服务
* - 清理 Nginx 配置文件可选 * - 清理 Nginx 配置文件可选
* - 删除生成的配置文件.envecosystem.config.jsnginx-idc.conf * - 删除生成的配置文件.envecosystem.config.jsnginx-yunrui.conf
* - 可选删除数据库文件SQLite * - 可选删除数据库文件SQLite
* - 可选删除 node_modules 和构建产物 * - 可选删除 node_modules 和构建产物
* *
@@ -58,7 +58,7 @@ function parseArgs() {
function showHelp() { function showHelp() {
console.log(` console.log(`
${colors.bright}IDC设备管理系统 - 卸载脚本 v${SCRIPT_VERSION}${colors.reset} ${colors.bright}云睿资产管理系统 - 卸载脚本 v${SCRIPT_VERSION}${colors.reset}
${colors.bright}用法:${colors.reset} node uninstall.js [选项] ${colors.bright}用法:${colors.reset} node uninstall.js [选项]
@@ -105,7 +105,7 @@ function commandExists(command) {
} }
function getPM2ServiceNames() { function getPM2ServiceNames() {
const defaultNames = { backendName: 'idc-backend', frontendName: 'idc-frontend' }; const defaultNames = { backendName: 'yunrui_asset-backend', frontendName: 'yunrui_asset-frontend' };
const configPath = path.join(__dirname, 'deploy', 'ecosystem.config.js'); const configPath = path.join(__dirname, 'deploy', 'ecosystem.config.js');
if (!fs.existsSync(configPath)) { if (!fs.existsSync(configPath)) {
@@ -123,7 +123,7 @@ function getPM2ServiceNames() {
if (app.name && app.name.startsWith('idc-')) { if (app.name && app.name.startsWith('idc-')) {
if (app.name.includes('backend') || (app.script && app.script.includes('server'))) { if (app.name.includes('backend') || (app.script && app.script.includes('server'))) {
names.backendName = app.name; names.backendName = app.name;
} else if (app.name.includes('frontend') || app.name === 'idc-frontend') { } else if (app.name.includes('frontend') || app.name === 'yunrui_asset-frontend') {
names.frontendName = app.name; names.frontendName = app.name;
} }
} }
@@ -137,7 +137,7 @@ function getPM2ServiceNames() {
function getDatabaseConfig() { function getDatabaseConfig() {
const defaultConfig = { const defaultConfig = {
dbType: 'sqlite', dbType: 'sqlite',
sqliteDbPath: path.join(__dirname, 'backend', 'idc_management.db') sqliteDbPath: path.join(__dirname, 'backend', 'yunrui_management.db')
}; };
const envPath = path.join(__dirname, 'backend', '.env'); const envPath = path.join(__dirname, 'backend', '.env');
@@ -304,13 +304,13 @@ async function cleanupNginxConfig(cmdArgs) {
const sudoPrefix = root ? '' : 'sudo '; const sudoPrefix = root ? '' : 'sudo ';
const idcConfigPaths = [ const idcConfigPaths = [
{ path: '/etc/nginx/sites-available/idc', label: 'sites-available/idc' }, { path: '/etc/nginx/sites-available/yunrui_asset', label: 'sites-available/yunrui_asset' },
{ path: '/etc/nginx/sites-enabled/idc', label: 'sites-enabled/idc(软链接)' }, { path: '/etc/nginx/sites-enabled/yunrui_asset', label: 'sites-enabled/yunrui_asset(软链接)' },
{ path: '/etc/nginx/conf.d/idc', label: 'conf.d/idc' }, { path: '/etc/nginx/conf.d/idc', label: 'conf.d/idc' },
{ path: '/etc/nginx/conf.d/idc.conf', label: 'conf.d/idc.conf' }, { path: '/etc/nginx/conf.d/idc.conf', label: 'conf.d/idc.conf' },
]; ];
const wwwDir = '/var/www/idc'; const wwwDir = '/var/www/yunrui_asset';
const defaultSitePath = '/etc/nginx/sites-enabled/default'; const defaultSitePath = '/etc/nginx/sites-enabled/default';
const defaultAvailablePath = '/etc/nginx/sites-available/default'; const defaultAvailablePath = '/etc/nginx/sites-available/default';
@@ -331,15 +331,15 @@ async function cleanupNginxConfig(cmdArgs) {
} }
if (!configRemoved) { if (!configRemoved) {
log.info('未找到 IDC Nginx 站点配置文件'); log.info('未找到云睿资产 Nginx 站点配置文件');
} }
if (fs.existsSync(wwwDir)) { if (fs.existsSync(wwwDir)) {
log.info('清理前端部署目录...'); log.info('清理前端部署目录...');
const result = runCommand(`${sudoPrefix}rm -rf "${wwwDir}"`, { silent: true }); const result = runCommand(`${sudoPrefix}rm -rf "${wwwDir}"`, { silent: true });
if (result.success) { if (result.success) {
log.success('前端部署目录已删除 (/var/www/idc)'); log.success('前端部署目录已删除 (/var/www/yunrui_asset)');
deletedItems.push({ type: '目录', name: '/var/www/idc' }); deletedItems.push({ type: '目录', name: '/var/www/yunrui_asset' });
} else { } else {
log.warning('前端部署目录删除失败,请手动清理'); log.warning('前端部署目录删除失败,请手动清理');
} }
@@ -384,7 +384,7 @@ async function cleanupConfigFiles() {
const filesToDelete = [ const filesToDelete = [
{ path: path.join(__dirname, 'backend', '.env'), name: '后端环境变量 (.env)', type: '配置文件' }, { path: path.join(__dirname, 'backend', '.env'), name: '后端环境变量 (.env)', type: '配置文件' },
{ path: path.join(__dirname, 'deploy', 'ecosystem.config.js'), name: 'PM2 配置 (ecosystem.config.js)', type: '配置文件' }, { path: path.join(__dirname, 'deploy', 'ecosystem.config.js'), name: 'PM2 配置 (ecosystem.config.js)', type: '配置文件' },
{ path: path.join(__dirname, 'deploy', 'nginx-idc.conf'), name: 'Nginx 配置 (nginx-idc.conf)', type: '配置文件' } { path: path.join(__dirname, 'deploy', 'nginx-yunrui.conf'), name: 'Nginx 配置 (nginx-yunrui.conf)', type: '配置文件' }
]; ];
for (const file of filesToDelete) { for (const file of filesToDelete) {
@@ -513,7 +513,7 @@ async function cleanupDatabase(cmdArgs) {
log.section('MySQL 删除方法'); log.section('MySQL 删除方法');
console.log(` ${ICONS.pipe} 方法1 - MySQL 命令行:`); console.log(` ${ICONS.pipe} 方法1 - MySQL 命令行:`);
console.log(` ${ICONS.pipe} ${colors.cyan}mysql -u root -p${colors.reset}`); console.log(` ${ICONS.pipe} ${colors.cyan}mysql -u root -p${colors.reset}`);
console.log(` ${ICONS.pipe} ${colors.cyan}DROP DATABASE idc_management;${colors.reset}`); console.log(` ${ICONS.pipe} ${colors.cyan}DROP DATABASE yunrui_management;${colors.reset}`);
console.log(` ${ICONS.pipe} 方法2 - 使用数据库管理工具(如 Navicat、DBeaver、phpMyAdmin`); console.log(` ${ICONS.pipe} 方法2 - 使用数据库管理工具(如 Navicat、DBeaver、phpMyAdmin`);
console.log(` ${ICONS.pipe} 方法3 - 如果不再需要 MySQL 数据,可直接卸载 MySQL 服务`); console.log(` ${ICONS.pipe} 方法3 - 如果不再需要 MySQL 数据,可直接卸载 MySQL 服务`);
} }
@@ -681,15 +681,15 @@ function showDryRunPreview(cmdArgs) {
console.log(`\n ${ICONS.pointer} ${colors.bright}2. 清理 Nginx 配置${colors.reset}`); console.log(`\n ${ICONS.pointer} ${colors.bright}2. 清理 Nginx 配置${colors.reset}`);
if (process.platform === 'linux') { if (process.platform === 'linux') {
const nginxConfigPaths = ['/etc/nginx/sites-available/idc', '/etc/nginx/sites-enabled/idc', const nginxConfigPaths = ['/etc/nginx/sites-available/yunrui_asset', '/etc/nginx/sites-enabled/yunrui_asset',
'/etc/nginx/conf.d/idc', '/etc/nginx/conf.d/idc.conf']; '/etc/nginx/conf.d/idc', '/etc/nginx/conf.d/idc.conf'];
nginxConfigPaths.forEach(p => { nginxConfigPaths.forEach(p => {
if (fs.existsSync(p)) { if (fs.existsSync(p)) {
console.log(` ${ICONS.pipe} 删除 IDC 站点配置: ${p}`); console.log(` ${ICONS.pipe} 删除云睿资产站点配置: ${p}`);
} }
}); });
if (fs.existsSync('/var/www/idc')) { if (fs.existsSync('/var/www/yunrui_asset')) {
console.log(` ${ICONS.pipe} 删除前端部署目录 (/var/www/idc)`); console.log(` ${ICONS.pipe} 删除前端部署目录 (/var/www/yunrui_asset)`);
} }
if (!fs.existsSync('/etc/nginx/sites-enabled/default') && fs.existsSync('/etc/nginx/sites-available/default')) { if (!fs.existsSync('/etc/nginx/sites-enabled/default') && fs.existsSync('/etc/nginx/sites-available/default')) {
console.log(` ${ICONS.pipe} 恢复 Nginx 默认站点`); console.log(` ${ICONS.pipe} 恢复 Nginx 默认站点`);
@@ -707,7 +707,7 @@ function showDryRunPreview(cmdArgs) {
const configFiles = [ const configFiles = [
{ path: path.join(__dirname, 'backend', '.env'), name: '后端环境变量 (.env)' }, { path: path.join(__dirname, 'backend', '.env'), name: '后端环境变量 (.env)' },
{ path: path.join(__dirname, 'deploy', 'ecosystem.config.js'), name: 'PM2 配置' }, { path: path.join(__dirname, 'deploy', 'ecosystem.config.js'), name: 'PM2 配置' },
{ path: path.join(__dirname, 'deploy', 'nginx-idc.conf'), name: 'Nginx 配置' } { path: path.join(__dirname, 'deploy', 'nginx-yunrui.conf'), name: 'Nginx 配置' }
]; ];
configFiles.forEach(f => { configFiles.forEach(f => {
if (fs.existsSync(f.path)) { if (fs.existsSync(f.path)) {
@@ -825,12 +825,12 @@ async function main() {
initLogFile(LOG_DIR); initLogFile(LOG_DIR);
log.banner( log.banner(
'IDC 设备管理系统', '云睿资产管理系统',
'卸载脚本', '卸载脚本',
SCRIPT_VERSION SCRIPT_VERSION
); );
log.warning('此脚本将卸载 IDC 设备管理系统'); log.warning('此脚本将卸载 云睿资产管理系统');
if (cmdArgs.force) { if (cmdArgs.force) {
log.info('运行模式: 强制卸载(无需确认)'); log.info('运行模式: 强制卸载(无需确认)');
+8 -8
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
/** /**
* IDC设备管理系统 - 一键更新脚本 * 云睿资产管理系统 - 一键更新脚本
* 功能拉取最新代码 安装依赖 数据库迁移 重建前端 重启服务 健康检查 * 功能拉取最新代码 安装依赖 数据库迁移 重建前端 重启服务 健康检查
* 版本2.0.0 * 版本2.0.0
*/ */
@@ -71,7 +71,7 @@ function parseArgs() {
function showHelp() { function showHelp() {
console.log(` console.log(`
${colors.bright}IDC设备管理系统 - 一键更新脚本 v${SCRIPT_VERSION}${colors.reset} ${colors.bright}云睿资产管理系统 - 一键更新脚本 v${SCRIPT_VERSION}${colors.reset}
${colors.bright}用法:${colors.reset} node update.js [选项] ${colors.bright}用法:${colors.reset} node update.js [选项]
@@ -194,7 +194,7 @@ function findBackendServiceName() {
} }
for (const proc of processes) { for (const proc of processes) {
if (proc.name === 'server' || proc.name === 'idc-backend' || proc.name === 'backend') { if (proc.name === 'server' || proc.name === 'yunrui_asset-backend' || proc.name === 'backend') {
return proc.name; return proc.name;
} }
} }
@@ -219,7 +219,7 @@ function findFrontendServiceName() {
if (script.includes('vite') || scriptPath.includes('vite') || if (script.includes('vite') || scriptPath.includes('vite') ||
script.includes('react') || script.includes('nginx') || script.includes('react') || script.includes('nginx') ||
proc.name === 'frontend' || proc.name === 'idc-frontend') { proc.name === 'frontend' || proc.name === 'yunrui_asset-frontend') {
return proc.name; return proc.name;
} }
} }
@@ -247,7 +247,7 @@ function backupDatabase(options) {
const dbType = dbTypeMatch ? dbTypeMatch[1].toLowerCase() : 'sqlite'; const dbType = dbTypeMatch ? dbTypeMatch[1].toLowerCase() : 'sqlite';
if (dbType === 'sqlite') { if (dbType === 'sqlite') {
const dbPath = path.join(__dirname, 'backend', 'idc_management.db'); const dbPath = path.join(__dirname, 'backend', 'yunrui_management.db');
if (!fs.existsSync(dbPath)) { if (!fs.existsSync(dbPath)) {
log.warning('SQLite 数据库文件不存在,跳过备份'); log.warning('SQLite 数据库文件不存在,跳过备份');
return { success: true, skipped: true }; return { success: true, skipped: true };
@@ -576,7 +576,7 @@ function syncFrontendToNginx(options) {
if (isBtPanel) { if (isBtPanel) {
nginxRoot = '/www/wwwroot/idc'; nginxRoot = '/www/wwwroot/idc';
} else { } else {
nginxRoot = '/var/www/idc'; nginxRoot = '/var/www/yunrui_asset';
} }
log.info(`未配置 nginxRoot,自动检测: ${nginxRoot} (${isBtPanel ? '宝塔' : '标准'})`); log.info(`未配置 nginxRoot,自动检测: ${nginxRoot} (${isBtPanel ? '宝塔' : '标准'})`);
} }
@@ -819,7 +819,7 @@ function rollback(reason) {
log.step('执行回滚...'); log.step('执行回滚...');
if (rollbackInfo.backupDbPath && fs.existsSync(rollbackInfo.backupDbPath)) { if (rollbackInfo.backupDbPath && fs.existsSync(rollbackInfo.backupDbPath)) {
const dbPath = path.join(__dirname, 'backend', 'idc_management.db'); const dbPath = path.join(__dirname, 'backend', 'yunrui_management.db');
fs.copyFileSync(rollbackInfo.backupDbPath, dbPath); fs.copyFileSync(rollbackInfo.backupDbPath, dbPath);
log.success('数据库已回滚'); log.success('数据库已回滚');
} }
@@ -897,7 +897,7 @@ async function main() {
initLogFile(LOG_DIR); initLogFile(LOG_DIR);
log.banner( log.banner(
'IDC 设备管理系统', '云睿资产管理系统',
'一键更新脚本', '一键更新脚本',
SCRIPT_VERSION SCRIPT_VERSION
); );