Explorar o código

天机 video.length > 0 判断

visuddhinanda %!s(int64=2) %!d(string=hai) anos
pai
achega
9295bd90e8
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      dashboard/src/components/template/Wbw/WbwVideoButton.tsx

+ 4 - 1
dashboard/src/components/template/Wbw/WbwVideoButton.tsx

@@ -19,6 +19,9 @@ const WbwVideoButtonWidget = ({ video }: IWidget) => {
   const [curr, setCurr] = useState(0);
   const [curr, setCurr] = useState(0);
 
 
   useEffect(() => {
   useEffect(() => {
+    if (!video || video.length === 0) {
+      return;
+    }
     const url = `/v2/attachment/${video[curr].videoId}`;
     const url = `/v2/attachment/${video[curr].videoId}`;
     console.info("url", url);
     console.info("url", url);
     get<IAttachmentResponse>(url).then((json) => {
     get<IAttachmentResponse>(url).then((json) => {
@@ -29,7 +32,7 @@ const WbwVideoButtonWidget = ({ video }: IWidget) => {
     });
     });
   }, [curr, video]);
   }, [curr, video]);
 
 
-  return video ? (
+  return video && video.length > 0 ? (
     <VideoModal src={url} type={video[0].type} trigger={<VideoIcon />} />
     <VideoModal src={url} type={video[0].type} trigger={<VideoIcon />} />
   ) : (
   ) : (
     <></>
     <></>