浏览代码

swkk页面reload时保持isMuted状态

任一存 2 年之前
父节点
当前提交
962d08f993
共有 3 个文件被更改,包括 17 次插入9 次删除
  1. 4 0
      src/store/index.js
  2. 1 2
      src/views/HomeView.vue
  3. 12 7
      src/views/SwkkView.vue

+ 4 - 0
src/store/index.js

@@ -53,6 +53,10 @@ export default new Vuex.Store({
       state._isMutedBackup = state.isMuted
       console.log('toggleMute result: ', state.isMuted)
     },
+    setIsMuted(state, value) {
+      state.isMuted = value
+      state._isMutedBackup = value
+    },
     mustMute(state) {
       state._isMutedBackup = state.isMuted
       state.isMuted = true

+ 1 - 2
src/views/HomeView.vue

@@ -70,7 +70,7 @@
     <div class="button-group">
       <router-link
         class="router-link"
-        to="./swkk-view?floor=1"
+        :to="`./swkk-view?floor=1&isMuted=${isMuted}`"
       >
         <img
           src="@/assets/images/button-to-scenes.png"
@@ -150,7 +150,6 @@ export default {
       this.$nextTick(() => {
         let dom = document.querySelector("#VideoDom")
         if (dom) {
-          console.log('找到了视频')
           dom.play()
           dom.addEventListener('canplaythrough', () => {
             dom.play()

+ 12 - 7
src/views/SwkkView.vue

@@ -238,9 +238,18 @@ export default {
   beforeCreate() {
   },
   beforeMount() {
+    console.log('sdfsdfsdf', this.$route.query)
+    if (this.$route.query.isMuted === 'false') {
+      this.setIsMuted(false)
+      let newHref = location.href.substring(0, location.href.length - 14)
+      location.href = newHref
+    } else if (this.$route.query.isMuted === 'true') {
+      this.setIsMuted(true)
+      let newHref = location.href.substring(0, location.href.length - 13)
+      location.href = newHref
+    }
   },
   mounted() {
-    // setTimeout(() => {
     this.$msgCenter.publish('show-loading')
     let floor = this.$route.query.floor
     this.floor = floor
@@ -249,8 +258,6 @@ export default {
     else if (floor === "2") sceneCode = process.env.VUE_APP_SCENE_CODE_FLOOR_2
     console.assert(sceneCode, 'no sceneCode!')
 
-    // 不等一秒,就会因为use了小地图而卡死?
-    // setTimeout(() => {
     let kankan = new KanKan({
       dom: ".swkk-wrap",
       num: sceneCode,
@@ -421,8 +428,6 @@ export default {
 
     kankan.render()
     this.kankan = kankan
-    // }, 1000)
-    // }, 500)
   },
   beforeDestroy() {
     this.stopAutoMoving()
@@ -431,10 +436,10 @@ export default {
     ...globalMapMutations([
       'mustMute',
       'cancelMustMute',
+      'setIsMuted',
     ]),
-    // 切换楼层
     changeFloor(val) {
-      let newHref = location.href.substring(0, location.href.length - 1) + val
+      let newHref = location.href.substring(0, location.href.length - 1) + val + `&isMuted=${this.isMuted}`
       location.href = newHref
       location.reload()
     },