Skip to content

Commit

Permalink
fix(admin): flattenMenuItemOfAdmin use pathPrefix of routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aysnine committed Jan 14, 2020
1 parent c58d17e commit f66b400
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { map, kebabCase } from 'lodash'

export const pathPrefix = '/admin'

export const routes = (prefix = pathPrefix) => [
export const routes = () => [
{
path: prefix,
path: pathPrefix,
name: 'admin',
redirect: `${prefix}/dashboard`,
redirect: `${pathPrefix}/dashboard`,
component: () => import('../views/admin/$index'),
children: map(
[
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/admin/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { includes } from 'lodash'
import { FLAGS } from '@/constants/flags'
import { getField, updateField } from 'vuex-map-fields'
import { flattenMenuItemOfAdmin } from '@/views/admin/$index/utils'
import { flattenMenuItemOfAdmin } from './utils'
import { createMenu } from './menu'

export const namespace = 'admin'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { map, flattenDeep, uniqBy, filter } from 'lodash'
import { pathPrefix } from '@/routes/admin'

const flattenMenuItem = (() => {
const it = collection =>
Expand All @@ -14,6 +15,8 @@ const flattenMenuItem = (() => {

export const flattenMenuItemOfAdmin = menu =>
uniqBy(
filter(flattenMenuItem(menu), ({ index }) => /^\/admin/.test(index)),
filter(flattenMenuItem(menu), ({ index }) =>
new RegExp(pathPrefix).test(index)
),
'index'
)

0 comments on commit f66b400

Please sign in to comment.