Przeglądaj źródła

叮当国医去除线路2

wjj 4 dni temu
rodzic
commit
826deb9085
1 zmienionych plików z 74 dodań i 30 usunięć
  1. 74 30
      src/views/course/videoResource/index.vue

+ 74 - 30
src/views/course/videoResource/index.vue

@@ -327,7 +327,7 @@
                       ></el-progress>
                       <span class="line-status-text">{{ Math.round(currentUploadProgress.line1) }}%</span>
                     </div>
-                    <div class="line-progress-item">
+                    <div v-if="!isDdgy" class="line-progress-item">
                       <span class="line-label">线路2:</span>
                       <el-progress
                         :percentage="currentUploadProgress.line2"
@@ -502,7 +502,7 @@
                   ></el-progress>
                   <span class="line-percentage">{{ Math.round(scope.row.uploadDetails.line1 || 0) }}%</span>
                 </div>
-                <div class="line-progress-row">
+                <div v-if="!isDdgy" class="line-progress-row">
                   <span class="line-label">线路2:</span>
                   <el-progress
                     :percentage="scope.row.uploadDetails.line2 || 0"
@@ -1017,7 +1017,9 @@ export default {
       isProcessingBatch: false, // 是否正在处理批次
       currentBatchIndex: 0, // 当前批次索引
       uploadCancellationTokens: new Map(), // Store cancellation functions by video ID
-      currentProject: process.env.VUE_APP_PROJECT
+      currentProject: process.env.VUE_APP_PROJECT,
+      // 叮当国医项目标识:该项目的视频不需要上传线路2
+      isDdgy: process.env.VUE_APP_PROJECT_CODE === 'ddgy' || process.env.VUE_APP_PROJECT_CODE === "'ddgy'"
     }
   },
   watch: {
@@ -1538,6 +1540,14 @@ export default {
     updateUploadProgress(key, value) {
       this.currentUploadProgress[key] = value;
 
+      // 叮当国医项目只上传线路1
+      if (this.isDdgy) {
+        this.currentUploadProgress.total = this.currentUploadProgress.line1Status === 'success'
+          ? 100
+          : Math.min(this.currentUploadProgress.line1, 99);
+        return;
+      }
+
       // 计算总进度:只有两个线路都成功才算100%
       if (this.currentUploadProgress.line1Status === 'success' && this.currentUploadProgress.line2Status === 'success') {
         this.currentUploadProgress.total = 100;
@@ -1566,20 +1576,37 @@ export default {
 
       try {
         await this.getFirstThumbnail(file, this.form);
-        const [line1Result, line2Result] = await Promise.allSettled([
-          this.uploadVideoToTxPcdn(file, this.form, options.onProgress),
-          //this.uploadVideoToHwObs(file, this.form, options.onProgress)
-          this.uploadVideoToHsy(file, this.form, options.onProgress)
-        ]);
 
-        const line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
-        const line2Success = line2Result.status === 'fulfilled' && line2Result.value.success;
+        let line1Success = false;
+        let line2Success = false;
 
-        if (line1Success && line2Success) {
+        if (this.isDdgy) {
+          // 叮当国医项目只上传线路1
+          const [line1Result] = await Promise.allSettled([
+            this.uploadVideoToTxPcdn(file, this.form, options.onProgress)
+          ]);
+          line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
+        } else {
+          const [line1Result, line2Result] = await Promise.allSettled([
+            this.uploadVideoToTxPcdn(file, this.form, options.onProgress),
+            //this.uploadVideoToHwObs(file, this.form, options.onProgress)
+            this.uploadVideoToHsy(file, this.form, options.onProgress)
+          ]);
+          line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
+          line2Success = line2Result.status === 'fulfilled' && line2Result.value.success;
+        }
+
+        if (line1Success && (this.isDdgy || line2Success)) {
           this.form.uploadStatus = 'success';
-          this.form.uploadProgress = { total: 100, line1: 100, line2: 100, line1Status: 'success', line2Status: 'success' };
+          this.form.uploadProgress = {
+            total: 100,
+            line1: 100,
+            line2: this.isDdgy ? 0 : 100,
+            line1Status: 'success',
+            line2Status: this.isDdgy ? 'pending' : 'success'
+          };
           this.currentUploadProgress.total = 100;
-          this.$message.success("视频上传完成!两个线路都上传成功");
+          this.$message.success(this.isDdgy ? "视频上传完成!" : "视频上传完成!两个线路都上传成功");
         } else {
           this.form.uploadStatus = 'failed';
           this.form.uploadProgress = {
@@ -1591,7 +1618,7 @@ export default {
           };
           const failedLines = [];
           if (!line1Success) failedLines.push('线路1');
-          if (!line2Success) failedLines.push('线路2');
+          if (!this.isDdgy && !line2Success) failedLines.push('线路2');
           this.$message.error(`视频上传失败!${failedLines.join('、')} 上传失败,请重试`);
         }
         this.form.fileName = file.name;
@@ -2002,36 +2029,44 @@ export default {
         // 获取封面
         await this.getFirstThumbnail(tempVideo.file, tempVideo);
 
-        // 并行上传到两个服务器
-        const [line1Result, line2Result] = await Promise.allSettled([
-          this.uploadVideoToTxPcdnBatch(tempVideo.file, tempVideo),
-          // this.uploadVideoToHwObsBatch(tempVideo.file, tempVideo)
-          this.uploadVideoToHSYBatch(tempVideo.file, tempVideo),
-
-        ]);
+        let line1Success = false;
+        let line2Success = false;
 
-        // 检查上传结果
-        const line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
-        const line2Success = line2Result.status === 'fulfilled' && line2Result.value.success;
+        if (this.isDdgy) {
+          // 叮当国医项目只上传线路1
+          const [line1Result] = await Promise.allSettled([
+            this.uploadVideoToTxPcdnBatch(tempVideo.file, tempVideo)
+          ]);
+          line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
+        } else {
+          // 并行上传到两个服务器
+          const [line1Result, line2Result] = await Promise.allSettled([
+            this.uploadVideoToTxPcdnBatch(tempVideo.file, tempVideo),
+            // this.uploadVideoToHwObsBatch(tempVideo.file, tempVideo)
+            this.uploadVideoToHSYBatch(tempVideo.file, tempVideo),
+          ]);
+          line1Success = line1Result.status === 'fulfilled' && line1Result.value.success;
+          line2Success = line2Result.status === 'fulfilled' && line2Result.value.success;
+        }
 
         const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
         if (index !== -1) {
-          if (line1Success && line2Success) {
+          if (line1Success && (this.isDdgy || line2Success)) {
             this.videoList[index].progress = 100;
             this.videoList[index].uploadStatus = 'success';
             this.videoList[index].uploadDetails.line1Status = 'success';
-            this.videoList[index].uploadDetails.line2Status = 'success';
+            this.videoList[index].uploadDetails.line2Status = this.isDdgy ? 'pending' : 'success';
             this.videoList[index].uploadDetails.line1 = 100;
-            this.videoList[index].uploadDetails.line2 = 100;
+            this.videoList[index].uploadDetails.line2 = this.isDdgy ? 0 : 100;
           } else {
             this.videoList[index].uploadStatus = 'failed';
             this.videoList[index].uploadDetails.line1Status = line1Success ? 'success' : 'failed';
-            this.videoList[index].uploadDetails.line2Status = line2Success ? 'success' : 'failed';
+            this.videoList[index].uploadDetails.line2Status = this.isDdgy ? 'pending' : (line2Success ? 'success' : 'failed');
             this.updateBatchProgress(index);
           }
         }
 
-        return { success: line1Success && line2Success, tempVideo };
+        return { success: line1Success && (this.isDdgy || line2Success), tempVideo };
       } catch (error) {
         const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
         if (index !== -1) {
@@ -2382,6 +2417,15 @@ export default {
         const item = this.videoList[index];
         const line1Progress = item.uploadDetails.line1 || 0;
         const line2Progress = item.uploadDetails.line2 || 0;
+
+        // 叮当国医项目只上传线路1
+        if (this.isDdgy) {
+          item.progress = item.uploadDetails.line1Status === 'success'
+            ? 100
+            : Math.min(line1Progress, 99);
+          return;
+        }
+
         // 只有两个线路都成功才算100%
         if (item.uploadDetails.line1Status === 'success' && item.uploadDetails.line2Status === 'success') {
           item.progress = 100;
@@ -2464,7 +2508,7 @@ export default {
 
       // 检查哪些线路需要重试
       const needRetryLine1 = uploadDetails.line1Status === 'failed' || uploadDetails.line1Status === 'pending';
-      const needRetryLine2 = uploadDetails.line2Status === 'failed' || uploadDetails.line2Status === 'pending';
+      const needRetryLine2 = this.isDdgy ? false : (uploadDetails.line2Status === 'failed' || uploadDetails.line2Status === 'pending');
 
       if (!needRetryLine1 && !needRetryLine2) {
         this.$message.info('所有线路都已上传成功,无需重试');