From 0e11d74e0e2d664d6104636a75558c31ead2448c Mon Sep 17 00:00:00 2001
From: long <515897141@qq.com>
Date: 星期四, 01 二月 2024 15:04:41 +0800
Subject: [PATCH] 样式调整

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

diff --git a/src/router/index.js b/src/router/index.js
index 2781380..2877b57 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -14,24 +14,87 @@
     {
       path: '/',
       name: 'root',
-      component: () => import('@/pages/index')
+      // component: () => import('@/pages/index')
+      // 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