add compomemts&front

This commit is contained in:
2026-08-10 16:16:37 +03:00
parent b0ee07823e
commit b0754e8cdb
27 changed files with 5256 additions and 962 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.
-52
View File
@@ -5,7 +5,6 @@ const isDev = require('electron-is-dev');
const fs = require('fs');
const COM_PORT = process.env.COM_PORT;
const COM_SPEED = process.env.COM_SPEED;
const { SerialPort } = require('serialport');
const axios = require('axios');
const { logger } = require('../../backend/src/config/logger');
const config = require('../src/config.json')
@@ -140,57 +139,6 @@ app.on('will-quit', () => {
});
//считыватель
SerialPort.list().then(ports => {
logger.info('Доступные порты:', ports.map(p => p.path));
}).catch(err => {
logger.error('Ошибка при получении списка портов:', err);
});
try {
const port = new SerialPort({ path: COM_PORT, baudRate: parseInt(COM_SPEED, 10)});
let buffer = '';
port.on('open', () => {
logger.info(' Serial port открыт');
});
port.on('data', (data) => {
logger.info('RAW DATA:', data);
buffer += data.toString('utf8');
if (buffer.includes('\n')) {
const lines = buffer.split('\n');
lines.forEach((line, idx) => {
if (idx < lines.length - 1) {
const uid = line.trim().replace(/\D/g, '');
if (uid) {
console.log(`UID карты: ${uid}`);
console.log('[DEBUG] Отправляю событие на admin-server:', {
event: 'CARD_PLACED',
uid: uid,
timestamp: Date.now()
});
axios.post(`${config.adminUrl}}/api/card-event`, {
event: 'CARD_PLACED',
uid: uid,
timestamp: Date.now()
}).catch(err => {
console.error('[ADMIN][CARD_LOG] Ошибка отправки:', err.message);
});
if (mainWindow && mainWindow.webContents) {
mainWindow.webContents.send('card-detected', uid);
console.log(` Отправка события 'card-detected' в рендерер с UID: ${uid}`);
} else {
console.warn('mainWindow или webContents не определены, событие не отправлено');
}
}
}
});
buffer = lines[lines.length - 1];
}
});
port.on('error', (err) => {
console.error('Ошибка serialport:', err);
});
} catch (err) {
console.error('!!! FATAL: FAILED TO INITIALIZE SERIALPORT !!!', err);
}
ipcMain.handle('get-app-config', async (event) => {
console.log('[IPC] Renderer requested app config. Sending:', appConfig);