学习机3.4.0版本
This commit is contained in:
@@ -17,9 +17,8 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import { NCard, NSpace, NDescriptions, NDescriptionsItem } from 'naive-ui'
|
||||
import { NCard, NSpace, NDescriptions, NDescriptionsItem, useMessage } from 'naive-ui'
|
||||
|
||||
import { useSerialPortStore, SerialPortEventType } from '@/stores/serialPort'
|
||||
import { LineBreakParser } from '@/utils/parser'
|
||||
|
||||
const date = ref()
|
||||
@@ -45,13 +44,13 @@ const handle = (data: string) => {
|
||||
|
||||
const decoder = new TextDecoder()
|
||||
const parser = new LineBreakParser()
|
||||
const onSerialPortData = (data: Uint8Array) => {
|
||||
const lineArr = parser.parse(decoder.decode(data))
|
||||
const onSerialPortData = (value: Uint8Array) => {
|
||||
const lineArr = parser.parse(decoder.decode(value))
|
||||
lineArr.forEach(line => handle(line))
|
||||
}
|
||||
|
||||
const serialPort = useSerialPortStore()
|
||||
serialPort.addEventListener(SerialPortEventType.data, onSerialPortData)
|
||||
window.ipcRenderer.send('COM_ON')
|
||||
window.ipcRenderer.receive('COM_LISTENER',onSerialPortData)
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
Reference in New Issue
Block a user