Commit cbea82d767bcf46256f60eb279233b73a41bd109

Authored by ww
1 parent fa48ff65

perf: camera manage add load faild message

@@ -12,12 +12,15 @@ @@ -12,12 +12,15 @@
12 import { useDrawer } from '/@/components/Drawer'; 12 import { useDrawer } from '/@/components/Drawer';
13 import { PageMode } from './config.data'; 13 import { PageMode } from './config.data';
14 import SvgIcon from '/@/components/Icon/src/SvgIcon.vue'; 14 import SvgIcon from '/@/components/Icon/src/SvgIcon.vue';
  15 + import { isDef } from '/@/utils/is';
  16 +
  17 + type CameraRecordItem = CameraRecord & { canPlay?: boolean };
15 18
16 const emit = defineEmits(['switchMode']); 19 const emit = defineEmits(['switchMode']);
17 const organizationIdTreeRef = ref(null); 20 const organizationIdTreeRef = ref(null);
18 const videoContainer = ref<Nullable<HTMLDivElement>>(null); 21 const videoContainer = ref<Nullable<HTMLDivElement>>(null);
19 const activeKey = ref(PageMode.SPLIT_SCREEN_MODE); 22 const activeKey = ref(PageMode.SPLIT_SCREEN_MODE);
20 - const cameraList = ref<CameraRecord[]>([]); 23 + const cameraList = ref<CameraRecordItem[]>([]);
21 const organizationId = ref<Nullable<string>>(null); 24 const organizationId = ref<Nullable<string>>(null);
22 const loading = ref(false); 25 const loading = ref(false);
23 const pagination = reactive({ 26 const pagination = reactive({
@@ -106,8 +109,18 @@ @@ -106,8 +109,18 @@
106 } 109 }
107 }; 110 };
108 111
109 - const handleVideoError = (event) => {  
110 - console.log('video happend error', event); 112 + const handleLoadStart = (record: CameraRecordItem) => {
  113 + const index = unref(cameraList).findIndex((item) => item.id === record.id);
  114 + setTimeout(() => {
  115 + ~index &&
  116 + !unref(cameraList).at(index)!.canPlay &&
  117 + (unref(cameraList).at(index)!.canPlay = false);
  118 + }, 10000);
  119 + };
  120 +
  121 + const handleLoadData = (record: CameraRecordItem) => {
  122 + const index = unref(cameraList).findIndex((item) => item.id === record.id);
  123 + ~index && (unref(cameraList).at(index)!.canPlay = true);
111 }; 124 };
112 125
113 const [registerDrawer, { openDrawer }] = useDrawer(); 126 const [registerDrawer, { openDrawer }] = useDrawer();
@@ -192,12 +205,19 @@ @@ -192,12 +205,19 @@
192 <div class="box-border w-full h-full p-3"> 205 <div class="box-border w-full h-full p-3">
193 <div class="bg-yellow-50 w-full h-full overflow-hidden relative video-container"> 206 <div class="bg-yellow-50 w-full h-full overflow-hidden relative video-container">
194 <VideoPlay 207 <VideoPlay
195 - @error="handleVideoError" 208 + @loadstart="handleLoadStart(item)"
  209 + @loadeddata="handleLoadData(item)"
196 v-bind="options" 210 v-bind="options"
197 :src="item.videoUrl" 211 :src="item.videoUrl"
198 :title="item.name" 212 :title="item.name"
199 /> 213 />
200 <div 214 <div
  215 + v-if="isDef(item.canPlay) && !item.canPlay"
  216 + class="video-container-error-msk absolute top-0 left-0 text-lg w-full h-full text-light-50 flex justify-center items-center z-50 bg-black"
  217 + >
  218 + 视频加载出错了!
  219 + </div>
  220 + <div
201 class="video-container-mask absolute top-0 left-0 z-50 text-lg w-full text-light-50 flex justify-center items-center" 221 class="video-container-mask absolute top-0 left-0 z-50 text-lg w-full text-light-50 flex justify-center items-center"
202 style="height: 100%; background-color: rgba(0, 0, 0, 0.5)" 222 style="height: 100%; background-color: rgba(0, 0, 0, 0.5)"
203 > 223 >
@@ -257,6 +277,12 @@ @@ -257,6 +277,12 @@
257 .video-container-mask { 277 .video-container-mask {
258 opacity: 1; 278 opacity: 1;
259 } 279 }
  280 +
  281 + .video-container-error-msk {
  282 + // opacity: 0;
  283 + // visibility: hidden;
  284 + color: #000;
  285 + }
260 } 286 }
261 } 287 }
262 </style> 288 </style>