From 5311b8ec19221a560aeca28262f14433b7781801 Mon Sep 17 00:00:00 2001 From: jxmanxk <312142485@qq.com> Date: 星期二, 23 一月 2024 17:43:53 +0800 Subject: [PATCH] update_202401231742_强制重置房间状态,不传治疗记录数组 --- src/router/index.js | 84 +++++++++++++++++++++++++++++++++++------- 1 files changed, 70 insertions(+), 14 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 932b582..2877b57 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -15,30 +15,86 @@ path: '/', name: 'root', // component: () => import('@/pages/index') - component: () => import('@/pages/login/index') - // component: () => import('@/pages/room/list') + // 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') + 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