Files
bdqh-course-platform-master/src/render/views/ClockConfig/SoundDetectionModuleConfigView/index.vue

46 lines
1.1 KiB
Vue
Raw Normal View History

2023-10-13 16:43:53 +08:00
<template>
<n-space vertical justify="center" class="sound-detect-module-config-view">
<div>
<n-select
placeholder="请设置声音检测模块事件"
v-model:value="value"
:options="options"
@update:value="onSelectUpdate"
class="mx-auto"
style="width: 50%; "/>
</div>
<ResetButtonView />
</n-space>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { NSpace, NSelect, useMessage } from 'naive-ui'
import ResetButtonView from '../ResetButtonView.vue'
import { options } from './data'
import { useSerialPortStore } from '@/stores/serialPort'
const message = useMessage()
const serialPort = useSerialPortStore()
const value = ref(null)
const onSelectUpdate = () => {
if (!serialPort.isOpen) {
message.error('请先连接无线通信模块并打开串口')
return
}
let cmd = `$SDEVENT,${value.value}*`
cmd += cmd.length
cmd += '\r\n'
serialPort.write(cmd)
}
</script>
<style scoped lang="less">
.sound-detect-module-config-view {
row-gap: 48px !important;
}
</style>