From 63c1f2f1322d563e9a680e4a6302f01dabc43da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=A0=E9=BE=99?= Date: Mon, 8 Aug 2022 15:44:16 +0800 Subject: [PATCH] refactor: routes sort --- src/layout/components/sidebar/components/SideMenu.vue | 10 +++++----- src/router/routes/index.js | 2 +- src/views/error-page/route.js | 2 +- src/views/examples/table/route.js | 2 +- src/views/test-page/route.js | 2 +- src/views/workbench/route.js | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/layout/components/sidebar/components/SideMenu.vue b/src/layout/components/sidebar/components/SideMenu.vue index 4347688..8c12e59 100644 --- a/src/layout/components/sidebar/components/SideMenu.vue +++ b/src/layout/components/sidebar/components/SideMenu.vue @@ -24,7 +24,7 @@ const appStore = useAppStore() const { currentRoute } = router const menuOptions = computed(() => { - return permissionStore.menus.map((item) => getMenuItem(item)).sort((a, b) => a.index - b.index) + return permissionStore.menus.map((item) => getMenuItem(item)).sort((a, b) => a.order - b.order) }) function resolvePath(basePath, path) { @@ -44,7 +44,7 @@ function getMenuItem(route, basePath = '') { key: route.name, path: resolvePath(basePath, route.path), icon: route.meta?.icon ? renderIcon(route.meta?.icon, { size: 16 }) : renderIcon('mdi:circle-outline', { size: 8 }), - index: route.meta?.index || 0, + order: route.meta?.order || 0, } const visibleChildren = route.children ? route.children.filter((item) => item.name && !item.isHidden) : [] @@ -61,19 +61,19 @@ function getMenuItem(route, basePath = '') { icon: singleRoute.meta?.icon ? renderIcon(singleRoute.meta?.icon, { size: 16 }) : renderIcon('mdi:circle-outline', { size: 8 }), - index: menuItem.index, + order: menuItem.order, } const visibleItems = singleRoute.children ? singleRoute.children.filter((item) => item.name && !item.isHidden) : [] if (visibleItems.length === 1) { menuItem = getMenuItem(visibleItems[0], menuItem.path) } else if (visibleItems.length > 1) { - menuItem.children = visibleItems.map((item) => getMenuItem(item, menuItem.path)).sort((a, b) => a.index - b.index) + menuItem.children = visibleItems.map((item) => getMenuItem(item, menuItem.path)).sort((a, b) => a.order - b.order) } } else { menuItem.children = visibleChildren .map((item) => getMenuItem(item, menuItem.path)) - .sort((a, b) => a.index - b.index) + .sort((a, b) => a.order - b.order) } return menuItem diff --git a/src/router/routes/index.js b/src/router/routes/index.js index ae350ca..4d096b9 100644 --- a/src/router/routes/index.js +++ b/src/router/routes/index.js @@ -25,7 +25,7 @@ export const basicRoutes = [ meta: { title: '外部链接', icon: 'mdi:link-variant', - index: 2, + order: 2, }, children: [ { diff --git a/src/views/error-page/route.js b/src/views/error-page/route.js index 00ecf4b..7a46bb2 100644 --- a/src/views/error-page/route.js +++ b/src/views/error-page/route.js @@ -8,7 +8,7 @@ export default { meta: { title: '错误页', icon: 'mdi:alert-circle-outline', - index: 99, + order: 99, }, children: [ { diff --git a/src/views/examples/table/route.js b/src/views/examples/table/route.js index a5026d6..21b2958 100644 --- a/src/views/examples/table/route.js +++ b/src/views/examples/table/route.js @@ -10,7 +10,7 @@ export default { icon: 'mdi:menu', role: ['admin'], requireAuth: true, - index: 3, + order: 3, }, children: [ { diff --git a/src/views/test-page/route.js b/src/views/test-page/route.js index f90a966..196a982 100644 --- a/src/views/test-page/route.js +++ b/src/views/test-page/route.js @@ -8,7 +8,7 @@ export default { meta: { title: '基础功能测试', icon: 'mdi:menu', - index: 1, + order: 1, }, children: [ { diff --git a/src/views/workbench/route.js b/src/views/workbench/route.js index 3713df4..2b4771a 100644 --- a/src/views/workbench/route.js +++ b/src/views/workbench/route.js @@ -13,7 +13,7 @@ export default { meta: { title: '工作台', icon: 'mdi:home', - index: 0, + order: 0, }, }, ],