diff --git a/src/components/Debug.vue b/src/components/Debug.vue index ab73e9e..a5a9774 100644 --- a/src/components/Debug.vue +++ b/src/components/Debug.vue @@ -272,10 +272,12 @@ const websocketonmessage = e => { const websocketonopen = () => { console.log('客户端链接成功!!!') handleGetCameraState() - websocketsend(getCameraParametersInteger) - // 无法获取当前闪光灯是开是关。建议上层代码,初始化时候关闭闪光灯,然后在本地保存一个当前状态 - handleCloseFlashLight() - websocketsend(getFlashBrightnessAnalog) + setTimeout(() => { + websocketsend(getCameraParametersInteger) + // 无法获取当前闪光灯是开是关。建议上层代码,初始化时候关闭闪光灯,然后在本地保存一个当前状态 + handleCloseFlashLight() + websocketsend(getFlashBrightnessAnalog) + }, 1000) } const websocketonerror = () => { diff --git a/src/pages/index.vue b/src/pages/index.vue index b8f4dec..87c13e8 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -536,7 +536,13 @@ const check = async () => { if (isCameraOpen.value) { websocketsend(getCharacterRecognitionResult) } else { - MessagePlugin('error', { content: '请确保相机处于开机状态' }) + setTimeout(() => { + if (isCameraOpen.value) { + websocketsend(getCharacterRecognitionResult) + } else { + MessagePlugin('error', { content: '请确保相机处于开机状态' }) + } + }, 1000) } } @@ -544,6 +550,8 @@ onMounted(async () => { websocket.value = new socket() websocket.value.WebSocketSet(getSocketdata) getInitData() + // 刚进入页面需要检测相机是否启动 + websocketsend(getCameraState) }) const catCurrentTaskDetail = () => {