From d3f0ff6001c34c9ac37e9e776f090f5a696a1361 Mon Sep 17 00:00:00 2001
From: jazz <jazzxhunter@163.com>
Date: 星期三, 13 十二月 2023 15:08:23 +0800
Subject: [PATCH] Merge branch 'xio_dev'

---
 src/router/index.js |   78 +++++++++++++++++++++++++++++++++++----
 1 files changed, 70 insertions(+), 8 deletions(-)

diff --git a/src/router/index.js b/src/router/index.js
index 347fa0c..2877b57 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -15,24 +15,86 @@
       path: '/',
       name: 'root',
       // component: () => import('@/pages/index')
-      component: () => import('@/pages/room/detail')
+      // component: () => import('@/pages/login/index')
+      component: () => import('@/pages/room/list')
     },
-    {
-      path: '/index',
-      name: 'index',
-      component: () => import('@/pages/index')
-    },
+    // {
+    //   path: '/login',
+    //   name: 'login',
+    //   component: () => import('@/pages/login/index')
+    // },
+    // {
+    //   path: '/index',
+    //   name: 'index',
+    //   component: () => import('@/pages/index')
+    // },
     {
       path: '/room/list',
       name: 'roomList',
-      component: () => import('@/pages/room/list')
+      component: () => import('@/pages/room/list'),
+      meta: { title: '娌荤枟瀹ゅ垪琛�', keepAlive: true }
     },
     {
       path: '/room/detail',
       name: 'roomDetail',
-      component: () => import('@/pages/room/detail')
+      component: () => import('@/pages/room/detail'),
+      meta: { title: '娌荤枟瀹よ鎯�', isPush: false }
     }
   ]
 })
 
+// 璺敱璺宠浆涔嬪墠
+// 鏄惁宸茬粡璺宠浆杩囨埧闂磋鎯�
+var isJumpeRoomDetail = localStorage.getItem('isJumpeRoomDetail')
+if (!isJumpeRoomDetail) {
+  localStorage.setItem('isJumpeRoomDetail', '0') // 鏄惁宸茬粡璺宠浆杩囨埧闂磋鎯�
+}
+
+// 璺宠浆鎴块棿璇︽儏
+function jumpRoomDetail() {
+  var roomId = localStorage.getItem('roomId')
+  var isJumpeRoomDetail = localStorage.getItem('isJumpeRoomDetail')
+  // 杩樻病璺宠浆涓旀湁localroomId鐨�
+  // console.log('7777777777777777777777777777', isJumpeRoomDetail, roomId)
+  if (isJumpeRoomDetail === '0' && roomId) {
+    localStorage.setItem('isJumpeRoomDetail', '1')
+    return { path: `./room/detail?id=${roomId}` }
+  } else {
+    localStorage.setItem('isJumpeRoomDetail', '1')
+    return true
+  }
+}
+
+// 璺敱璺宠浆涔嬪墠
+router.beforeEach(function(to, from, next) {
+  // var isJumpeRoomDetail = localStorage.getItem('isJumpeRoomDetail')
+  // console.log('999999999999999999999999999999999', to, from, isJumpeRoomDetail)
+  var nextPage = true // 榛樿true
+  // 鐩存帴杩涘叆棣栭〉锛堝垪琛ㄩ〉锛�
+  if ((to.name === 'root' || to.name === 'roomList') && !from.name) {
+    nextPage = jumpRoomDetail()
+  }
+  // 鐩存帴杩涘叆璇︽儏椤�
+  if (to.name === 'roomDetail' && !from.name) {
+    localStorage.setItem('isJumpeRoomDetail', '1')
+    if (to.query.id) {
+      localStorage.setItem('roomId', to.query.id)
+    }
+  }
+
+  // 鍒楄〃椤佃繘鍏ヨ鎯呴〉
+  if (to.name === 'roomDetail' && (from.name === 'root' || from.name === 'roomList')) {
+    localStorage.setItem('isJumpeRoomDetail', '0')
+    if (to.query.id) {
+      localStorage.setItem('roomId', to.query.id)
+    }
+  }
+
+  // 璇︽儏椤佃繑鍥炲垪琛�
+  if ((to.name === 'root' || to.name === 'roomList') && from.name === 'roomDetail') {
+    localStorage.setItem('isJumpeRoomDetail', '1')
+  }
+  next(nextPage)
+})
+
 export default router

--
Gitblit v1.8.0