Commit cbea82d767bcf46256f60eb279233b73a41bd109
1 parent
fa48ff65
perf: camera manage add load faild message
Showing
1 changed file
with
30 additions
and
4 deletions
... | ... | @@ -12,12 +12,15 @@ |
12 | 12 | import { useDrawer } from '/@/components/Drawer'; |
13 | 13 | import { PageMode } from './config.data'; |
14 | 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 | 19 | const emit = defineEmits(['switchMode']); |
17 | 20 | const organizationIdTreeRef = ref(null); |
18 | 21 | const videoContainer = ref<Nullable<HTMLDivElement>>(null); |
19 | 22 | const activeKey = ref(PageMode.SPLIT_SCREEN_MODE); |
20 | - const cameraList = ref<CameraRecord[]>([]); | |
23 | + const cameraList = ref<CameraRecordItem[]>([]); | |
21 | 24 | const organizationId = ref<Nullable<string>>(null); |
22 | 25 | const loading = ref(false); |
23 | 26 | const pagination = reactive({ |
... | ... | @@ -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 | 126 | const [registerDrawer, { openDrawer }] = useDrawer(); |
... | ... | @@ -192,12 +205,19 @@ |
192 | 205 | <div class="box-border w-full h-full p-3"> |
193 | 206 | <div class="bg-yellow-50 w-full h-full overflow-hidden relative video-container"> |
194 | 207 | <VideoPlay |
195 | - @error="handleVideoError" | |
208 | + @loadstart="handleLoadStart(item)" | |
209 | + @loadeddata="handleLoadData(item)" | |
196 | 210 | v-bind="options" |
197 | 211 | :src="item.videoUrl" |
198 | 212 | :title="item.name" |
199 | 213 | /> |
200 | 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 | 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 | 222 | style="height: 100%; background-color: rgba(0, 0, 0, 0.5)" |
203 | 223 | > |
... | ... | @@ -257,6 +277,12 @@ |
257 | 277 | .video-container-mask { |
258 | 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 | 288 | </style> | ... | ... |