Browse Source

问答题语音修改逻辑

SanHQin 1 month ago
parent
commit
d46b410b2c

+ 1 - 1
dist/index.html

@@ -32,7 +32,7 @@
       width: 100%;
       background: #e6eaf0;
       font-family: '黑体';
-    }</style><link href=./static/css/app.8240784569c09a22297b3a0d237696c3.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.23ea04dc469b57e2b4f8.js></script><script type=text/javascript src=./static/js/vendor.dfc8a8e3392292c7b8e5.js></script><script type=text/javascript src=./static/js/app.4199cb34eb06c3d9a3d4.js></script></body></html><script>function stopSafari() {
+    }</style><link href=./static/css/app.2b1eabacf4e9f8386e5eb77615317913.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.23ea04dc469b57e2b4f8.js></script><script type=text/javascript src=./static/js/vendor.dfc8a8e3392292c7b8e5.js></script><script type=text/javascript src=./static/js/app.2cdf762fa5ed384c3df3.js></script></body></html><script>function stopSafari() {
     //阻止safari浏览器双击放大功能
     let lastTouchEnd = 0  //更新手指弹起的时间
     document.documentElement.addEventListener("touchstart", function (event) {

File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.2b1eabacf4e9f8386e5eb77615317913.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.2b1eabacf4e9f8386e5eb77615317913.css.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/workPage.1b882290277fe3c5d90b3ac9c6803cf6.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/workPage.1b882290277fe3c5d90b3ac9c6803cf6.css.map


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


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


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/manifest.23ea04dc469b57e2b4f8.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/workPage-manifest.2ece51fa34be51c8610a.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/workPage.81e72de0156f3f1c4694.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/workPage.81e72de0156f3f1c4694.js.map


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


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/workPage.bf763b78445aaf669236.js.map


+ 1 - 1
dist/workPage.html

@@ -1,4 +1,4 @@
-<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>工作页面 - CocoFlow</title><link rel=icon href=../static/logo.ico><link href=./static/css/workPage.44973c21a9b3c1c3890a7896df5c527c.css rel=stylesheet></head><body><noscript><strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script type=text/javascript src=./static/js/workPage-manifest.2ece51fa34be51c8610a.js></script><script type=text/javascript src=./static/js/workPage-vendor.0c46d4deebf81c844386.js></script><script type=text/javascript src=./static/js/workPage.bf763b78445aaf669236.js></script></body></html><script>function stopSafari() {
+<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>工作页面 - CocoFlow</title><link rel=icon href=../static/logo.ico><link href=./static/css/workPage.1b882290277fe3c5d90b3ac9c6803cf6.css rel=stylesheet></head><body><noscript><strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script type=text/javascript src=./static/js/workPage-manifest.2ece51fa34be51c8610a.js></script><script type=text/javascript src=./static/js/workPage-vendor.0c46d4deebf81c844386.js></script><script type=text/javascript src=./static/js/workPage.81e72de0156f3f1c4694.js></script></body></html><script>function stopSafari() {
     //阻止safari浏览器双击放大功能
     let lastTouchEnd = 0  //更新手指弹起的时间
     document.documentElement.addEventListener("touchstart", function (event) {

+ 41 - 11
src/components/pages/workPage/components/questionsAndAnswers.vue

@@ -84,7 +84,9 @@ export default {
       recordObj: {
         status: "0", // 0:默认  1:录音中  2:暂停,
         loading:false,
+        startTime:0, // 开始录音时间
       }
+
     };
   },
   watch: {
@@ -141,23 +143,51 @@ export default {
 
       iframe.contentWindow.ConversationTranscriber();
       this.recordObj.status = "1"
+      this.recordObj.startTime = new Date().getTime();
 
     },
     stopRecord() {
-      if(this.recordObj.status=='1' && !this.recordObj.loading){
-        let iframe = this.$refs["iframeRef"];
-        this.recordObj.loading = true;
-        iframe.contentWindow.window.document
-          .getElementById("scenarioStopButton")
-          .click();
-        iframe.contentWindow.onSessionStopped = (s, e) => {
-          this.recordObj.status = "0"
+      console.log()
+      if(this.recordObj.startTime!==0 && new Date().getTime() - this.recordObj.startTime < 2000){
+        return console.log("稍等")
+      }
+      // 判断浏览器是否有开启录音权限
+      navigator.permissions && navigator.permissions.query({ name: 'microphone' }).then(permissionStatus => {
+        if (permissionStatus.state !== "granted") {
+          // 没有开启录音权限,直接确定停止录音
+          this.recordObj.status = "0";
           this.recordObj.loading = false;
-          this.$message.success("已停止录音")
+          let iframe = this.$refs["iframeRef"];
           iframe.contentWindow.onSessionStopped = null;
           iframe.contentWindow.window.onRecognizedResult = null;
-        };
-      }
+
+          this.$message.success("未开启录音权限,已停止录音");
+          return;
+        }
+        // 有权限再判断状态
+        if(this.recordObj.status=='1' && !this.recordObj.loading){
+          let iframe = this.$refs["iframeRef"];
+          this.recordObj.loading = true;
+          iframe.contentWindow.window.document
+            .getElementById("scenarioStopButton")
+            .click();
+          iframe.contentWindow.onSessionStopped = (s, e) => {
+            this.recordObj.status = "0"
+            this.recordObj.loading = false;
+            this.$message.success("已停止录音")
+            iframe.contentWindow.onSessionStopped = null;
+            iframe.contentWindow.window.onRecognizedResult = null;
+          };
+        }
+      }).catch(() => {
+        // 浏览器不支持或异常,默认直接停止
+        this.recordObj.status = "0";
+        this.recordObj.loading = false;
+        let iframe = this.$refs["iframeRef"];
+        iframe.contentWindow.onSessionStopped = null;
+        iframe.contentWindow.window.onRecognizedResult = null;
+        this.$message.success("无法检测麦克风权限,已停止录音");
+      });
       // this.recordObj.status = "0"
     }
   },

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