|
|
@@ -96,12 +96,18 @@ const emit = defineEmits([ 'confirm','onClose']);
|
|
|
import configInfo from '@/stores/modules/config';
|
|
|
const configInfoStore = configInfo();
|
|
|
|
|
|
-const confirm = ()=>{
|
|
|
- hideVideo(currentPointName.value)
|
|
|
+const confirm = async () => {
|
|
|
+ console.log('confirm');
|
|
|
+ setTimeout(()=>{
|
|
|
+ hideVideo(currentPointName.value)
|
|
|
+ },1000)
|
|
|
emit('confirm')
|
|
|
}
|
|
|
-const onClose = ()=>{
|
|
|
- hideVideo(currentPointName.value)
|
|
|
+const onClose = async () => {
|
|
|
+ console.log('onClose');
|
|
|
+ setTimeout(()=>{
|
|
|
+ hideVideo(currentPointName.value)
|
|
|
+ },1000)
|
|
|
emit('onClose')
|
|
|
}
|
|
|
// 定义 props
|
|
|
@@ -156,9 +162,10 @@ async function checkConfirm(init){
|
|
|
loading.value = false;
|
|
|
}
|
|
|
|
|
|
-// editRow 数据加载完成后调用 showVideo
|
|
|
+// editRow 数据加载完成后调用,仅记录点位,首次不打开预览
|
|
|
function onEditRowReady(point_name) {
|
|
|
- showVideo(point_name)
|
|
|
+ console.log('onEditRowReady,记录点位:' + point_name)
|
|
|
+ currentPointName.value = point_name
|
|
|
}
|
|
|
|
|
|
const init = ref(true)
|
|
|
@@ -175,37 +182,88 @@ const showrEditRow = ref(false)
|
|
|
|
|
|
let interval:any = null
|
|
|
let currentPointName = ref('A')
|
|
|
+let isVideoShowing = ref(false)
|
|
|
+let isHidingVideo = ref(false)
|
|
|
+let hideVideoTimer: any = null
|
|
|
+let pendingShowVideoPoint: string | null = null
|
|
|
+let isFirstShow = false // 标记是否已首次显示预览
|
|
|
+
|
|
|
+function clearPreviewInterval() {
|
|
|
+ if (interval) {
|
|
|
+ clearInterval(interval)
|
|
|
+ interval = null
|
|
|
+ }
|
|
|
+ if (hideVideoTimer) {
|
|
|
+ clearTimeout(hideVideoTimer)
|
|
|
+ hideVideoTimer = null
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-function showVideo(point_name = 'A'){
|
|
|
+function showVideo(point_name = 'A') {
|
|
|
+ if (isHidingVideo.value) {
|
|
|
+ console.log('正在关闭预览中,延迟打开:' + point_name)
|
|
|
+ pendingShowVideoPoint = point_name
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isVideoShowing.value && currentPointName.value === point_name) {
|
|
|
+ console.log('预览已在显示,跳过重复调用')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log('打开预览=====================' + point_name)
|
|
|
+ clearPreviewInterval()
|
|
|
+ isVideoShowing.value = true
|
|
|
currentPointName.value = point_name
|
|
|
|
|
|
clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
|
|
|
|
|
|
clientStore.ipc.send(icpList.camera.PreviewShow, { point_name });
|
|
|
clientStore.ipc.on(icpList.camera.PreviewShow, async (event, result) => {
|
|
|
-
|
|
|
- setTimeout(()=>{
|
|
|
- interval = setInterval(()=>{
|
|
|
+ clearPreviewInterval()
|
|
|
+ hideVideoTimer = setTimeout(() => {
|
|
|
+ interval = setInterval(() => {
|
|
|
previewKey.value++;
|
|
|
- },200)
|
|
|
- },500)
|
|
|
-
|
|
|
+ }, 200)
|
|
|
+ }, 500)
|
|
|
})
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-function hideVideo(point_name = 'A'){
|
|
|
+async function hideVideo(point_name = 'A') {
|
|
|
+ console.log('关闭预览=====================' + point_name)
|
|
|
+ clearPreviewInterval()
|
|
|
+ isVideoShowing.value = false
|
|
|
+ isHidingVideo.value = true
|
|
|
+
|
|
|
return new Promise((resolve) => {
|
|
|
clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
|
|
|
clientStore.ipc.send(icpList.camera.PreviewHide, { point_name });
|
|
|
clientStore.ipc.on(icpList.camera.PreviewHide, async (event, result) => {
|
|
|
- if(interval) clearInterval(interval)
|
|
|
+ isHidingVideo.value = false
|
|
|
+ // 如果有待执行的打开请求,执行它
|
|
|
+ if (pendingShowVideoPoint) {
|
|
|
+ const point = pendingShowVideoPoint
|
|
|
+ pendingShowVideoPoint = null
|
|
|
+ setTimeout(() => showVideo(point), 100)
|
|
|
+ }
|
|
|
resolve(true)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
async function switchPreviewPoint(point_name = 'A') {
|
|
|
+ console.log('switchPreviewPoint:' + point_name);
|
|
|
+ // 如果点位相同,不做任何处理
|
|
|
+ if (point_name === currentPointName.value) {
|
|
|
+ console.log('点位相同,跳过切换');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 首次显示预览之前不做切换
|
|
|
+/* if (!isFirstShow) {
|
|
|
+ console.log('首次显示预览前,跳过切换');
|
|
|
+ currentPointName.value = point_name;
|
|
|
+ return;
|
|
|
+ }*/
|
|
|
+ // 执行切换
|
|
|
await hideVideo(currentPointName.value)
|
|
|
showVideo(point_name)
|
|
|
}
|
|
|
@@ -222,31 +280,31 @@ function takePictures() {
|
|
|
console.log(editData.value.editRowData);
|
|
|
|
|
|
if (clientStore.isClient) {
|
|
|
-
|
|
|
loading.value = true;
|
|
|
- hideVideo(currentPointName.value)
|
|
|
- socketStore.sendMessage({
|
|
|
- type: 'run_mcu_single',
|
|
|
- data: {
|
|
|
- camera_height: Number(editData.value.editRowData.camera_height),
|
|
|
- camera_angle: Number(editData.value.editRowData.camera_angle),
|
|
|
- led_switch:editData.value.editRowData.led_switch,
|
|
|
- id:0,
|
|
|
- mode_type:editData.value.editRowData.mode_type,
|
|
|
- turntable_position:Number(editData.value.editRowData.turntable_position),
|
|
|
- action_name:editData.value.editRowData.action_name || '测试',
|
|
|
- turntable_angle: Number(editData.value.editRowData.turntable_angle),
|
|
|
- shoe_upturn: Number(editData.value.editRowData.shoe_upturn),
|
|
|
- action_index:1,
|
|
|
- number_focus:0,
|
|
|
- take_picture:true,
|
|
|
- pre_delay:0,
|
|
|
- after_delay:0,
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ console.log('takePictures');
|
|
|
+ hideVideo(currentPointName.value).then(() => {
|
|
|
+ socketStore.sendMessage({
|
|
|
+ type: 'run_mcu_single',
|
|
|
+ data: {
|
|
|
+ camera_height: Number(editData.value.editRowData.camera_height),
|
|
|
+ camera_angle: Number(editData.value.editRowData.camera_angle),
|
|
|
+ led_switch:editData.value.editRowData.led_switch,
|
|
|
+ id:0,
|
|
|
+ mode_type:editData.value.editRowData.mode_type,
|
|
|
+ turntable_position:Number(editData.value.editRowData.turntable_position),
|
|
|
+ action_name:editData.value.editRowData.action_name || '测试',
|
|
|
+ turntable_angle: Number(editData.value.editRowData.turntable_angle),
|
|
|
+ shoe_upturn: Number(editData.value.editRowData.shoe_upturn),
|
|
|
+ action_index:1,
|
|
|
+ number_focus:0,
|
|
|
+ take_picture:true,
|
|
|
+ pre_delay:0,
|
|
|
+ after_delay:0,
|
|
|
+ point_name:editData.value.editRowData.point_name || currentPointName.value || 'A',
|
|
|
+ is_move_device:editData.value.editRowData.is_move_device || 1
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -261,11 +319,12 @@ function createMainImage (file_path){
|
|
|
clientStore.ipc.on(icpList.takePhoto.createMainImage, async (event, result) => {
|
|
|
if(result.code === 0 && result.data?.main_out_path){
|
|
|
imageTplPath.value = result.data?.main_out_path
|
|
|
- hideVideo(currentPointName.value)
|
|
|
+ // 预览已在 takePictures 中关闭,不再重复调用 hideVideo
|
|
|
step.value = 2
|
|
|
loading.value = false;
|
|
|
}else if(result.msg){
|
|
|
loading.value = false;
|
|
|
+ console.log('createMainImage');
|
|
|
showVideo(currentPointName.value)
|
|
|
if(result.code !== 0) ElMessage.error(result.msg)
|
|
|
}
|
|
|
@@ -282,11 +341,16 @@ clientStore.ipc.on(icpList.socket.message+'_smart_shooter_photo_take', async (ev
|
|
|
console.log(result);
|
|
|
if(result.code === 0 && result.data?.photo_file_name){
|
|
|
imageTplPath.value = result.data?.photo_file_name
|
|
|
- hideVideo(currentPointName.value)
|
|
|
step.value = 2
|
|
|
loading.value = false;
|
|
|
+ // 首次拍摄完成后打开预览用于检查镜头
|
|
|
+ if (!isFirstShow) {
|
|
|
+ isFirstShow = true
|
|
|
+ setTimeout(() => showVideo(currentPointName.value), 100)
|
|
|
+ }
|
|
|
}else {
|
|
|
loading.value = false;
|
|
|
+ console.log('_smart_shooter_photo_take');
|
|
|
showVideo(currentPointName.value)
|
|
|
if(result.code !== 0 && result.msg) ElMessage.error(result.msg)
|
|
|
}
|
|
|
@@ -301,11 +365,16 @@ clientStore.ipc.on(icpList.socket.message+'_run_mcu_single', async (event, resul
|
|
|
|
|
|
if(result.code === 0 && result.data?.file_path){
|
|
|
imageTplPath.value = result.data?.file_path
|
|
|
- hideVideo(currentPointName.value)
|
|
|
step.value = 2
|
|
|
loading.value = false;
|
|
|
+ // 首次拍摄完成后打开预览用于检查镜头
|
|
|
+ if (!isFirstShow) {
|
|
|
+ isFirstShow = true
|
|
|
+ setTimeout(() => showVideo(currentPointName.value), 100)
|
|
|
+ }
|
|
|
}else {
|
|
|
loading.value = false;
|
|
|
+ console.log('_run_mcu_single');
|
|
|
showVideo(currentPointName.value)
|
|
|
if(result.code !== 0 && result.msg) ElMessage.error(result.msg)
|
|
|
}
|
|
|
@@ -328,7 +397,6 @@ clientStore.ipc.on(icpList.socket.message+'_run_mcu_single', async (event, resul
|
|
|
|
|
|
const exampleImage = ref('https://huilimaimg.cnhqt.com/frontend/zhihuiyin/demo.jpg?x-oss-process=image/resize,w_400')
|
|
|
onMounted(async ()=>{
|
|
|
- if(isSetting.value) showVideo()
|
|
|
await configInfoStore.getAppConfig()
|
|
|
if(configInfoStore.appConfig.controlType === "SmartShooter"){
|
|
|
preview.value = configInfoStore.appConfig.userDataPath + "\\preview\\liveview.png"
|
|
|
@@ -341,6 +409,8 @@ onMounted(async ()=>{
|
|
|
* 页面卸载时移除所有事件监听器。
|
|
|
*/
|
|
|
onBeforeUnmount(() => {
|
|
|
+ clearPreviewInterval()
|
|
|
+ console.log('onBeforeUnmount');
|
|
|
hideVideo(currentPointName.value)
|
|
|
clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
|
|
|
clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
|