From dfd3d67ca0eea06cd4295540a0b741bfbe80007c Mon Sep 17 00:00:00 2001 From: zhang1106 <849185023@qq.com> Date: Wed, 21 Jan 2026 10:40:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE):=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=85=A8=E5=B1=80=E9=85=8D=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增ConfigContext提供全局配置状态管理 - 重构系统设置页面,移除语言和深色模式选项 - 优化备份功能,支持自定义备份路径 - 应用主题颜色动态更新功能 - 添加配置变更自动重载机制 --- .../backup_2026-01-21T01-50-59-025Z.json | 1280 +++++++++++++++++ backend/routes/systemSettings.js | 50 +- frontend/src/App.jsx | 168 ++- frontend/src/context/ConfigContext.jsx | 79 + frontend/src/pages/SystemSettings.jsx | 77 +- 5 files changed, 1596 insertions(+), 58 deletions(-) create mode 100644 backend/backups/backup_2026-01-21T01-50-59-025Z.json create mode 100644 frontend/src/context/ConfigContext.jsx diff --git a/backend/backups/backup_2026-01-21T01-50-59-025Z.json b/backend/backups/backup_2026-01-21T01-50-59-025Z.json new file mode 100644 index 0000000..c729abe --- /dev/null +++ b/backend/backups/backup_2026-01-21T01-50-59-025Z.json @@ -0,0 +1,1280 @@ +{ + "timestamp": "2026-01-21T01:50:59.026Z", + "version": "1.0.0", + "data": { + "devices": [ + { + "deviceId": "DEV001", + "name": "Cisco 路由器002", + "type": "router", + "model": "Cisco ISR 4451", + "serialNumber": "SN9358685702", + "rackId": "A05", + "position": 6, + "height": 2, + "powerConsumption": 266, + "status": "offline", + "purchaseDate": "2023-07-12 16:00:00.000 +00:00", + "warrantyExpiry": "2027-07-11 16:00:00.000 +00:00", + "ipAddress": "192.168.12.51", + "description": "接入路由器,用于路由器002业务", + "customFields": "{\"position\":6,\"height\":2,\"powerConsumption\":266,\"rackId\":\"A05\"}", + "createdAt": "2025-12-30 06:00:33.729 +00:00", + "updatedAt": "2025-12-30 06:00:33.729 +00:00" + }, + { + "deviceId": "KuaiShou_Server_1", + "name": "KuaiShou_Server_1", + "type": "server", + "model": "SR570", + "serialNumber": "819185652", + "rackId": "C06", + "position": 1, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":1,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.243 +00:00", + "updatedAt": "2025-12-30 06:00:56.243 +00:00" + }, + { + "deviceId": "KuaiShou_Server_2", + "name": "KuaiShou_Server_2", + "type": "server", + "model": "SR570", + "serialNumber": "819185655", + "rackId": "C06", + "position": 3, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":3,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.343 +00:00", + "updatedAt": "2025-12-30 06:00:56.343 +00:00" + }, + { + "deviceId": "KuaiShou_Server_3", + "name": "KuaiShou_Server_3", + "type": "server", + "model": "SR570", + "serialNumber": "819185650", + "rackId": "C06", + "position": 5, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":5,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.413 +00:00", + "updatedAt": "2025-12-30 06:00:56.413 +00:00" + }, + { + "deviceId": "KuaiShou_Server_4", + "name": "KuaiShou_Server_4", + "type": "server", + "model": "SR570", + "serialNumber": "819185653", + "rackId": "C06", + "position": 7, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":7,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.482 +00:00", + "updatedAt": "2025-12-30 06:00:56.482 +00:00" + }, + { + "deviceId": "KuaiShou_Server_5", + "name": "KuaiShou_Server_5", + "type": "server", + "model": "SR570", + "serialNumber": "J3012OPF", + "rackId": "C06", + "position": 9, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":9,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.552 +00:00", + "updatedAt": "2025-12-30 06:00:56.552 +00:00" + }, + { + "deviceId": "KuaiShou_Server_6", + "name": "KuaiShou_Server_6", + "type": "server", + "model": "SR570", + "serialNumber": "J30120PE", + "rackId": "C06", + "position": 11, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":11,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.623 +00:00", + "updatedAt": "2025-12-30 06:00:56.623 +00:00" + }, + { + "deviceId": "KuaiShou_Server_7", + "name": "KuaiShou_Server_7", + "type": "server", + "model": "SR570", + "serialNumber": "J3015R86", + "rackId": "C06", + "position": 13, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":13,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.695 +00:00", + "updatedAt": "2025-12-30 06:00:56.695 +00:00" + }, + { + "deviceId": "KuaiShou_Server_8", + "name": "KuaiShou_Server_8", + "type": "server", + "model": "SR570", + "serialNumber": "J3012OPG", + "rackId": "C06", + "position": 15, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":15,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.774 +00:00", + "updatedAt": "2025-12-30 06:00:56.774 +00:00" + }, + { + "deviceId": "KuaiShou_Server_9", + "name": "KuaiShou_Server_9", + "type": "server", + "model": "SR570", + "serialNumber": "J3012ONZ", + "rackId": "C06", + "position": 17, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":17,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.843 +00:00", + "updatedAt": "2025-12-30 06:00:56.843 +00:00" + }, + { + "deviceId": "KuaiShou_Server_10", + "name": "KuaiShou_Server_10", + "type": "server", + "model": "SR570", + "serialNumber": "J300Z86R", + "rackId": "C06", + "position": 19, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":19,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:56.912 +00:00", + "updatedAt": "2025-12-30 06:00:56.912 +00:00" + }, + { + "deviceId": "测试", + "name": "测试", + "type": "server", + "model": "RH2288HV3", + "serialNumber": "2102310YJV10H1001224", + "rackId": "C07", + "position": 6, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":6,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C07\"}", + "createdAt": "2025-12-30 06:00:56.982 +00:00", + "updatedAt": "2025-12-30 06:00:56.982 +00:00" + }, + { + "deviceId": "透明缓存_万兆switch", + "name": "透明缓存_万兆switch", + "type": "switch", + "model": "DELL N4032F", + "serialNumber": "3X9L0Z1", + "rackId": "C06", + "position": 37, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":37,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:57.053 +00:00", + "updatedAt": "2025-12-30 06:00:57.053 +00:00" + }, + { + "deviceId": "透明缓存_千兆管理switch", + "name": "透明缓存_千兆管理switch", + "type": "switch", + "model": "catalyst C3560G", + "serialNumber": "F0C1652V0EM", + "rackId": "C06", + "position": 35, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":35,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:57.122 +00:00", + "updatedAt": "2025-12-30 06:00:57.122 +00:00" + }, + { + "deviceId": "透明缓存_网络流量处理系统", + "name": "透明缓存_网络流量处理系统", + "type": "switch", + "model": "A10", + "serialNumber": "NUlll", + "rackId": "C06", + "position": 33, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":33,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:57.191 +00:00", + "updatedAt": "2025-12-30 06:00:57.191 +00:00" + }, + { + "deviceId": "透明缓存_安全堡垒机", + "name": "透明缓存_安全堡垒机", + "type": "server", + "model": "DELL R730XD", + "serialNumber": "7YFJXP2", + "rackId": "C06", + "position": 30, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":30,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:57.275 +00:00", + "updatedAt": "2025-12-30 06:00:57.275 +00:00" + }, + { + "deviceId": "透明缓存_AU3000", + "name": "透明缓存_AU3000", + "type": "server", + "model": "DELL R730XD", + "serialNumber": "7Y4LXP2", + "rackId": "C06", + "position": 27, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":27,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:57.345 +00:00", + "updatedAt": "2025-12-30 06:00:57.345 +00:00" + }, + { + "deviceId": "透明缓存_GC2508_1", + "name": "透明缓存_GC2508_1", + "type": "server", + "model": "DELL R730XD", + "serialNumber": "7ZCQXP2", + "rackId": "C06", + "position": 24, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":24,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:57.413 +00:00", + "updatedAt": "2025-12-30 06:00:57.413 +00:00" + }, + { + "deviceId": "透明缓存_GC2508_2", + "name": "透明缓存_GC2508_2", + "type": "server", + "model": "DELL R730XD", + "serialNumber": "7ZCJXP2", + "rackId": "C06", + "position": 21, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":21,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:57.593 +00:00", + "updatedAt": "2025-12-30 06:00:57.593 +00:00" + }, + { + "deviceId": "lvs1.cn3096", + "name": "lvs1.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "CK15B81R03E", + "rackId": "D11", + "position": 24, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":24,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:57.678 +00:00", + "updatedAt": "2025-12-30 06:00:57.678 +00:00" + }, + { + "deviceId": "HUB-1", + "name": "HUB-1", + "type": "switch", + "model": "锐捷", + "serialNumber": "G1LQ6AN015306", + "rackId": "D11", + "position": 41, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":41,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:57.781 +00:00", + "updatedAt": "2025-12-30 06:00:57.781 +00:00" + }, + { + "deviceId": "CNW-EC-SELBPART-G1-1.CN3096", + "name": "CNW-EC-SELBPART-G1-1.CN3096", + "type": "switch", + "model": "锐捷", + "serialNumber": "G1PH70Q10380A", + "rackId": "D11", + "position": 43, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":43,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:57.880 +00:00", + "updatedAt": "2025-12-30 06:00:57.880 +00:00" + }, + { + "deviceId": "CNW-EC-SELBPART-G1-2.CN3096", + "name": "CNW-EC-SELBPART-G1-2.CN3096", + "type": "switch", + "model": "锐捷", + "serialNumber": "G1PH70Q106626", + "rackId": "D12", + "position": 43, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":43,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D12\"}", + "createdAt": "2025-12-30 06:00:57.963 +00:00", + "updatedAt": "2025-12-30 06:00:57.963 +00:00" + }, + { + "deviceId": "lvs2.cn3096", + "name": "lvs2.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "CK15B81R03C", + "rackId": "D12", + "position": 21, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":21,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D12\"}", + "createdAt": "2025-12-30 06:00:58.035 +00:00", + "updatedAt": "2025-12-30 06:00:58.035 +00:00" + }, + { + "deviceId": "LS-6850-56HF-H1", + "name": "LS-6850-56HF-H1", + "type": "switch", + "model": "S6850", + "serialNumber": "210235A2PQP213000096", + "rackId": "C06", + "position": 41, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":41,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:58.113 +00:00", + "updatedAt": "2025-12-30 06:00:58.113 +00:00" + }, + { + "deviceId": "LS-5130S-52S-EI", + "name": "LS-5130S-52S-EI", + "type": "switch", + "model": "S5130", + "serialNumber": "219801A12F9211Q00168", + "rackId": "C06", + "position": 39, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":39,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C06\"}", + "createdAt": "2025-12-30 06:00:58.185 +00:00", + "updatedAt": "2025-12-30 06:00:58.185 +00:00" + }, + { + "deviceId": "KuaiShou_Server_13", + "name": "KuaiShou_Server_10", + "type": "server", + "model": "Dell R540", + "serialNumber": "GLR4D43", + "rackId": "D11", + "position": 30, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1900-01-01 00:00:00.000 +00:00", + "warrantyExpiry": "1920-01-02 00:00:00.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":30,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:58.266 +00:00", + "updatedAt": "2025-12-30 06:00:58.266 +00:00" + }, + { + "deviceId": "KuaiShou_Server_11", + "name": "KuaiShou_Server_11", + "type": "server", + "model": "Dell R540", + "serialNumber": "GLQXC43", + "rackId": "D11", + "position": 33, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":33,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:58.334 +00:00", + "updatedAt": "2025-12-30 06:00:58.334 +00:00" + }, + { + "deviceId": "KuaiShou_Server_12", + "name": "KuaiShou_Server_12", + "type": "server", + "model": "Dell R540", + "serialNumber": "GLR6D43", + "rackId": "D11", + "position": 36, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":36,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:58.405 +00:00", + "updatedAt": "2025-12-30 06:00:58.405 +00:00" + }, + { + "deviceId": "测试1", + "name": "测试1", + "type": "server", + "model": "DELL R730XD", + "serialNumber": "713L52X", + "rackId": "C07", + "position": 12, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1900-01-01 00:00:00.000 +00:00", + "warrantyExpiry": "1920-01-02 00:00:00.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":12,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C07\"}", + "createdAt": "2025-12-30 06:00:58.475 +00:00", + "updatedAt": "2025-12-30 06:00:58.475 +00:00" + }, + { + "deviceId": "测试2", + "name": "测试1", + "type": "server", + "model": "华为2288HV3", + "serialNumber": "2102311QGK10H1000053", + "rackId": "C07", + "position": 15, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1900-01-01 00:00:00.000 +00:00", + "warrantyExpiry": "1920-01-02 00:00:00.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":15,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C07\"}", + "createdAt": "2025-12-30 06:00:58.545 +00:00", + "updatedAt": "2025-12-30 06:00:58.545 +00:00" + }, + { + "deviceId": "测试3", + "name": "测试3", + "type": "server", + "model": "华为2288HV3", + "serialNumber": "210235G78M10E1000139", + "rackId": "C08", + "position": 3, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1900-01-01 00:00:00.000 +00:00", + "warrantyExpiry": "1920-01-02 00:00:00.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":3,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C08\"}", + "createdAt": "2025-12-30 06:00:58.614 +00:00", + "updatedAt": "2025-12-30 06:00:58.614 +00:00" + }, + { + "deviceId": "快手扩容-1", + "name": "快手扩容-1", + "type": "server", + "model": "Lenovo SR570", + "serialNumber": "J300LENE", + "rackId": "C07", + "position": 27, + "height": 1, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":27,\"height\":1,\"powerConsumption\":500,\"rackId\":\"C07\"}", + "createdAt": "2025-12-30 06:00:58.685 +00:00", + "updatedAt": "2025-12-30 06:00:58.685 +00:00" + }, + { + "deviceId": "快手扩容-2", + "name": "快手扩容-2", + "type": "server", + "model": "Inspur SA5212M5", + "serialNumber": "819434370", + "rackId": "C07", + "position": 24, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":24,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C07\"}", + "createdAt": "2025-12-30 06:00:58.755 +00:00", + "updatedAt": "2025-12-30 06:00:58.755 +00:00" + }, + { + "deviceId": "快手扩容-3", + "name": "快手扩容-3", + "type": "server", + "model": "Inspur SA5212M4", + "serialNumber": "819280575", + "rackId": "C07", + "position": 21, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":21,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C07\"}", + "createdAt": "2025-12-30 06:00:58.825 +00:00", + "updatedAt": "2025-12-30 06:00:58.825 +00:00" + }, + { + "deviceId": "快手扩容-4", + "name": "快手扩容-4", + "type": "server", + "model": "Inspur SA5212M5", + "serialNumber": "819452802", + "rackId": "C07", + "position": 18, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":18,\"height\":2,\"powerConsumption\":500,\"rackId\":\"C07\"}", + "createdAt": "2025-12-30 06:00:58.950 +00:00", + "updatedAt": "2025-12-30 06:00:58.950 +00:00" + }, + { + "deviceId": "merge1.cn3096", + "name": "merge1.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "818307883", + "rackId": "D11", + "position": 3, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":3,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:59.023 +00:00", + "updatedAt": "2025-12-30 06:00:59.023 +00:00" + }, + { + "deviceId": "cache6.cn3096", + "name": "cache6.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "818306720", + "rackId": "D11", + "position": 6, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":6,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:59.102 +00:00", + "updatedAt": "2025-12-30 06:00:59.102 +00:00" + }, + { + "deviceId": "cache5.cn3096", + "name": "cache5.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "819585227", + "rackId": "D11", + "position": 9, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":9,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:59.172 +00:00", + "updatedAt": "2025-12-30 06:00:59.172 +00:00" + }, + { + "deviceId": "cache4.cn3096", + "name": "cache4.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "219830538", + "rackId": "D11", + "position": 12, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":12,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:59.243 +00:00", + "updatedAt": "2025-12-30 06:00:59.243 +00:00" + }, + { + "deviceId": "cache3.cn3096", + "name": "cache3.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "218269526", + "rackId": "D11", + "position": 15, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":15,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:59.435 +00:00", + "updatedAt": "2025-12-30 06:00:59.435 +00:00" + }, + { + "deviceId": "cache2.cn3096", + "name": "cache2.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "818294133", + "rackId": "D11", + "position": 18, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":18,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:59.505 +00:00", + "updatedAt": "2025-12-30 06:00:59.505 +00:00" + }, + { + "deviceId": "cache1.cn3096", + "name": "cache1.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "818458511", + "rackId": "D11", + "position": 21, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":21,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D11\"}", + "createdAt": "2025-12-30 06:00:59.575 +00:00", + "updatedAt": "2025-12-30 06:00:59.575 +00:00" + }, + { + "deviceId": "cache7.cn3196", + "name": "cache7.cn3196", + "type": "server", + "model": "阿里定制", + "serialNumber": "819268886", + "rackId": "D12", + "position": 18, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":18,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D12\"}", + "createdAt": "2025-12-30 06:00:59.645 +00:00", + "updatedAt": "2025-12-30 06:00:59.645 +00:00" + }, + { + "deviceId": "cache8.cn3196", + "name": "cache8.cn3196", + "type": "server", + "model": "阿里定制", + "serialNumber": "818281019", + "rackId": "D12", + "position": 15, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":15,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D12\"}", + "createdAt": "2025-12-30 06:00:59.714 +00:00", + "updatedAt": "2025-12-30 06:00:59.714 +00:00" + }, + { + "deviceId": "cache9.cn3196", + "name": "cache9.cn3196", + "type": "server", + "model": "阿里定制", + "serialNumber": "218280243", + "rackId": "D12", + "position": 12, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":12,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D12\"}", + "createdAt": "2025-12-30 06:00:59.784 +00:00", + "updatedAt": "2025-12-30 06:00:59.784 +00:00" + }, + { + "deviceId": "cache10.cn3096", + "name": "cache10.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "218269518", + "rackId": "D12", + "position": 9, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":9,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D12\"}", + "createdAt": "2025-12-30 06:00:59.855 +00:00", + "updatedAt": "2025-12-30 06:00:59.855 +00:00" + }, + { + "deviceId": "cache11.cn3096", + "name": "cache11.cn3096", + "type": "server", + "model": "阿里定制", + "serialNumber": "819585174", + "rackId": "D12", + "position": 6, + "height": 2, + "powerConsumption": 500, + "status": "running", + "purchaseDate": "1899-12-31 15:54:17.000 +00:00", + "warrantyExpiry": "1900-01-01 15:54:17.000 +00:00", + "ipAddress": "", + "description": "", + "customFields": "{\"position\":6,\"height\":2,\"powerConsumption\":500,\"rackId\":\"D12\"}", + "createdAt": "2025-12-30 06:00:59.925 +00:00", + "updatedAt": "2025-12-30 06:00:59.925 +00:00" + } + ], + "racks": [ + { + "rackId": "A04", + "name": "A04", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:50.616 +00:00", + "updatedAt": "2025-12-30 06:00:29.539 +00:00" + }, + { + "rackId": "A05", + "name": "A05", + "height": 42, + "maxPower": 10000, + "currentPower": 266, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:51.135 +00:00", + "updatedAt": "2025-12-30 06:00:33.800 +00:00" + }, + { + "rackId": "A06", + "name": "A06", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:51.240 +00:00", + "updatedAt": "2025-12-30 03:12:08.209 +00:00" + }, + { + "rackId": "A01", + "name": "A01", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:51.344 +00:00", + "updatedAt": "2025-12-30 03:16:57.752 +00:00" + }, + { + "rackId": "A02", + "name": "A02", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:51.519 +00:00", + "updatedAt": "2025-12-30 03:12:09.515 +00:00" + }, + { + "rackId": "A07", + "name": "A07", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:51.622 +00:00", + "updatedAt": "2025-12-30 03:12:09.923 +00:00" + }, + { + "rackId": "A08", + "name": "A08", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:51.867 +00:00", + "updatedAt": "2025-12-30 03:12:09.250 +00:00" + }, + { + "rackId": "A09", + "name": "A09", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:52.416 +00:00", + "updatedAt": "2025-12-30 03:12:09.753 +00:00" + }, + { + "rackId": "A10", + "name": "A10", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:52.701 +00:00", + "updatedAt": "2025-12-30 03:12:09.621 +00:00" + }, + { + "rackId": "A03", + "name": "A03", + "height": 42, + "maxPower": 10000, + "currentPower": 0, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-25 05:08:52.806 +00:00", + "updatedAt": "2025-12-30 03:12:09.483 +00:00" + }, + { + "rackId": "C06", + "name": "C06", + "height": 42, + "maxPower": 10000, + "currentPower": 9500, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-30 03:17:44.632 +00:00", + "updatedAt": "2025-12-30 06:00:58.228 +00:00" + }, + { + "rackId": "C07", + "name": "C07", + "height": 42, + "maxPower": 10000, + "currentPower": 3500, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-30 03:17:44.689 +00:00", + "updatedAt": "2025-12-30 06:00:58.984 +00:00" + }, + { + "rackId": "D11", + "name": "D11", + "height": 42, + "maxPower": 10000, + "currentPower": 6500, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-30 03:17:44.752 +00:00", + "updatedAt": "2025-12-30 06:00:59.610 +00:00" + }, + { + "rackId": "D12", + "name": "D12", + "height": 42, + "maxPower": 10000, + "currentPower": 3500, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-30 03:17:44.796 +00:00", + "updatedAt": "2025-12-30 06:00:59.957 +00:00" + }, + { + "rackId": "C08", + "name": "C08", + "height": 42, + "maxPower": 10000, + "currentPower": 500, + "status": "active", + "roomId": "ROOM001", + "createdAt": "2025-12-30 03:17:44.869 +00:00", + "updatedAt": "2025-12-30 06:00:58.650 +00:00" + } + ], + "rooms": [ + { + "roomId": "ROOM001", + "name": "测试机房", + "location": "测试位置", + "area": 100, + "capacity": 100, + "status": "active", + "description": null, + "createdAt": "2025-12-25 05:06:53.179 +00:00", + "updatedAt": "2025-12-25 05:06:53.179 +00:00" + } + ], + "consumables": [], + "deviceFields": [ + { + "fieldId": 1, + "fieldName": "deviceId", + "displayName": "设备ID", + "fieldType": "string", + "required": 1, + "options": null, + "order": 1, + "visible": 1, + "createdAt": "2025-12-25 05:10:03.898 +00:00", + "updatedAt": "2025-12-29 08:28:41.999 +00:00" + }, + { + "fieldId": 2, + "fieldName": "name", + "displayName": "设备名称", + "fieldType": "string", + "required": 1, + "options": null, + "order": 2, + "visible": 1, + "createdAt": "2025-12-25 05:10:04.777 +00:00", + "updatedAt": "2025-12-29 08:28:42.068 +00:00" + }, + { + "fieldId": 3, + "fieldName": "type", + "displayName": "设备类型", + "fieldType": "select", + "required": 1, + "options": "[{\"value\":\"server\",\"label\":\"服务器\"},{\"value\":\"switch\",\"label\":\"交换机\"},{\"value\":\"router\",\"label\":\"路由器\"},{\"value\":\"storage\",\"label\":\"存储设备\"},{\"value\":\"other\",\"label\":\"其他设备\"}]", + "order": 3, + "visible": 1, + "createdAt": "2025-12-25 05:10:05.492 +00:00", + "updatedAt": "2025-12-29 08:28:42.103 +00:00" + }, + { + "fieldId": 4, + "fieldName": "model", + "displayName": "型号", + "fieldType": "string", + "required": 1, + "options": null, + "order": 4, + "visible": 1, + "createdAt": "2025-12-25 05:10:06.166 +00:00", + "updatedAt": "2025-12-29 08:28:42.139 +00:00" + }, + { + "fieldId": 5, + "fieldName": "serialNumber", + "displayName": "序列号", + "fieldType": "string", + "required": 1, + "options": null, + "order": 5, + "visible": 1, + "createdAt": "2025-12-25 05:10:06.886 +00:00", + "updatedAt": "2025-12-29 08:28:42.173 +00:00" + }, + { + "fieldId": 6, + "fieldName": "rackId", + "displayName": "所在机柜", + "fieldType": "select", + "required": 1, + "options": null, + "order": 6, + "visible": 1, + "createdAt": "2025-12-25 05:10:07.572 +00:00", + "updatedAt": "2025-12-29 08:40:39.158 +00:00" + }, + { + "fieldId": 7, + "fieldName": "position", + "displayName": "位置(U)", + "fieldType": "number", + "required": 1, + "options": null, + "order": 7, + "visible": 1, + "createdAt": "2025-12-25 05:10:08.259 +00:00", + "updatedAt": "2025-12-29 08:28:42.242 +00:00" + }, + { + "fieldId": 8, + "fieldName": "height", + "displayName": "高度(U)", + "fieldType": "number", + "required": 1, + "options": null, + "order": 8, + "visible": 1, + "createdAt": "2025-12-25 05:10:08.973 +00:00", + "updatedAt": "2025-12-29 08:28:42.279 +00:00" + }, + { + "fieldId": 9, + "fieldName": "powerConsumption", + "displayName": "功率(W)", + "fieldType": "number", + "required": 1, + "options": null, + "order": 9, + "visible": 1, + "createdAt": "2025-12-25 05:10:09.051 +00:00", + "updatedAt": "2025-12-29 08:40:39.242 +00:00" + }, + { + "fieldId": 10, + "fieldName": "status", + "displayName": "状态", + "fieldType": "select", + "required": 1, + "options": "[{\"value\":\"running\",\"label\":\"运行中\"},{\"value\":\"maintenance\",\"label\":\"维护中\"},{\"value\":\"offline\",\"label\":\"离线\"},{\"value\":\"fault\",\"label\":\"故障\"}]", + "order": 10, + "visible": 1, + "createdAt": "2025-12-25 05:10:09.087 +00:00", + "updatedAt": "2025-12-29 08:28:42.347 +00:00" + }, + { + "fieldId": 11, + "fieldName": "purchaseDate", + "displayName": "购买日期", + "fieldType": "date", + "required": 1, + "options": null, + "order": 11, + "visible": 1, + "createdAt": "2025-12-25 05:10:09.121 +00:00", + "updatedAt": "2025-12-30 05:59:06.031 +00:00" + }, + { + "fieldId": 12, + "fieldName": "warrantyExpiry", + "displayName": "保修到期", + "fieldType": "date", + "required": 1, + "options": null, + "order": 12, + "visible": 1, + "createdAt": "2025-12-25 05:10:09.157 +00:00", + "updatedAt": "2025-12-30 05:59:06.104 +00:00" + }, + { + "fieldId": 13, + "fieldName": "ipAddress", + "displayName": "IP地址", + "fieldType": "string", + "required": 0, + "options": null, + "order": 13, + "visible": 1, + "createdAt": "2025-12-25 05:10:09.192 +00:00", + "updatedAt": "2025-12-29 08:40:39.417 +00:00" + }, + { + "fieldId": 14, + "fieldName": "description", + "displayName": "描述", + "fieldType": "textarea", + "required": 0, + "options": null, + "order": 14, + "visible": 1, + "createdAt": "2025-12-25 05:10:09.226 +00:00", + "updatedAt": "2025-12-29 08:40:39.523 +00:00" + } + ], + "users": [ + { + "userId": "user_mjkrahqi31ud7tdo5", + "username": "admin", + "status": "active", + "createdAt": "2025-12-25 01:20:37.194 +00:00", + "updatedAt": "2026-01-20 06:50:21.848 +00:00" + } + ] + } +} \ No newline at end of file diff --git a/backend/routes/systemSettings.js b/backend/routes/systemSettings.js index 5f9e00d..3b8d0f0 100644 --- a/backend/routes/systemSettings.js +++ b/backend/routes/systemSettings.js @@ -13,7 +13,6 @@ const initDefaultSettings = async () => { { settingKey: 'site_logo', settingValue: JSON.stringify(''), settingType: 'string', category: 'general', description: '网站Logo URL', isEditable: true }, { settingKey: 'timezone', settingValue: JSON.stringify('Asia/Shanghai'), settingType: 'string', category: 'general', description: '时区设置', isEditable: true }, { settingKey: 'date_format', settingValue: JSON.stringify('YYYY-MM-DD'), settingType: 'string', category: 'general', description: '日期格式', isEditable: true }, - { settingKey: 'language', settingValue: JSON.stringify('zh-CN'), settingType: 'string', category: 'general', description: '语言设置', isEditable: true }, { settingKey: 'session_timeout', settingValue: JSON.stringify(30), settingType: 'number', category: 'general', description: '会话超时时间(分钟)', isEditable: true }, { settingKey: 'max_login_attempts', settingValue: JSON.stringify(5), settingType: 'number', category: 'general', description: '最大登录尝试次数', isEditable: true }, { settingKey: 'maintenance_mode', settingValue: JSON.stringify(false), settingType: 'boolean', category: 'general', description: '维护模式', isEditable: true }, @@ -21,7 +20,6 @@ const initDefaultSettings = async () => { // 外观设置 { settingKey: 'primary_color', settingValue: JSON.stringify('#667eea'), settingType: 'string', category: 'appearance', description: '主题主色调', isEditable: true }, { settingKey: 'secondary_color', settingValue: JSON.stringify('#764ba2'), settingType: 'string', category: 'appearance', description: '主题辅助色调', isEditable: true }, - { settingKey: 'dark_mode', settingValue: JSON.stringify(false), settingType: 'boolean', category: 'appearance', description: '深色模式', isEditable: true }, { settingKey: 'compact_mode', settingValue: JSON.stringify(false), type: 'boolean', category: 'appearance', description: '紧凑模式', isEditable: true }, { settingKey: 'sidebar_collapsed', settingValue: JSON.stringify(false), settingType: 'boolean', category: 'appearance', description: '侧边栏默认折叠', isEditable: true }, { settingKey: 'table_row_height', settingValue: JSON.stringify('default'), settingType: 'string', category: 'appearance', description: '表格行高: small/default/middle/large', isEditable: true }, @@ -234,13 +232,11 @@ router.post('/reset/:key', async (req, res) => { site_logo: '', timezone: 'Asia/Shanghai', date_format: 'YYYY-MM-DD', - language: 'zh-CN', session_timeout: 30, max_login_attempts: 5, maintenance_mode: false, primary_color: '#667eea', secondary_color: '#764ba2', - dark_mode: false, compact_mode: false, sidebar_collapsed: false, table_row_height: 'default', @@ -280,7 +276,19 @@ router.post('/reset/:key', async (req, res) => { // 手动执行备份 router.post('/backup', async (req, res) => { try { - const backupDir = path.join(__dirname, '../backups'); + // 获取系统设置中的备份路径 + const backupPathSetting = await SystemSetting.findByPk('backup_path'); + const backupPath = backupPathSetting ? JSON.parse(backupPathSetting.settingValue) : './backups'; + + // 解析备份目录路径 + let backupDir; + if (backupPath.startsWith('/') || backupPath.match(/^[A-Za-z]:\//)) { + // 绝对路径 + backupDir = backupPath; + } else { + // 相对路径,基于项目根目录 + backupDir = path.join(__dirname, '../', backupPath); + } // 确保备份目录存在 if (!fs.existsSync(backupDir)) { @@ -335,7 +343,7 @@ router.post('/backup', async (req, res) => { res.json({ message: '备份成功', - backupFile: `backups/backup_${timestamp}.json`, + backupFile: `${backupPath}/backup_${timestamp}.json`, fileSize: fs.statSync(backupFile).size, backupCount: backupFiles.length }); @@ -345,10 +353,27 @@ router.post('/backup', async (req, res) => { } }); +// 辅助函数:获取备份目录路径 +const getBackupDir = async () => { + const backupPathSetting = await SystemSetting.findByPk('backup_path'); + const backupPath = backupPathSetting ? JSON.parse(backupPathSetting.settingValue) : './backups'; + + let backupDir; + if (backupPath.startsWith('/') || backupPath.match(/^[A-Za-z]:\//)) { + // 绝对路径 + backupDir = backupPath; + } else { + // 相对路径,基于项目根目录 + backupDir = path.join(__dirname, '../', backupPath); + } + + return backupDir; +}; + // 获取备份列表 router.get('/backup/list', async (req, res) => { try { - const backupDir = path.join(__dirname, '../backups'); + const backupDir = await getBackupDir(); if (!fs.existsSync(backupDir)) { return res.json({ backups: [] }); @@ -361,7 +386,7 @@ router.get('/backup/list', async (req, res) => { const stats = fs.statSync(filePath); return { filename: f, - path: `backups/${f}`, + path: `${path.basename(backupDir)}/${f}`, size: stats.size, createdAt: stats.birthtime, modifiedAt: stats.mtime @@ -384,7 +409,8 @@ router.post('/backup/restore', async (req, res) => { return res.status(400).json({ error: '请提供备份文件名' }); } - const backupFile = path.join(__dirname, '../backups', filename); + const backupDir = await getBackupDir(); + const backupFile = path.join(backupDir, filename); if (!fs.existsSync(backupFile)) { return res.status(404).json({ error: '备份文件不存在' }); @@ -433,7 +459,8 @@ router.post('/backup/restore', async (req, res) => { router.delete('/backup/:filename', async (req, res) => { try { const { filename } = req.params; - const backupFile = path.join(__dirname, '../backups', filename); + const backupDir = await getBackupDir(); + const backupFile = path.join(backupDir, filename); if (!fs.existsSync(backupFile)) { return res.status(404).json({ error: '备份文件不存在' }); @@ -451,7 +478,8 @@ router.delete('/backup/:filename', async (req, res) => { router.get('/backup/download/:filename', async (req, res) => { try { const { filename } = req.params; - const backupFile = path.join(__dirname, '../backups', filename); + const backupDir = await getBackupDir(); + const backupFile = path.join(backupDir, filename); if (!fs.existsSync(backupFile)) { return res.status(404).json({ error: '备份文件不存在' }); diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 6c6b2b7..1b0c7ca 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,8 +1,9 @@ import React, { useState, Suspense, lazy } from 'react'; -import { Layout, Menu, theme, Button, Dropdown, Avatar, message, Space, Divider } from 'antd'; +import { Layout, Menu, theme, Button, Dropdown, Avatar, message, Space, Divider, ConfigProvider as AntdConfigProvider } from 'antd'; import { BarChartOutlined, DatabaseOutlined, CloudServerOutlined, MenuUnfoldOutlined, MenuFoldOutlined, EyeOutlined, BuildOutlined, HomeOutlined, ShoppingCartOutlined, InboxOutlined, ImportOutlined, FileTextOutlined, UserOutlined, LogoutOutlined, HistoryOutlined, AuditOutlined, ToolOutlined, ScheduleOutlined, SettingOutlined } from '@ant-design/icons'; import { BrowserRouter as Router, Routes, Route, Link, Navigate, useLocation, useNavigate } from 'react-router-dom'; import { useAuth } from './context/AuthContext'; +import { ConfigProvider, useConfig } from './context/ConfigContext'; import { Spin } from 'antd'; const Dashboard = lazy(() => import('./pages/Dashboard')); @@ -131,6 +132,7 @@ const AppLayout = ({ children }) => { const { user, logout } = useAuth(); const navigate = useNavigate(); const location = useLocation(); + const { config } = useConfig(); const handleLogout = () => { logout(); @@ -149,6 +151,56 @@ const AppLayout = ({ children }) => { return 'dashboard'; }; + // 动态设计令牌 + const designTokens = { + colors: { + primary: { + main: config.primary_color || '#667eea', + gradient: `linear-gradient(135deg, ${config.primary_color || '#667eea'} 0%, ${config.secondary_color || '#764ba2'} 100%)`, + light: '#8b9ff0' + }, + success: { main: '#10b981' }, + warning: { main: '#f59e0b' }, + error: { main: '#ef4444' }, + text: { + primary: '#1e293b', + secondary: '#64748b', + inverse: '#ffffff' + }, + background: { + primary: '#ffffff', + secondary: '#f8fafc', + dark: '#1e293b' + }, + border: { + light: '#e2e8f0' + }, + sidebar: { + bg: '#ffffff', + bgHover: 'rgba(102, 126, 234, 0.08)', + bgActive: 'rgba(102, 126, 234, 0.15)', + text: '#475569', + textHover: config.primary_color || '#667eea', + textActive: config.primary_color || '#667eea', + border: '#e2e8f0' + } + }, + shadows: { + small: '0 1px 2px 0 rgba(0, 0, 0, 0.05)', + medium: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)', + large: '0 10px 15px -3px rgba(0, 0, 0, 0.1)' + }, + borderRadius: { + small: '6px', + medium: '10px' + }, + spacing: { + sm: '8px', + md: '16px', + lg: '24px' + } + }; + const menuItems = [ { key: 'dashboard', @@ -315,7 +367,7 @@ const AppLayout = ({ children }) => { color: designTokens.colors.primary.main, lineHeight: 1.2 }}> - IDC管理 + {config.site_name || 'IDC管理'}
{ { ); }; +const ThemeConfig = () => { + const { config } = useConfig(); + + // 动态设计令牌 + const designTokens = { + colors: { + primary: { + main: config.primary_color || '#667eea', + gradient: `linear-gradient(135deg, ${config.primary_color || '#667eea'} 0%, ${config.secondary_color || '#764ba2'} 100%)`, + light: '#8b9ff0' + }, + success: { main: '#10b981' }, + warning: { main: '#f59e0b' }, + error: { main: '#ef4444' }, + text: { + primary: '#1e293b', + secondary: '#64748b', + inverse: '#ffffff' + }, + background: { + primary: '#ffffff', + secondary: '#f8fafc', + dark: '#1e293b' + }, + border: { + light: '#e2e8f0' + }, + sidebar: { + bg: '#ffffff', + bgHover: 'rgba(102, 126, 234, 0.08)', + bgActive: 'rgba(102, 126, 234, 0.15)', + text: '#475569', + textHover: config.primary_color || '#667eea', + textActive: config.primary_color || '#667eea', + border: '#e2e8f0' + } + }, + shadows: { + small: '0 1px 2px 0 rgba(0, 0, 0, 0.05)', + medium: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)', + large: '0 10px 15px -3px rgba(0, 0, 0, 0.1)' + }, + borderRadius: { + small: '6px', + medium: '10px' + }, + spacing: { + sm: '8px', + md: '16px', + lg: '24px' + } + }; + + return ( + + + }> + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + + + ); +}; + function App() { return ( - - }> - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - - + + + ); } diff --git a/frontend/src/context/ConfigContext.jsx b/frontend/src/context/ConfigContext.jsx new file mode 100644 index 0000000..1d1b85b --- /dev/null +++ b/frontend/src/context/ConfigContext.jsx @@ -0,0 +1,79 @@ +import React, { createContext, useState, useEffect, useContext } from 'react'; +import axios from 'axios'; + +const ConfigContext = createContext(); + +export const ConfigProvider = ({ children }) => { + const [config, setConfig] = useState({ + // 默认配置 + site_name: '机柜管理系统', + primary_color: '#667eea', + secondary_color: '#764ba2', + sidebar_collapsed: false, + compact_mode: false, + animation_enabled: true, + language: 'zh-CN', + timezone: 'Asia/Shanghai', + date_format: 'YYYY-MM-DD', + session_timeout: 30, + max_login_attempts: 5, + maintenance_mode: false + }); + const [loading, setLoading] = useState(true); + + // 加载系统配置 + const loadConfig = async () => { + try { + const response = await axios.get('/api/system-settings'); + const settings = response.data; + const configValues = {}; + + // 将配置转换为扁平结构 + Object.entries(settings).forEach(([key, value]) => { + configValues[key] = value.value; + }); + + setConfig(prev => ({ + ...prev, + ...configValues + })); + } catch (error) { + console.error('加载系统配置失败:', error); + } finally { + setLoading(false); + } + }; + + // 初始化加载配置 + useEffect(() => { + loadConfig(); + }, []); + + // 更新配置 + const updateConfig = (newConfig) => { + setConfig(prev => ({ + ...prev, + ...newConfig + })); + }; + + // 重新加载配置 + const reloadConfig = async () => { + await loadConfig(); + }; + + return ( + + {children} + + ); +}; + +// 自定义钩子,方便组件使用配置 +export const useConfig = () => { + const context = useContext(ConfigContext); + if (!context) { + throw new Error('useConfig must be used within a ConfigProvider'); + } + return context; +}; diff --git a/frontend/src/pages/SystemSettings.jsx b/frontend/src/pages/SystemSettings.jsx index 67dc141..8f5d3b8 100644 --- a/frontend/src/pages/SystemSettings.jsx +++ b/frontend/src/pages/SystemSettings.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react'; import { Tabs, Form, Input, Switch, Select, Button, Card, Space, message, Modal, Table, Tag, Progress, Divider, Descriptions, Alert } from 'antd'; import { SettingOutlined, GlobalOutlined, BgColorsOutlined, DatabaseOutlined, InfoCircleOutlined, CloudUploadOutlined, DeleteOutlined, ReloadOutlined, DownloadOutlined, SyncOutlined, CheckCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; import axios from 'axios'; +import { useConfig } from '../context/ConfigContext'; const { Option } = Select; const { TabPane } = Tabs; @@ -15,6 +16,7 @@ const SystemSettings = () => { const [backupLoading, setBackupLoading] = useState(false); const [systemInfo, setSystemInfo] = useState(null); const [form] = Form.useForm(); + const { reloadConfig } = useConfig(); useEffect(() => { fetchSettings(); @@ -74,6 +76,8 @@ const SystemSettings = () => { await axios.put('/api/system-settings', { settings: updates }); message.success('设置保存成功'); fetchSettings(); + // 重新加载全局配置,使更改立即生效 + await reloadConfig(); } catch (error) { message.error('保存设置失败'); } finally { @@ -151,6 +155,8 @@ const SystemSettings = () => { await axios.post(`/api/system-settings/reset/${key}`); message.success('重置成功'); fetchSettings(); + // 重新加载全局配置,使更改立即生效 + await reloadConfig(); } catch (error) { message.error('重置失败'); } @@ -237,10 +243,29 @@ const SystemSettings = () => { { value: 'DD/MM/YYYY', label: '01/01/2024' }, { value: 'MM/DD/YYYY', label: '01/01/2024' } ], - language: [ - { value: 'zh-CN', label: '简体中文' }, - { value: 'zh-TW', label: '繁體中文' }, - { value: 'en-US', label: 'English' } + primary_color: [ + { value: '#667eea', label: '蓝色 (#667eea)' }, + { value: '#764ba2', label: '紫色 (#764ba2)' }, + { value: '#f093fb', label: '粉色 (#f093fb)' }, + { value: '#4facfe', label: '浅蓝色 (#4facfe)' }, + { value: '#43e97b', label: '绿色 (#43e97b)' }, + { value: '#fa709a', label: '红色 (#fa709a)' }, + { value: '#fee140', label: '黄色 (#fee140)' }, + { value: '#00b4db', label: '青色 (#00b4db)' }, + { value: '#0083b0', label: '深蓝色 (#0083b0)' }, + { value: '#fcb045', label: '橙色 (#fcb045)' } + ], + secondary_color: [ + { value: '#764ba2', label: '紫色 (#764ba2)' }, + { value: '#667eea', label: '蓝色 (#667eea)' }, + { value: '#4facfe', label: '浅蓝色 (#4facfe)' }, + { value: '#43e97b', label: '绿色 (#43e97b)' }, + { value: '#fa709a', label: '红色 (#fa709a)' }, + { value: '#fee140', label: '黄色 (#fee140)' }, + { value: '#00b4db', label: '青色 (#00b4db)' }, + { value: '#0083b0', label: '深蓝色 (#0083b0)' }, + { value: '#fcb045', label: '橙色 (#fcb045)' }, + { value: '#f093fb', label: '粉色 (#f093fb)' } ], table_row_height: [ { value: 'small', label: '紧凑 (Small)' }, @@ -273,11 +298,18 @@ const SystemSettings = () => { }; const renderGeneralSettings = () => { - const generalKeys = ['site_name', 'site_logo', 'timezone', 'date_format', 'language', 'session_timeout', 'max_login_attempts', 'maintenance_mode']; + const generalKeys = ['site_name', 'site_logo', 'timezone', 'date_format', 'session_timeout', 'max_login_attempts', 'maintenance_mode']; return (
- {generalKeys.map(key => settings[key] && renderFormItem(key, settings[key]))} + {generalKeys.map(key => { + // 确保时区和日期格式使用select类型 + const settingData = { ...settings[key] }; + if (key === 'timezone' || key === 'date_format') { + settingData.type = 'select'; + } + return renderFormItem(key, settingData); + })} @@ -290,18 +322,25 @@ const SystemSettings = () => { }; const renderAppearanceSettings = () => { - const appearanceKeys = ['primary_color', 'secondary_color', 'dark_mode', 'compact_mode', 'sidebar_collapsed', 'table_row_height', 'animation_enabled']; + const appearanceKeys = ['primary_color', 'secondary_color', 'compact_mode', 'sidebar_collapsed', 'table_row_height', 'animation_enabled']; return ( - {appearanceKeys.map(key => settings[key] && renderFormItem(key, settings[key]))} + {appearanceKeys.map(key => { + // 确保主题颜色使用select类型 + const settingData = { ...settings[key] }; + if (key === 'primary_color' || key === 'secondary_color') { + settingData.type = 'select'; + } + return renderFormItem(key, settingData); + })} @@ -314,14 +353,6 @@ const SystemSettings = () => { }; const renderBackupSettings = () => { - const backupInfo = settings.backup_retention ? { - auto_backup_enabled: settings.auto_backup_enabled, - backup_interval: settings.backup_interval, - backup_retention: settings.backup_retention, - last_backup_time: settings.last_backup_time, - backup_count: settings.backup_count - } : null; - const backupColumns = [ { title: '文件名', @@ -357,13 +388,19 @@ const SystemSettings = () => { } ]; + // 备份设置键列表 + const backupKeys = ['auto_backup_enabled', 'backup_interval', 'backup_retention', 'backup_path', 'last_backup_time', 'backup_count']; + return (
- {backupInfo && Object.entries(backupInfo).map(([key, data]) => ( - data && typeof data === 'object' ? renderFormItem(key, data) : null - ))} + {backupKeys.map(key => { + if (settings[key]) { + return renderFormItem(key, settings[key]); + } + return null; + })}