liuyg
2022-01-07 04b6dba74c7051dcc0947b08a4f70b595672e3f2
src/store/modules/mobile.js
@@ -47,6 +47,7 @@
    tilesetLayer: null, //瀑布流
    audioData: null, //语音
    audioState: false, //语音状态
  },
  mutations: {
    MSET_VIEWER(state, viewer) {
@@ -298,13 +299,12 @@
      // })
      commit("MSET_POPUPDOM", popupsDom);
    },
    closeMobileWindowsDom({ state, commit }) {
    closeMobileWindowsDom({ state, commit, dispatch }) {
      if (!state.MobileWindowsHide && state.popupsDom) {
        state.popupsDom.closeOur();
        commit("MSET_MOBILEWINDOWSHIDE", true);
        if (state.audioData) {
          state.audioData = null;
          window.speechSynthesis.cancel();
          dispatch("MSET_GETAUDIOBEGIN", "notOpen");
        }
      } //cancel
    },
@@ -490,13 +490,23 @@
      });
    },
    MSET_GETAUDIO({ state, commit, dispatch }, val) {
      if (state.audioData) {
        state.audioData = null;
      state.audioData = new window.SpeechSynthesisUtterance();
      state.audioData.text = val;
      state.audioData.onstart = function (e) {
        state.audioState = true;
      };
      state.audioData.onend = function (event) {
        state.audioState = false;
      };
    },
    MSET_GETAUDIOBEGIN({ state, commit, dispatch }, val) {
      if (state.audioState) {
        window.speechSynthesis.cancel();
        state.audioState = false;
      } else {
        state.audioData = new window.SpeechSynthesisUtterance();
        state.audioData.text = val;
        window.speechSynthesis.speak(state.audioData);
        if (val != "notOpen") {
          window.speechSynthesis.speak(state.audioData);
        }
      }
    },
  },