diff --git a/el-admin/src/router/index.js b/el-admin/src/router/index.js
index 80f3f62..f2b41fa 100644
--- a/el-admin/src/router/index.js
+++ b/el-admin/src/router/index.js
@@ -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,85 +12,93 @@ 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: [
- {
- path: '/',
- name: 'login1',
- component: Login
- },{
- path: '/login',
- name: 'Login',
- component: Login
- },{
- path: '/index',
- name: 'Index',
- component: Index,
- children:[{
- path: '/dashboard',
- name: 'Dashboard',
- component: Dashboard,
- meta: {title: '数据面板'}
- },{
- path: '/menuList',
- name: 'menuList',
- component: MenuList,
- meta: {title: '菜单管理'}
- },{
- path: '/groupMngr',
- name: 'AdminGroupList',
- component: AdminGroupList,
- meta: {title: '组管理'}
- },{
- path: '/adminUserList',
- name: 'AdminUserList',
- component: AdminUserList,
- meta: {title: '系统用户管理'}
- },{
- path: '/adminChangPwd',
- name: 'AdminChangPwd',
- component: AdminChangPwd,
- meta: {title: '修改密码'}
- },{
- path: '/healthCalendar',
- name: 'HealthCalendar',
- component: HealthCalendar,
- meta: {title: '体检日历'}
- },{
- path: '/healthCheckList',
- name: 'HealthCheckList',
- 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')
- // }
- ]
+ history: createWebHashHistory(import.meta.env.BASE_URL),
+ routes: [
+ {
+ path: '/',
+ name: 'login1',
+ component: Login
+ }, {
+ path: '/login',
+ name: 'Login',
+ component: Login
+ }, {
+ path: '/index',
+ name: 'Index',
+ component: Index,
+ children: [{
+ path: '/dashboard',
+ name: 'Dashboard',
+ component: Dashboard,
+ meta: { title: '数据面板' }
+ }, {
+ path: '/menuList',
+ name: 'menuList',
+ component: MenuList,
+ meta: { title: '菜单管理' }
+ }, {
+ path: '/groupMngr',
+ name: 'AdminGroupList',
+ component: AdminGroupList,
+ meta: { title: '组管理' }
+ }, {
+ path: '/adminUserList',
+ name: 'AdminUserList',
+ component: AdminUserList,
+ meta: { title: '系统用户管理' }
+ }, {
+ path: '/adminChangPwd',
+ name: 'AdminChangPwd',
+ component: AdminChangPwd,
+ meta: { title: '修改密码' }
+ }, {
+ path: '/healthCalendar',
+ name: 'HealthCalendar',
+ component: HealthCalendar,
+ meta: { title: '体检日历' }
+ }, {
+ path: '/healthCheckList',
+ name: 'HealthCheckList',
+ component: healthCheckList,
+ meta: { title: '体检记录列表' }
+ }]
+ },
+
+ ]
})
- // 动态添加额外的路由
-function addDynamicRoutes() {
+// 动态添加额外的路由
+function addDynamicRoutes(list) {
+
// 通过某种条件判断是否需要添加额外的路由
- if (1) {
- router.addRoute({
- path: '/dynamic',
- name: 'Dynamic',
- component: Login
- })
- }
- }
-
- addDynamicRoutes()
-
+ // list.forEach(function(v,i){
+ //console.log(v.url)
+ router.addRoute({
+ path: '/a',
+ name: 'a',
+ component: HealthCalendar
+ })
+ // })
+
+
+}
+
+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
diff --git a/el-admin/src/stores/index.js b/el-admin/src/stores/index.js
index ecf3607..fcbf7e5 100644
--- a/el-admin/src/stores/index.js
+++ b/el-admin/src/stores/index.js
@@ -2,15 +2,17 @@ import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export const usePinia = defineStore('usePinia', () => {
- const count = ref(0)
+//主题
const theme=ref('light')
- const doubleCount = computed(() => count.value * 2)
- function increment() {
- count.value++
- }
const themeChange=(v)=>{
theme.value=v
}
- return { theme,themeChange,count, doubleCount, increment }
+//用户菜单
+ const userMenu=ref([])
+ const setUserMenu=(v)=>{
+ userMenu.value=v
+ }
+
+ return { theme,themeChange,userMenu,setUserMenu}
})
diff --git a/el-admin/src/views/Login.vue b/el-admin/src/views/Login.vue
index 3db8309..96e05e9 100644
--- a/el-admin/src/views/Login.vue
+++ b/el-admin/src/views/Login.vue
@@ -41,13 +41,13 @@