Parcourir la source

refactor: sidebar positioning key

Casper Dai il y a 3 ans
Parent
commit
8af4d05568
2 fichiers modifiés avec 1 ajouts et 12 suppressions
  1. 1 7
      src/layout/components/Sidebar/index.vue
  2. 0 5
      src/router/index.js

+ 1 - 7
src/layout/components/Sidebar/index.vue

@@ -76,13 +76,7 @@ export default {
       return filterRoutes(this.permissionRoutes)
     },
     activeMenu () {
-      const route = this.$route
-      const { meta, path } = route
-      // if set path, the sidebar will highlight the path you set
-      if (meta.activeMenu) {
-        return meta.activeMenu
-      }
-      return path
+      return this.$route.matched[1]?.path
     }
   }
 }

+ 0 - 5
src/router/index.js

@@ -17,7 +17,6 @@ Vue.use(Router)
  * meta : {
  *   title: 'title',               the name show in sidebar and breadcrumb (recommend set)
  *   icon: 'svg-name'/'el-icon-x', the icon show in the sidebar
- *   activeMenu: '/example/list',  if set path, the sidebar will highlight the path you set
  *   cache: 'router-name'          if set, the router will be cached (only in Solo)
  * }
  */
@@ -91,7 +90,6 @@ export const asyncRoutes = [
             path: '',
             component: () => import('@/views/schedule/index'),
             meta: {
-              activeMenu: '/cm/recur',
               cache: 'ScheduleList',
               info: {
                 type: ScheduleType.RECUR,
@@ -105,7 +103,6 @@ export const asyncRoutes = [
             component: () => import('@/views/schedule/designer/index'),
             meta: {
               title: '编辑',
-              activeMenu: '/cm/recur',
               cache: 'ScheduleList',
               info: { redirect: 'recur-list' }
             },
@@ -124,7 +121,6 @@ export const asyncRoutes = [
             path: '',
             component: () => import('@/views/schedule/index'),
             meta: {
-              activeMenu: '/cm/schedule',
               cache: 'ScheduleList',
               info: {
                 type: ScheduleType.COMPLEX,
@@ -138,7 +134,6 @@ export const asyncRoutes = [
             component: () => import('@/views/schedule/designer/index'),
             meta: {
               title: '编辑',
-              activeMenu: '/cm/schedule',
               cache: 'ScheduleList',
               info: { redirect: 'schedule-list' }
             },