feat: 新增登录重定向之前被拦截的页面

This commit is contained in:
lilinyuan
2024-04-29 09:58:18 +08:00
parent 24dfaac98a
commit 8c1d2eeabe
2 changed files with 18 additions and 0 deletions

View File

@@ -188,6 +188,7 @@ router.beforeEach(async (to, form, next) => {
next() next()
NProgress.done() NProgress.done()
} else { } else {
sessionStorage.setItem('toView', JSON.stringify(to))
next({path: '/login'}) next({path: '/login'})
} }
} else { } else {

View File

@@ -51,6 +51,9 @@
import * as echarts from 'echarts' import * as echarts from 'echarts'
import homeImage from "@/assets/home/home.png" import homeImage from "@/assets/home/home.png"
import coffee from "@/assets/home/coffee.png" import coffee from "@/assets/home/coffee.png"
import { useRouter } from 'vue-router';
const router = useRouter()
const list=ref([ const list=ref([
{ {
title: '在线用户量', title: '在线用户量',
@@ -172,8 +175,22 @@ const init = () => {
data.pieCharts = echarts.init(document.getElementById('pie3')).setOption(pieOption) data.pieCharts = echarts.init(document.getElementById('pie3')).setOption(pieOption)
} }
const redirectView = () => {
const toView = sessionStorage.getItem('toView')
console.log(toView, 'toView');
toView ?
router.push({
path: JSON.parse(toView).path,
query: {
...JSON.parse(toView).query
}
}) :
null
}
onMounted(() => { onMounted(() => {
init() init()
redirectView()
}) })
window.addEventListener('resize', () => { window.addEventListener('resize', () => {