SanHQin преди 6 месеца
родител
ревизия
e008232aee
променени са 2 файла, в които са добавени 60 реда и са изтрити 33 реда
  1. 42 22
      src/components/pages/aiAddCourse/aiBoxRight.vue
  2. 18 11
      src/components/pages/test/check/aiBoxRight.vue

+ 42 - 22
src/components/pages/aiAddCourse/aiBoxRight.vue

@@ -226,7 +226,13 @@
         :disabled="isVoice"
         ref="textareaRef"
         v-model.trim="courseText"
-        :placeholder="isVoice ? isTalk?'':'点击按钮开始录音' : '在此输入您想了解的内容'"
+        :placeholder="
+          isVoice
+            ? isTalk
+              ? ''
+              : '点击按钮开始录音'
+            : '在此输入您想了解的内容'
+        "
       ></textarea>
 
       <span
@@ -341,7 +347,7 @@
         终止
       </div>
     </div>
-		<iframe
+    <iframe
       allow="camera *; microphone *;display-capture;midi;encrypted-media;"
       src="https://beta.cloud.cocorobo.cn/browser/public/index.html"
       ref="iiframe"
@@ -869,7 +875,11 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
           let history = [];
           if (this.continuous) {
             this.array.forEach((i, index) => {
-              if (i.content) history.push({ role: "user", content: index == this.array.length - 1 ? message : i.content  });
+              if (i.content)
+                history.push({
+                  role: "user",
+                  content: index == this.array.length - 1 ? message : i.content
+                });
               if (i.aiContent)
                 history.push({ role: "assistant", content: i.aiContent });
             });
@@ -1030,7 +1040,10 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
     async getUserName() {
       let params = { uid: this.userid };
       try {
-        let res = await this.ajax.get(this.$store.state.api + "getUser", params);
+        let res = await this.ajax.get(
+          this.$store.state.api + "getUser",
+          params
+        );
         this.username = res.data[0][0].name;
       } catch (err) {
         console.error(err);
@@ -1039,10 +1052,10 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
     //保存消息
     async insertChat(_uid) {
       let _data = this.array.find(i => i.uid == _uid);
-      this.saveUid = ''
-      this.faloading = false
-      if(!this.username){
-        await this.getUserName()
+      this.saveUid = "";
+      this.faloading = false;
+      if (!this.username) {
+        await this.getUserName();
       }
       if (!_data) return;
       let params = {
@@ -1355,7 +1368,7 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
       this.isVoice = flag;
     },
     startVoice() {
-			let iiframe = this.$refs["iiframe"];
+      let iiframe = this.$refs["iiframe"];
       iiframe.contentWindow.window.document.getElementById(
         "languageOptions"
       ).selectedIndex = 2; //普通话
@@ -1367,20 +1380,27 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
         if (_msg) this.courseText += _msg;
       };
     },
-		stopVoice(){
-			if (!this.isTalk) return this.$message.info("请先开始录音");
-      let iiframe = this.$refs["iiframe"];
-      iiframe.contentWindow.window.document
-        .getElementById("scenarioStopButton")
-        .click();
-      iiframe.contentWindow.onSessionStopped = (s, e) => {
+    stopVoice() {
+      try {
+        if (!this.isTalk) return this.$message.info("请先开始录音");
+        let iiframe = this.$refs["iiframe"];
+        iiframe.contentWindow.window.document
+          .getElementById("scenarioStopButton")
+          .click();
+        iiframe.contentWindow.onSessionStopped = (s, e) => {
+          this.isTalk = false;
+          if (this.courseText) {
+            this.addContent();
+          }
+        };
+      } catch (error) {
+        console.log(error);
         this.isTalk = false;
-				if(this.courseText){
-					this.addContent();
-				}
-        
-      };
-		}
+        if (this.courseText) {
+          this.addContent();
+        }
+      }
+    }
   },
   computed: {
     pan() {

+ 18 - 11
src/components/pages/test/check/aiBoxRight.vue

@@ -1302,18 +1302,25 @@ export default {
       };
     },
 		stopVoice(){
-			if (!this.isTalk) return this.$message.info("请先开始录音");
-      let iiframe = this.$refs["iiframe"];
-      iiframe.contentWindow.window.document
-        .getElementById("scenarioStopButton")
-        .click();
-      iiframe.contentWindow.onSessionStopped = (s, e) => {
+			try {
+        if (!this.isTalk) return this.$message.info("请先开始录音");
+        let iiframe = this.$refs["iiframe"];
+        iiframe.contentWindow.window.document
+          .getElementById("scenarioStopButton")
+          .click();
+        iiframe.contentWindow.onSessionStopped = (s, e) => {
+          this.isTalk = false;
+          if (this.courseText) {
+            this.addContent();
+          }
+        };
+      } catch (error) {
+        console.log(error);
         this.isTalk = false;
-				if(this.courseText){
-					this.addContent();
-				}
-        
-      };
+        if (this.courseText) {
+          this.addContent();
+        }
+      }
 		}
   },
   computed: {