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,