From 761b8a9f40c5c48628f3f389c74edaa60db8a233 Mon Sep 17 00:00:00 2001 From: wyx <51903@qq.com> Date: Wed, 15 Mar 2023 15:07:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD=E5=BD=93?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BF=9B=E5=85=A5=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=AB=AF=E5=B1=95=E7=A4=BA=E7=9A=84=E7=95=8C=E9=9D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 24 ++++++++++++++++++++++++ src/store/index.js | 9 +-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index f376229f..d7a2556a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -8,6 +8,8 @@ */ import { createRouter, createWebHistory } from 'vue-router'; import routesConfig from './config'; +import store from "@/store"; + const routes = [ { path: '/', @@ -21,4 +23,26 @@ const router = createRouter({ routes, }) + +let count = 0; +const timers = setInterval(() => { + count ++ + let pathArr = store.state.menus + let currentPath = router.options.history.location + console.log(pathArr, currentPath, pathArr.indexOf(currentPath)) + if(pathArr.length!==0){ + // 刷新界面是否重新执行 + if(pathArr.indexOf(currentPath)==-1){ + clearInterval(timers) + router.push({path: pathArr[0]}) + }else{ + clearInterval(timers) + } + } + // 30s超时结束 + if(count==60&&pathArr.length==0){ + clearInterval(timers) + } +}, 500); + export default router \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 004edc54..c064244c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -12,14 +12,7 @@ export default createStore({ state: { openpages: localStorage.getItem("openpages") ? JSON.parse(localStorage.getItem("openpages")) - : [ - { - pagename: "学习路径图", - href: "/learningpath", - active: true, - }, - ], - + : [], assessmentName: "", routerId: null, projectTemplateId: null,