feat: 动态载入node-serialport和node-usb避免nwjs下server异常
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import { exec } from 'node:child_process';
|
||||
import {
|
||||
SerialPort,
|
||||
ReadlineParser,
|
||||
ByteLengthParser
|
||||
} from 'serialport';
|
||||
import _ from 'lodash';
|
||||
import EventsBase from './events-base.js';
|
||||
import { CURRENT_PLANTFORM } from './config.js';
|
||||
import { CURRENT_PLANTFORM, SERVER_MODE } from './config.js';
|
||||
|
||||
|
||||
let SerialPort, ReadlineParser, ByteLengthParser;
|
||||
|
||||
if (SERVER_MODE === 'all') {
|
||||
const serial = await import('serialport');
|
||||
SerialPort = serial.SerialPort;
|
||||
ReadlineParser = serial.ReadlineParser;
|
||||
ByteLengthParser = serial.ByteLengthParser;
|
||||
}
|
||||
|
||||
|
||||
export default class Serial extends EventsBase {
|
||||
|
||||
Reference in New Issue
Block a user