mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-08-29 16:52:43 +08:00
修复登陆后,点击浏览器返回按钮跳转错误页问题
This commit is contained in:
parent
94dfc524c7
commit
998861f36e
@ -1,6 +1,6 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { constantRoutes } from './routes'
|
||||
import { getCache } from '@/utils/cache'
|
||||
import { getCache, setCache } from '@/utils/cache'
|
||||
|
||||
import type { App } from 'vue'
|
||||
|
||||
@ -42,10 +42,18 @@ export const permissionRouter = () => {
|
||||
router.beforeEach((to, from, next) => {
|
||||
const token = getCache('token')
|
||||
const route = getCache('menuKey')
|
||||
console.log('route', route)
|
||||
console.log('token', token)
|
||||
|
||||
if (token !== 'no') {
|
||||
if (to.path === '/' || from.path === '/login') {
|
||||
next(route)
|
||||
if (route !== 'no') {
|
||||
next(route)
|
||||
} else {
|
||||
next('/dashboard')
|
||||
|
||||
setCache('menuKey', '/dashboard')
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { getCache, setCache } from '@/utils/cache'
|
||||
import { NEllipsis } from 'naive-ui'
|
||||
import RayIcon from '@/components/RayIcon/index'
|
||||
|
||||
import { getCache, setCache } from '@/utils/cache'
|
||||
|
||||
import type { MenuOption } from 'naive-ui'
|
||||
import type { RouteRecordRaw, RouteMeta } from 'vue-router'
|
||||
|
||||
@ -146,6 +147,9 @@ export const useMenu = defineStore('menu', () => {
|
||||
(newData) => {
|
||||
updateMenuKeyWhenRouteUpdate(newData)
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user