Prechádzať zdrojové kódy

swkk:切换楼层时的reload方案修改为最直接的。以及先不要强制从首页进入那一套。

任一存 2 rokov pred
rodič
commit
54fccfa5f5
2 zmenil súbory, kde vykonal 12 pridanie a 23 odobranie
  1. 9 9
      src/router/index.js
  2. 3 14
      src/views/SwkkView.vue

+ 9 - 9
src/router/index.js

@@ -147,14 +147,14 @@ const router = new VueRouter({
   routes
 })
 
-router.beforeEach((to, from, next) => {
-  console.log('beforeEach: ', to, from, next)
-  // 强制每次都从首页进入
-  if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView' && !location.href.endsWith('autoReload=true')) {
-    next('/')
-  } else {
-    next()
-  }
-})
+// router.beforeEach((to, from, next) => {
+//   console.log('beforeEach: ', to, from, next)
+//   // 强制每次都从首页进入
+//   if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView') {
+//     next('/')
+//   } else {
+//     next()
+//   }
+// })
 
 export default router

+ 3 - 14
src/views/SwkkView.vue

@@ -233,13 +233,6 @@ export default {
     }
   },
   beforeCreate() {
-    // 因为本组件卸载后,kankan会出错,导致再次挂载本组件后kankan无法正常运行,需要reload,所以做此处理。
-    if (!location.href.endsWith('autoReload=true')) {
-      location.href += '&autoReload=true'
-      location.reload()
-    } else {
-      location.href = location.href.substring(0, location.href.length - 16)
-    }
   },
   beforeMount() {
   },
@@ -413,13 +406,9 @@ export default {
     ]),
     // 切换楼层
     changeFloor(val) {
-      this.$router.replace({
-        name: 'SwkkView',
-        query: { floor: val }
-      })
-      setTimeout(() => {
-        location.reload(true)
-      }, 200)
+      let newHref = location.href.substring(0, location.href.length - 1) + val
+      location.href = newHref
+      location.reload()
     },
     onClickAutoMoving() {
       if (this.isAutoMoving) {