From 8bc1e13641e9f172e7bdc12abc054c82b565324e Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Fri, 07 Jan 2022 10:23:27 +0800
Subject: [PATCH] +

---
 src/store/modules/mobile.js |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/store/modules/mobile.js b/src/store/modules/mobile.js
index ac5f790..341e11c 100644
--- a/src/store/modules/mobile.js
+++ b/src/store/modules/mobile.js
@@ -45,6 +45,8 @@
     tilesetLayer: null, //2.5d模型
     usetowpointfive: null,
     tilesetLayer: null, //瀑布流
+
+    audioData: null, //语音
   },
   mutations: {
     MSET_VIEWER(state, viewer) {
@@ -300,7 +302,11 @@
       if (!state.MobileWindowsHide && state.popupsDom) {
         state.popupsDom.closeOur();
         commit("MSET_MOBILEWINDOWSHIDE", true);
-      }
+        if (state.audioData) {
+          state.audioData = null;
+          window.speechSynthesis.cancel();
+        }
+      } //cancel
     },
     CHANGETOC3({ state, commit }, data) {
       // //转换经纬度坐标 成世界坐标cartesian3
@@ -483,6 +489,16 @@
         },
       });
     },
+    MSET_GETAUDIO({ state, commit, dispatch }, val) {
+      if (state.audioData) {
+        state.audioData = null;
+        window.speechSynthesis.cancel();
+      } else {
+        state.audioData = new window.SpeechSynthesisUtterance();
+        state.audioData.text = val;
+        window.speechSynthesis.speak(state.audioData);
+      }
+    },
   },
 };
 

--
Gitblit v1.9.3