浏览代码

修改上传逻辑

lex 1 年之前
父节点
当前提交
f295f718e6

+ 15 - 4
src/views/classList/index.tsx

@@ -271,15 +271,26 @@ export default defineComponent({
                   )}
 
                   {!(row.preStudentNum > 0) ? (
-                    <p
-                      style={{ color: '#EA4132', cursor: 'pointer' }}
+                    <NButton
+                      disabled={!row.upgradeFlag}
+                      type="error"
+                      color="#EA4132"
+                      text
                       onClick={() => {
                         state.removeVisiable = true;
                         state.removeRow = row;
                       }}>
                       删除
-                    </p>
-                  ) : null}
+                    </NButton>
+                  ) : // <p
+                  //   style={{ color: '#EA4132', cursor: 'pointer' }}
+                  //   onClick={() => {
+                  //     state.removeVisiable = true;
+                  //     state.removeRow = row;
+                  //   }}>
+                  //   删除
+                  // </p>
+                  null}
                   {row.imGroupId ? null : (
                     <NButton
                       type="primary"

+ 24 - 13
src/views/natural-resources/components/my-resources/save-modal/index.tsx

@@ -210,25 +210,36 @@ export default defineComponent({
       btnLoading.value = false;
     };
     const getVideoMsg = (file: any) => {
-      return new Promise(resolve => {
+      return new Promise((resolve, reject) => {
         // let dataURL = '';
         const videoElement = document.createElement('video');
         videoElement.currentTime = 1;
         videoElement.src = URL.createObjectURL(file);
-        videoElement.addEventListener('loadeddata', function () {
-          const canvas: any = document.createElement('canvas'),
-            width = videoElement.videoWidth, //canvas的尺寸和图片一样
-            height = videoElement.videoHeight;
-          canvas.width = width;
-          canvas.height = height;
-          canvas.getContext('2d').drawImage(videoElement, 0, 0, width, height); //绘制canvas
-          // dataURL = canvas.toDataURL('image/jpeg'); //转换为base64
-          // console.log(canvas);
-          canvas.toBlob((blob: any) => {
-            // console.log(blob);
-            resolve(blob);
+        videoElement.addEventListener('loadedmetadata', function () {
+          console.log('loaded in');
+
+          // Listen for 'canplay' to ensure the video is ready for frame capture
+          videoElement.addEventListener('canplay', function () {
+            console.log('Video can play');
+            const canvas: any = document.createElement('canvas'),
+              width = videoElement.videoWidth,
+              height = videoElement.videoHeight;
+
+            canvas.width = width;
+            canvas.height = height;
+            canvas
+              .getContext('2d')
+              .drawImage(videoElement, 0, 0, width, height);
+
+            canvas.toBlob((blob: any) => {
+              resolve(blob);
+            });
           });
         });
+        videoElement.addEventListener('error', function (e) {
+          console.error('Error loading video:', e);
+          reject(e);
+        });
       });
     };
 

+ 1 - 1
src/views/natural-resources/components/my-resources/upload-modal/index.tsx

@@ -91,7 +91,7 @@ export default defineComponent({
           break;
         case 'PPT':
           typeImg = iconPPT;
-          break;          
+          break;
       }
       return typeImg;
     };