zjs_project 3 周之前
父節點
當前提交
b3be376cc6
共有 2 個文件被更改,包括 26 次插入6 次删除
  1. 6 1
      src/pages/webgl_rxdz_test/webgl_rxdz_test.vue
  2. 20 5
      src/router/index.js

+ 6 - 1
src/pages/webgl_rxdz_test/webgl_rxdz_test.vue

@@ -1810,6 +1810,7 @@
 				if(gltf.spaceType==13){//楼梯不处理
 					return false
 				}
+                console.warn("***selectSpaceHandle0***",this.selectSpace)
 				if(this.selectSpace){
 					this.changeSpaceColor(this.selectSpace.spaceId,2);//取消上一个空间的颜色
 				}
@@ -1839,7 +1840,7 @@
                 this.locationHandle();
                 setTimeout( async ()=>{
                     let shottingImg = await this.shottingAction() + "?x-oss-process=image/auto-orient,1/quality,Q_46/format,jpg";//开始截图
-                    console.warn("***shottingImg***",shottingImg);
+                    console.warn("***shottingImg***",shottingImg,this.selectSpace);
                     setStorage('shottingImg', shottingImg);//把空间选择的数据存入本地缓存里面,方便后续使用
                     if(!this.curLayoutStruct){
                         this.curLayoutStruct = [this.curHouseObj]
@@ -1849,6 +1850,10 @@
                         curObj.shottingImg = shottingImg;
                         setStorage('curLayoutStruct', this.curLayoutStruct);//把楼层的数据存入缓存中
                     }
+                    if(this.selectSpace){
+                    	this.changeSpaceColor(this.selectSpace.spaceId,2);//取消上一个空间的颜色
+                        this.selectSpace = null;
+                    }
                     let gltf = this.lableItem.find(it=>it.spaceId==spaceId);
                     if(gltf){
                         this.goRoam(gltf)

+ 20 - 5
src/router/index.js

@@ -216,10 +216,25 @@ const router = new Router({
 // 	//如果存在用户账号信息|| to.query.uid
 // 	next();
 // })
-// //同一个路由跳转报错解决,NavigationDuplicated: Avoided redundant navigation to current location:
-// const originalPush = Router.prototype.push
-// Router.prototype.push = function push(location) {
-//     return  originalPush.call(this,location).catch(err=>err)
-// }
+// 添加路由守卫
+router.beforeEach((to, from, next) => {
+    // 如果目标路由是webgl_rxdz_test
+    if (to.name === 'webgl_rxdz_test') {
+        // 如果来源是webgl_rxdz_test_houseList,设置keepAlive为false
+        if (from.name === 'webgl_rxdz_test_houseList') {
+            to.meta.keepAlive = false;
+        } else {
+            // 其他来源保持默认的keepAlive为true
+            to.meta.keepAlive = true;
+        }
+    }
+    next();
+});
+
+// 解决路由重复导航的问题
+const originalPush = Router.prototype.push;
+Router.prototype.push = function push(location) {
+    return originalPush.call(this, location).catch(err => err);
+}
 
 export default router;