|
|
|
|
@ -1,9 +1,6 @@
|
|
|
|
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
usePinia
|
|
|
|
|
} from '@/stores/index.js'
|
|
|
|
|
import { ref, watch } from 'vue';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import Login from '../views/Login.vue'
|
|
|
|
|
import Index from '../views/Index.vue'
|
|
|
|
|
@ -72,31 +69,16 @@ const router = createRouter({
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 动态添加额外的路由
|
|
|
|
|
function addDynamicRoutes(list) {
|
|
|
|
|
|
|
|
|
|
// 通过某种条件判断是否需要添加额外的路由
|
|
|
|
|
// list.forEach(function(v,i){
|
|
|
|
|
//console.log(v.url)
|
|
|
|
|
router.addRoute({
|
|
|
|
|
path: '/a',
|
|
|
|
|
name: 'a',
|
|
|
|
|
component: HealthCalendar
|
|
|
|
|
})
|
|
|
|
|
// })
|
|
|
|
|
import {
|
|
|
|
|
GetAdminBaseMenuList
|
|
|
|
|
} from "@/api/api.js";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
router.beforeEach(async (to, from ) => {
|
|
|
|
|
|
|
|
|
|
let pinia
|
|
|
|
|
|
|
|
|
|
router.beforeEach(async (to, from) => {
|
|
|
|
|
pinia = usePinia()
|
|
|
|
|
console.log(pinia.userMenu)
|
|
|
|
|
watch(() => pinia.userMenu, (newValue, oldValue) => {
|
|
|
|
|
console.log('值发生变化', newValue);
|
|
|
|
|
addDynamicRoutes(newValue)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|