feat: 实现安全存储和批量导入功能增强

refactor(前端): 重构认证和存储逻辑使用secureStorage
feat(前端): 添加安全存储工具和日志工具
feat(前端): 增强批量导入功能支持服务器和交换机设备
fix(后端): 改进设备端口和网卡批量导入接口
docs: 更新导入模板和操作说明
This commit is contained in:
zhangbing
2026-03-29 10:06:32 +08:00
parent 63f0cb570e
commit 1d815b812e
22 changed files with 1326 additions and 214 deletions
+13 -4
View File
@@ -165,13 +165,22 @@ router.post('/batch', async (req, res) => {
const portData = ports[i];
try {
if (!portData.portId || !portData.deviceId || !portData.portName) {
if (!portData.portId || !(portData.deviceId || portData.deviceSn) || !portData.portName) {
throw new Error('缺少必填字段');
}
const device = await Device.findByPk(portData.deviceId, { transaction });
if (!device) {
throw new Error(`设备 ${portData.deviceId} 不存在`);
let device;
if (portData.deviceSn) {
device = await Device.findOne({ where: { serialNumber: portData.deviceSn }, transaction });
if (!device) {
throw new Error(`设备SN ${portData.deviceSn} 不存在`);
}
portData.deviceId = device.deviceId;
} else {
device = await Device.findByPk(portData.deviceId, { transaction });
if (!device) {
throw new Error(`设备ID ${portData.deviceId} 不存在`);
}
}
const isServer = device.type && device.type.toLowerCase().includes('server');