Sfoglia il codice sorgente

修改声音输出

yangg 6 mesi fa
parent
commit
e7d56c988b

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/chunk-eded1796.6ca98a6d.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.bce488f1.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-5c5b00e6.000d22d0.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-eded1796.3cd763e6.js


+ 13 - 4
src/views/login/aiIndex.vue

@@ -203,6 +203,7 @@ export default {
       phone: "",
       uploadFiles: [], // 存储上传的文件
       documents: [], // 新增:专门存储文档类型文件的数组
+      currentAudio: null, // 添加当前播放的音频实例
     };
   },
   mounted() {
@@ -243,11 +244,19 @@ export default {
   methods: {
     /* 播放音频 */
     playAudio(audioBase64) {
-      console.log(audioBase64);
-      // 创建音频元素
-      const audio = new Audio(audioBase64); // 播放音频
+      // 如果有正在播放的音频,先停止它
+      if (this.currentAudio) {
+        this.currentAudio.pause();
+        this.currentAudio = null;
+      }
+
+      // 创建新的音频实例并播放
+      const audio = new Audio(audioBase64);
+      this.currentAudio = audio;
+      
       audio.play().catch((error) => {
         console.error("Error playing audio:", error);
+        this.currentAudio = null;
       });
     },
     async handleFileUpload(event) {
@@ -1062,7 +1071,7 @@ textarea {
 .input-container textarea {
   width: 100%; /* 输入框占据所有可用空间 */
   padding: 10px;
-  margin-right: 10px; /* 与按��的间距 */
+  margin-right: 10px; /* 与按的间距 */
   box-sizing: border-box;
 }
 

Some files were not shown because too many files changed in this diff