|
|
|
|
@ -1,4 +1,10 @@
|
|
|
|
|
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'
|
|
|
|
|
import MenuList from '../views/SystemMngr/Menu/List.vue'
|
|
|
|
|
@ -6,9 +12,10 @@ import AdminGroupList from '../views/SystemMngr/Group/List.vue'
|
|
|
|
|
import AdminUserList from '../views/SystemMngr/User/List.vue'
|
|
|
|
|
import AdminChangPwd from '../views/SystemMngr/User/ChangPwd.vue'
|
|
|
|
|
import HealthCalendar from '../views/AppointmentMngr/HealthCalendar.vue'
|
|
|
|
|
import HealthCheckList from '../views/MedicalCenter/HealthCheckList.vue'
|
|
|
|
|
import healthCheckList from '../views/MedicalCenter/HealthCheckList.vue'
|
|
|
|
|
import Dashboard from '../views/MedicalCenter/Dashboard.vue'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
history: createWebHashHistory(import.meta.env.BASE_URL),
|
|
|
|
|
routes: [
|
|
|
|
|
@ -16,75 +23,82 @@ const router = createRouter({
|
|
|
|
|
path: '/',
|
|
|
|
|
name: 'login1',
|
|
|
|
|
component: Login
|
|
|
|
|
},{
|
|
|
|
|
}, {
|
|
|
|
|
path: '/login',
|
|
|
|
|
name: 'Login',
|
|
|
|
|
component: Login
|
|
|
|
|
},{
|
|
|
|
|
}, {
|
|
|
|
|
path: '/index',
|
|
|
|
|
name: 'Index',
|
|
|
|
|
component: Index,
|
|
|
|
|
children:[{
|
|
|
|
|
children: [{
|
|
|
|
|
path: '/dashboard',
|
|
|
|
|
name: 'Dashboard',
|
|
|
|
|
component: Dashboard,
|
|
|
|
|
meta: {title: '数据面板'}
|
|
|
|
|
},{
|
|
|
|
|
meta: { title: '数据面板' }
|
|
|
|
|
}, {
|
|
|
|
|
path: '/menuList',
|
|
|
|
|
name: 'menuList',
|
|
|
|
|
component: MenuList,
|
|
|
|
|
meta: {title: '菜单管理'}
|
|
|
|
|
},{
|
|
|
|
|
meta: { title: '菜单管理' }
|
|
|
|
|
}, {
|
|
|
|
|
path: '/groupMngr',
|
|
|
|
|
name: 'AdminGroupList',
|
|
|
|
|
component: AdminGroupList,
|
|
|
|
|
meta: {title: '组管理'}
|
|
|
|
|
},{
|
|
|
|
|
meta: { title: '组管理' }
|
|
|
|
|
}, {
|
|
|
|
|
path: '/adminUserList',
|
|
|
|
|
name: 'AdminUserList',
|
|
|
|
|
component: AdminUserList,
|
|
|
|
|
meta: {title: '系统用户管理'}
|
|
|
|
|
},{
|
|
|
|
|
meta: { title: '系统用户管理' }
|
|
|
|
|
}, {
|
|
|
|
|
path: '/adminChangPwd',
|
|
|
|
|
name: 'AdminChangPwd',
|
|
|
|
|
component: AdminChangPwd,
|
|
|
|
|
meta: {title: '修改密码'}
|
|
|
|
|
},{
|
|
|
|
|
meta: { title: '修改密码' }
|
|
|
|
|
}, {
|
|
|
|
|
path: '/healthCalendar',
|
|
|
|
|
name: 'HealthCalendar',
|
|
|
|
|
component: HealthCalendar,
|
|
|
|
|
meta: {title: '体检日历'}
|
|
|
|
|
},{
|
|
|
|
|
meta: { title: '体检日历' }
|
|
|
|
|
}, {
|
|
|
|
|
path: '/healthCheckList',
|
|
|
|
|
name: 'HealthCheckList',
|
|
|
|
|
component: HealthCheckList,
|
|
|
|
|
meta: {title: '体检记录列表'}
|
|
|
|
|
component: healthCheckList,
|
|
|
|
|
meta: { title: '体检记录列表' }
|
|
|
|
|
}]
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// path: '/about',
|
|
|
|
|
// name: 'about',
|
|
|
|
|
// // route level code-splitting
|
|
|
|
|
// // this generates a separate chunk (About.[hash].js) for this route
|
|
|
|
|
// // which is lazy-loaded when the route is visited.
|
|
|
|
|
// component: () => import('../views/AboutView.vue')
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 动态添加额外的路由
|
|
|
|
|
function addDynamicRoutes() {
|
|
|
|
|
// 动态添加额外的路由
|
|
|
|
|
function addDynamicRoutes(list) {
|
|
|
|
|
|
|
|
|
|
// 通过某种条件判断是否需要添加额外的路由
|
|
|
|
|
if (1) {
|
|
|
|
|
// list.forEach(function(v,i){
|
|
|
|
|
//console.log(v.url)
|
|
|
|
|
router.addRoute({
|
|
|
|
|
path: '/dynamic',
|
|
|
|
|
name: 'Dynamic',
|
|
|
|
|
component: Login
|
|
|
|
|
path: '/a',
|
|
|
|
|
name: 'a',
|
|
|
|
|
component: HealthCalendar
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
addDynamicRoutes()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let pinia
|
|
|
|
|
|
|
|
|
|
router.beforeEach(async (to, from) => {
|
|
|
|
|
pinia = usePinia()
|
|
|
|
|
console.log(pinia.userMenu)
|
|
|
|
|
watch(() => pinia.userMenu, (newValue, oldValue) => {
|
|
|
|
|
console.log('值发生变化', newValue);
|
|
|
|
|
addDynamicRoutes(newValue)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default router
|
|
|
|
|
|