fix(desktop): prevent illegal baud rate from being passed as parameter

This commit is contained in:
Guoguo
2025-12-16 15:35:43 +08:00
parent 6a2e916981
commit b9e400628f

View File

@@ -80,7 +80,11 @@ export const SerialPort = ({ setMsg }: SerialPortProps): ReactElement => {
setIsFailed(false)
setMsg('')
const rate = customBaudRate ?? baudRate
let rate = baudRate
if (customBaudRate && !baudRateOptions.some(option => option.value === customBaudRate)) {
rate = customBaudRate
}
const success = await window.electron.ipcRenderer.invoke(IpcEvents.OPEN_SERIAL_PORT, port, rate)
if (success) {