From 5cfc31265862f2342666fa0dbbf84eb54a50c317 Mon Sep 17 00:00:00 2001
From: du <13220750630.163.com>
Date: 星期二, 15 四月 2025 15:17:21 +0800
Subject: [PATCH] 修改BUG

---
 easegen-front/src/views/chooseTemplate/index.vue       |   13 ++
 easegen-front/src/views/myCourse/index.vue             |   26 ++++
 easegen-front/src/views/chooseTemplate/audioSelect.vue |  208 ++++++++++++++++++++++++-----------------
 3 files changed, 152 insertions(+), 95 deletions(-)

diff --git a/easegen-front/src/views/chooseTemplate/audioSelect.vue b/easegen-front/src/views/chooseTemplate/audioSelect.vue
index ed9a0be..78d2521 100644
--- a/easegen-front/src/views/chooseTemplate/audioSelect.vue
+++ b/easegen-front/src/views/chooseTemplate/audioSelect.vue
@@ -7,76 +7,64 @@
     :close-on-click-modal="false"
   >
     <el-tabs v-model="activeName" @tab-change="handleClick">
-      <el-tab-pane :label="child.label" :name="child.value" v-for="(child,ind) in voiceTypeList" :key="ind">
-        <div class="language" v-if="activeName == 0">
+      <div class="language" v-if="activeName == 0">
           <span
             v-for="(item, index) in languageList"
             :key="index"
             :class="{ isActive: item.isActive }"
             @click="handleLanguage(item)"
-            >{{ item.label }}</span
-          >
-        </div>
-        <div class="language">
+          >{{ item.label }}</span>
+      </div>
+      <div class="language">
           <span
             v-for="(item, index) in audioType"
             :key="index"
             :class="{ isActive: item.isActive }"
             @click="handleAudio(item)"
-            >{{ item.label }}</span
+          >{{ item.label }}</span>
+      </div>
+      <div v-if="audioList && audioList.length > 0">
+        <div class="table-container">
+          <div
+            class="table-list"
+            :style="{ borderColor: item.isSelect ? '#0183f4' : '' }"
+            :class="{ isHover: item.isHover }"
+            v-for="(item, index) in audioList"
+            :key="index"
+            @mouseenter="handleMouseenter(item)"
+            @mouseleave="handleMouseleave(item)"
+            @click="handleSelect(item)"
           >
-        </div>
-        <div v-if="audioList && audioList.length > 0">
-          <div class="table-container">
-            <div
-              class="table-list"
-              :style="{ borderColor: item.isSelect ? '#0183f4' : '' }"
-              :class="{ isHover: item.isHover }"
-              v-for="(item, index) in audioList"
-              :key="index"
-              @mouseenter="handleMouseenter(item)"
-              @mouseleave="handleMouseleave(item)"
-              @click="handleSelect(item)"
-            >
-              <div class="item-head">
-                <img :src="item.avatarUrl" />
-                <!-- <div class="head-btn">楂樼骇</div> -->
-              </div>
-              <div class="item-name">
-                <span>{{ item.name }}</span>
-                <span>{{ item.introduction }}</span>
-              </div>
-              <img
-                class="play-img"
-                v-if="item.isHover && !item.isPlay"
-                src="@/assets/imgs/play.png"
-                alt=""
-                @click.stop="playAudio(item)"
-              />
-              <img
-                class="play-img"
-                v-if="item.isHover && item.isPlay"
-                src="@/assets/imgs/pause.png"
-                alt=""
-                @click.stop="pauseAudio(item)"
-              />
+            <div class="item-head">
+              <img :src="item.avatarUrl" />
             </div>
+            <div class="item-name">
+              <span>{{ item.name }}</span>
+              <span>{{ item.introduction }}</span>
+            </div>
+            <img
+              class="play-img"
+              v-if="item.isHover && !item.isPlay"
+              src="@/assets/imgs/play.png"
+              alt=""
+              @click.stop="playAudio(item)"
+            />
+            <img
+              class="play-img"
+              v-if="item.isHover && item.isPlay"
+              src="@/assets/imgs/pause.png"
+              alt=""
+              @click.stop="pauseAudio(item)"
+            />
           </div>
-          <!-- 鍒嗛〉 -->
-          <Pagination
-            :total="total"
-            v-model:page="queryParams.pageNo"
-            v-model:limit="queryParams.pageSize"
-            @pagination="getList"
-          />
         </div>
-        <div v-else class="nodata">
-          <img src="@/assets/imgs/nodata.png" alt="" />
-        </div>
-      </el-tab-pane>
+      </div>
+      <div v-else class="nodata">
+        <img src="@/assets/imgs/nodata.png" alt="" />
+      </div>
     </el-tabs>
     <template #footer>
-      <el-button @click="audioSelectVisible = false">{{t('common.cancel')}}</el-button>
+      <el-button @click="useOriginalSound">浣跨敤鍘熷0</el-button>
       <el-button type="primary" @click="submitForm">{{t('common.ok')}}</el-button>
     </template>
   </el-dialog>
@@ -99,9 +87,6 @@
     Reflect.set(item, "isActive", false);
   });
   languageList.value = list;
-  // selectLanguage.value = list[0];
-  // selectLanguage.value.isActive = true;
-  // 绉婚櫎榛樿閫変腑
   selectLanguage.value = { value: '' };
 };
 const audioType = ref();
@@ -115,9 +100,6 @@
   });
   audioType.value = list;
   audioTypeCustom.value = list;
-  // selectAudio.value = list[0];
-  // selectAudio.value.isActive = true;
-  // 绉婚櫎榛樿閫変腑
   selectAudio.value = { value: '' };
 };
 //鑾峰彇澹伴煶绫诲埆
@@ -152,9 +134,7 @@
       item.isPlay = false;
       item.isSelect = false;
     });
-    console.log(data.list)
     audioList.value = data.list;
-
     total.value = data.total;
   } finally {
     loading.value = false;
@@ -162,8 +142,8 @@
 };
 //澹伴煶妯″瀷绫诲瀷杩囨护
 const handleClick = (item)=>{
-   activeName.value = item;
-   getList();
+  activeName.value = item;
+  getList();
 }
 //璇█杩囨护
 const handleLanguage = (item) => {
@@ -194,12 +174,10 @@
 };
 const handleMouseleave = (item) => {
   item.isHover = false;
-  item.isPlay = false;
 };
 //閫夋嫨澹伴煶妯″瀷
 const selectList = ref();
 const handleSelect = (item) => {
-  console.log(item)
   selectList.value = [item];
   audioList.value.forEach((child) => {
     if (child.id == item.id) {
@@ -220,30 +198,84 @@
     audioSelectVisible.value = false;
   }
 };
-//鎾斁澹伴煶
-const currentAudio = ref();
-const playAudio = async (item) => {
-  item.isPlay = !item.isPlay;
-  await nextTick();
-  // currentAudio.value[0].play();
-  if (currentAudio.value && currentAudio.value.auditionUrl === item.auditionUrl) {
-    currentAudio.value.play();
-  } else {
-    currentAudio.value = new Audio(item.auditionUrl);
-    currentAudio.value.play();
+
+// 浣跨敤鍘熷0
+const useOriginalSound = () => {
+  // 娓呴櫎閫変腑鐨勯煶棰�
+  selectList.value = null;
+
+  // 娓呴櫎鍒楄〃涓墍鏈夐�変腑鐘舵��
+  if (audioList.value) {
+    audioList.value.forEach(item => {
+      item.isSelect = false;
+    });
+  }
+
+  // 鍋滄褰撳墠鎾斁鐨勯煶棰�
+  if (currentAudio.value) {
+    currentAudio.value.pause();
+    currentAudio.value = null;
+  }
+
+  // 閲嶇疆褰撳墠鎾斁鐘舵��
+  if (currentlyPlaying.value) {
+    currentlyPlaying.value.isPlay = false;
+    currentlyPlaying.value = null;
+  }
+
+  // 鍏抽棴瀵硅瘽妗�
+  audioSelectVisible.value = false;
+
+  // 瑙﹀彂浜嬩欢閫氱煡鐖剁粍浠朵娇鐢ㄥ師澹�
+  emit('success', undefined);
+};
+
+// 闊抽绠$悊
+const currentAudio = ref<HTMLAudioElement | null>(null);
+const currentlyPlaying = ref<any>(null);
+
+const playAudio = async (item: any) => {
+  // 濡傛灉鐐瑰嚮鐨勬槸褰撳墠姝e湪鎾斁鐨勯」鐩紝鍒欐殏鍋�
+  if (currentlyPlaying.value && currentlyPlaying.value.id === item.id) {
+    pauseAudio(item);
+    return;
+  }
+
+  // 鍋滄褰撳墠鎾斁鐨勯煶棰�
+  if (currentAudio.value) {
+    currentAudio.value.pause();
+    currentAudio.value = null;
+  }
+
+  // 濡傛灉涔嬪墠鏈夋挱鏀剧殑椤圭洰锛岄噸缃叾鐘舵��
+  if (currentlyPlaying.value) {
+    currentlyPlaying.value.isPlay = false;
+  }
+
+  // 璁剧疆鏂扮殑鎾斁椤圭洰
+  currentlyPlaying.value = item;
+  item.isPlay = true;
+
+  // 鍒涘缓鏂扮殑闊抽瀵硅薄骞舵挱鏀�
+  currentAudio.value = new Audio(item.auditionUrl);
+  currentAudio.value.play();
+
+  // 娣诲姞鎾斁缁撴潫浜嬩欢鐩戝惉
+  currentAudio.value.addEventListener('ended', () => {
+    item.isPlay = false;
+    currentlyPlaying.value = null;
+    currentAudio.value = null;
+  });
+};
+
+const pauseAudio = (item: any) => {
+  if (currentAudio.value && currentlyPlaying.value && currentlyPlaying.value.id === item.id) {
+    currentAudio.value.pause();
+    item.isPlay = false;
+    currentlyPlaying.value = null;
   }
 };
-const pauseAudio = async (item) => {
-  item.isPlay = !item.isPlay;
-  await nextTick();
-  // currentAudio.value[0].pause();
-  if (currentAudio.value && currentAudio.value.auditionUrl === item.auditionUrl) {
-    currentAudio.value.pause();
-  } else {
-    currentAudio.value = new Audio(item.auditionUrl);
-    currentAudio.value.pause();
-  }
-};
+
 const open = () => {
   audioSelectVisible.value = true
 }
diff --git a/easegen-front/src/views/chooseTemplate/index.vue b/easegen-front/src/views/chooseTemplate/index.vue
index 3afaf25..b6b6ec1 100644
--- a/easegen-front/src/views/chooseTemplate/index.vue
+++ b/easegen-front/src/views/chooseTemplate/index.vue
@@ -1303,12 +1303,19 @@
   audioSelect.value.open()
 }
 const selectAudio = (data) => {
+  console.log(data)
   audioSelectData.value = data
   // selectPPT.value.selectAudio = data[0]
   // 閬嶅巻鎵�鏈夊満鏅紝搴旂敤鐩稿悓鐨勫0闊虫ā鍨�
-  PPTArr.value.forEach((scene) => {
-    scene.selectAudio = data[0]
-  })
+  if (data==undefined){
+    selectPPT.value.selectAudio.name=''
+    return {}
+  }else {
+    PPTArr.value.forEach((scene) => {
+      scene.selectAudio = data[0]
+    })
+  }
+
 }
 //鐢熸垚璇剧▼id
 const coursesCreate = () => {
diff --git a/easegen-front/src/views/myCourse/index.vue b/easegen-front/src/views/myCourse/index.vue
index e3b6893..ed0ce38 100644
--- a/easegen-front/src/views/myCourse/index.vue
+++ b/easegen-front/src/views/myCourse/index.vue
@@ -40,10 +40,16 @@
 <!--          {{ formatDuration(scope.row.duration) }}-->
 <!--        </template>-->
 <!--      </el-table-column>-->
-      <el-table-column label="鎺掗槦涓暟" align="center" prop="pos" />
+      <el-table-column label="鎺掗槦涓暟" align="center" prop="pos" >
+        <template #default="scope">
+         <span v-if="scope.row.pos==0">瑙嗛姝e湪鍚堟垚...</span>
+          <span v-else>{{ scope.row.pos }}</span>
+        </template>
+      </el-table-column>
       <el-table-column label="杩涘害" align="center" prop="progressVideo">
         <template #default="scope">
-          {{ calculateProgress(scope.row.progressVideo) }}%
+          <span v-if="scope.row.status==2">100%</span>
+          <span v-else>{{ calculateProgress(scope.row.progressVideo) }}%</span>
         </template>
       </el-table-column>
 
@@ -448,17 +454,25 @@
     subtitleDialogVisible.value = true
     subtitleForm.videoId = videoId
     const videoDetail = await pptTemplateApi.myCourseDetail(videoId)
-    console.log('瑙嗛璇︽儏:', videoDetail)
+
+
     // 绔嬪嵆鑾峰彇瑙嗛璇︽儏妫�鏌ュ瓧骞曠姸鎬�
     subtitleForm.subtitlesAddStatus=videoDetail.subtitlesAddStatus
     if (videoDetail.subtitlesAddStatus === 2) {
       subtitleForm.videoUrl = videoDetail.videoUrl || ''
+      generating.value=false
+      polling.value=false
 
+    }else if (videoDetail.subtitlesAddStatus === 1) {
+      generating.value=true
+      polling.value=true
     }
     if (videoDetail.subtitlesStatus === 2) { // 2 琛ㄧず瀛楀箷宸茬敓鎴�
       if (videoDetail.subtitlesUrl) {
         subtitleForm.subtitlesUrl = videoDetail.subtitlesUrl
         subtitleForm.courseName=videoDetail.courseName
+        generating.value=false
+        polling.value=false
         try {
           // 灏濊瘯浠嶶RL鑾峰彇瀛楀箷鍐呭
           const response = await fetch(videoDetail.subtitlesUrl)
@@ -477,15 +491,19 @@
         // 鐩存帴浣跨敤瀛楀箷鍐呭
         subtitleForm.content = videoDetail.subtitlesContent
       }
-    } else {
+    } else if (videoDetail.subtitlesStatus === 3) {
       // 瀛楀箷鏈敓鎴愭垨鐢熸垚澶辫触锛屾竻绌哄唴瀹�
       subtitleForm.content = ''
+    }else if (videoDetail.subtitlesStatus === 1) {
+      generating.value=true
+      polling.value=true
     }
   } catch (error) {
     console.error('鑾峰彇瑙嗛璇︽儏澶辫触:', error)
     message.error('鑾峰彇瑙嗛璇︽儏澶辫触锛岃閲嶈瘯')
     subtitleDialogVisible.value = false
   }
+  console.log('瑙嗛璇︽儏:', generating)
 }
 
 // 閲嶇疆瀛楀箷琛ㄥ崟

--
Gitblit v1.9.3