From 1fa546e22f9b913868cdeb5a84f3fc3c4f500ffb Mon Sep 17 00:00:00 2001 From: jazz <jazzxhunter@163.com> Date: 星期四, 21 十二月 2023 19:39:48 +0800 Subject: [PATCH] update_202312211937_增加卸麻通知和称谓显示 --- 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