From 8c1d2eeabe41efd4b04641b8c9be34ced4e6fee7 Mon Sep 17 00:00:00 2001 From: lilinyuan <1084668738@qq.com> Date: Mon, 29 Apr 2024 09:58:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91=E4=B9=8B=E5=89=8D=E8=A2=AB=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E7=9A=84=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 1 + src/views/home/index.vue | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index 9c643ac..a4118d1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -188,6 +188,7 @@ router.beforeEach(async (to, form, next) => { next() NProgress.done() } else { + sessionStorage.setItem('toView', JSON.stringify(to)) next({path: '/login'}) } } else { diff --git a/src/views/home/index.vue b/src/views/home/index.vue index bb427b8..679461a 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -51,6 +51,9 @@ import * as echarts from 'echarts' import homeImage from "@/assets/home/home.png" import coffee from "@/assets/home/coffee.png" +import { useRouter } from 'vue-router'; + +const router = useRouter() const list=ref([ { title: '在线用户量', @@ -172,8 +175,22 @@ const init = () => { 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(() => { init() + redirectView() }) window.addEventListener('resize', () => {