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 | 82 ++++++++++++++++++++++++++++++++++------- 1 files changed, 68 insertions(+), 14 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 53ff605..2877b57 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -18,29 +18,83 @@ // component: () => import('@/pages/login/index') component: () => import('@/pages/room/list') }, - { - path: '/login', - name: 'login', - component: () => import('@/pages/login/index') - }, - { - 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') - // meta: { title: '娌荤枟瀹ゅ垪琛�', keepAlive: true } + component: () => import('@/pages/room/list'), + meta: { title: '娌荤枟瀹ゅ垪琛�', keepAlive: true } }, { path: '/room/detail', name: 'roomDetail', - component: () => import('@/pages/room/detail') - // meta: { title: '娌荤枟瀹よ鎯�', keepAlive: false } + 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