前端提交1103
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
<template v-slot:append>
|
||||
<kbTime></kbTime>
|
||||
<!-- <v-btn icon="mdi-magnify"></v-btn> -->
|
||||
<v-btn icon="mdi-serial-port" @click="doGetPort"></v-btn>
|
||||
<v-btn icon="mdi-overscan" @click="doScreen"></v-btn>
|
||||
</template>
|
||||
</v-app-bar>
|
||||
@@ -29,6 +30,7 @@
|
||||
<v-main>
|
||||
<v-fade-transition>
|
||||
<Report v-if="menuActivated === '报工'"></Report>
|
||||
<Quality v-if="menuActivated === '质量'"></Quality>
|
||||
</v-fade-transition>
|
||||
<!-- 底部logo -->
|
||||
<v-footer class="footer-center" app>
|
||||
@@ -45,6 +47,7 @@
|
||||
import kbTime from '../components/kbTime.vue'
|
||||
|
||||
import Report from '../report/index.vue'
|
||||
import Quality from '../quality/index.vue'
|
||||
const { proxy } = getCurrentInstance()
|
||||
// 返回主页面
|
||||
const goBack = () => {
|
||||
@@ -144,9 +147,41 @@ import { useDisplay } from "vuetify";
|
||||
const { mobile, name } = useDisplay();
|
||||
|
||||
onMounted(() => {
|
||||
checkSerial()
|
||||
console.log('是否是移动设备', mobile.value); // false
|
||||
console.log('桌面大小', name.value); // false
|
||||
});
|
||||
|
||||
|
||||
|
||||
/// ================= 串口通讯 =================
|
||||
function checkSerial() {
|
||||
if ("serial" in navigator) {
|
||||
console.log(true);
|
||||
} else {
|
||||
console.log(false);
|
||||
}
|
||||
}
|
||||
const port = ref(null)
|
||||
const ports = ref([])
|
||||
async function doGetPort() {
|
||||
try {
|
||||
const portInfo = await navigator.serial.requestPort();
|
||||
port.value = await portInfo.open({ baudRate: 9600 });
|
||||
port.value.addEventListener('data', (event) => {
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
const data = decoder.decode(event.data);
|
||||
console.log('接收到串口数据:', data);
|
||||
});
|
||||
console.log('串口已打开');
|
||||
} catch (error) {
|
||||
console.error('串口请求或打开失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/// ==========================================
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user