mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-24 00:53:52 +00:00
revise menu property : router => route
This commit is contained in:
@@ -11,7 +11,7 @@ const Bread = ({ menu }) => {
|
||||
let pathArray = []
|
||||
let current
|
||||
for (let index in menu) {
|
||||
if (menu[index].router && pathToRegexp(menu[index].router).exec(location.pathname)) {
|
||||
if (menu[index].route && pathToRegexp(menu[index].route).exec(location.pathname)) {
|
||||
current = menu[index]
|
||||
break
|
||||
}
|
||||
@@ -48,7 +48,7 @@ const Bread = ({ menu }) => {
|
||||
return (
|
||||
<Breadcrumb.Item key={key}>
|
||||
{((pathArray.length - 1) !== key)
|
||||
? <Link to={item.router}>
|
||||
? <Link to={item.route}>
|
||||
{content}
|
||||
</Link>
|
||||
: content}
|
||||
|
||||
@@ -31,7 +31,7 @@ const Menus = ({ siderFold, darkTheme, handleClickNavMenu, navOpenKeys, changeOp
|
||||
}
|
||||
return (
|
||||
<Menu.Item key={item.id}>
|
||||
<Link to={item.router}>
|
||||
<Link to={item.route}>
|
||||
{item.icon && <Icon type={item.icon} />}
|
||||
{(!siderFoldN || !menuTree.includes(item)) && item.name}
|
||||
</Link>
|
||||
@@ -82,7 +82,7 @@ const Menus = ({ siderFold, darkTheme, handleClickNavMenu, navOpenKeys, changeOp
|
||||
let currentMenu
|
||||
let defaultSelectedKeys
|
||||
for (let item of menu) {
|
||||
if (item.router && pathToRegexp(item.router).exec(location.pathname)) {
|
||||
if (item.route && pathToRegexp(item.route).exec(location.pathname)) {
|
||||
currentMenu = item
|
||||
break
|
||||
}
|
||||
|
||||
+19
-19
@@ -1,4 +1,4 @@
|
||||
const { config, posts } = require('./common')
|
||||
const { config } = require('./common')
|
||||
|
||||
const { apiPrefix } = config
|
||||
let database = [
|
||||
@@ -6,35 +6,35 @@ let database = [
|
||||
id: '1',
|
||||
icon: 'laptop',
|
||||
name: 'Dashboard',
|
||||
router: '/dashboard',
|
||||
route: '/dashboard',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
bpid: '1',
|
||||
name: 'Users',
|
||||
icon: 'user',
|
||||
router: '/user',
|
||||
route: '/user',
|
||||
},
|
||||
{
|
||||
id: '7',
|
||||
bpid: '1',
|
||||
name: 'Posts',
|
||||
icon: 'shopping-cart',
|
||||
router: '/post',
|
||||
route: '/post',
|
||||
},
|
||||
{
|
||||
id: '21',
|
||||
mpid: '-1',
|
||||
bpid: '2',
|
||||
name: 'User Detail',
|
||||
router: '/user/:id',
|
||||
route: '/user/:id',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
bpid: '1',
|
||||
name: 'Request',
|
||||
icon: 'api',
|
||||
router: '/request',
|
||||
route: '/request',
|
||||
},
|
||||
{
|
||||
id: '4',
|
||||
@@ -48,7 +48,7 @@ let database = [
|
||||
mpid: '4',
|
||||
name: 'IconFont',
|
||||
icon: 'heart-o',
|
||||
router: '/UIElement/iconfont',
|
||||
route: '/UIElement/iconfont',
|
||||
},
|
||||
{
|
||||
id: '42',
|
||||
@@ -56,7 +56,7 @@ let database = [
|
||||
mpid: '4',
|
||||
name: 'DataTable',
|
||||
icon: 'database',
|
||||
router: '/UIElement/dataTable',
|
||||
route: '/UIElement/dataTable',
|
||||
},
|
||||
{
|
||||
id: '43',
|
||||
@@ -64,7 +64,7 @@ let database = [
|
||||
mpid: '4',
|
||||
name: 'DropOption',
|
||||
icon: 'bars',
|
||||
router: '/UIElement/dropOption',
|
||||
route: '/UIElement/dropOption',
|
||||
},
|
||||
{
|
||||
id: '44',
|
||||
@@ -72,7 +72,7 @@ let database = [
|
||||
mpid: '4',
|
||||
name: 'Search',
|
||||
icon: 'search',
|
||||
router: '/UIElement/search',
|
||||
route: '/UIElement/search',
|
||||
},
|
||||
{
|
||||
id: '45',
|
||||
@@ -80,7 +80,7 @@ let database = [
|
||||
mpid: '4',
|
||||
name: 'Editor',
|
||||
icon: 'edit',
|
||||
router: '/UIElement/editor',
|
||||
route: '/UIElement/editor',
|
||||
},
|
||||
{
|
||||
id: '46',
|
||||
@@ -88,7 +88,7 @@ let database = [
|
||||
mpid: '4',
|
||||
name: 'layer (Function)',
|
||||
icon: 'credit-card',
|
||||
router: '/UIElement/layer',
|
||||
route: '/UIElement/layer',
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
@@ -102,7 +102,7 @@ let database = [
|
||||
mpid: '5',
|
||||
name: 'LineChart',
|
||||
icon: 'line-chart',
|
||||
router: '/chart/lineChart',
|
||||
route: '/chart/lineChart',
|
||||
},
|
||||
{
|
||||
id: '52',
|
||||
@@ -110,7 +110,7 @@ let database = [
|
||||
mpid: '5',
|
||||
name: 'BarChart',
|
||||
icon: 'bar-chart',
|
||||
router: '/chart/barChart',
|
||||
route: '/chart/barChart',
|
||||
},
|
||||
{
|
||||
id: '53',
|
||||
@@ -118,7 +118,7 @@ let database = [
|
||||
mpid: '5',
|
||||
name: 'AreaChart',
|
||||
icon: 'area-chart',
|
||||
router: '/chart/areaChart',
|
||||
route: '/chart/areaChart',
|
||||
},
|
||||
{
|
||||
id: '6',
|
||||
@@ -131,28 +131,28 @@ let database = [
|
||||
bpid: '6',
|
||||
mpid: '6',
|
||||
name: 'Test Navigation1',
|
||||
router: '/navigation/navigation1',
|
||||
route: '/navigation/navigation1',
|
||||
},
|
||||
{
|
||||
id: '62',
|
||||
bpid: '6',
|
||||
mpid: '6',
|
||||
name: 'Test Navigation2',
|
||||
router: '/navigation/navigation2',
|
||||
route: '/navigation/navigation2',
|
||||
},
|
||||
{
|
||||
id: '621',
|
||||
bpid: '62',
|
||||
mpid: '62',
|
||||
name: 'Test Navigation21',
|
||||
router: '/navigation/navigation2/navigation1',
|
||||
route: '/navigation/navigation2/navigation1',
|
||||
},
|
||||
{
|
||||
id: '622',
|
||||
bpid: '62',
|
||||
mpid: '62',
|
||||
name: 'Test Navigation22',
|
||||
router: '/navigation/navigation2/navigation2',
|
||||
route: '/navigation/navigation2/navigation2',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ const App = ({ children, dispatch, app, loading, location }) => {
|
||||
let { pathname } = location
|
||||
pathname = pathname.startsWith('/') ? pathname : `/${pathname}`
|
||||
const { iconFontJS, iconFontCSS, logo } = config
|
||||
const current = menu.filter(item => pathToRegexp(item.router || '').exec(pathname))
|
||||
const current = menu.filter(item => pathToRegexp(item.route || '').exec(pathname))
|
||||
const hasPermission = current.length ? permissions.visit.includes(current[0].id) : false
|
||||
const href = window.location.href
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import config from './config'
|
||||
import menu from './menu'
|
||||
import request from './request'
|
||||
import classnames from 'classnames'
|
||||
import { color } from './theme'
|
||||
@@ -101,7 +100,6 @@ const arrayToTree = (array, id = 'id', pid = 'pid', children = 'children') => {
|
||||
|
||||
module.exports = {
|
||||
config,
|
||||
menu,
|
||||
request,
|
||||
color,
|
||||
classnames,
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
module.exports = [
|
||||
{
|
||||
id: 1,
|
||||
icon: 'laptop',
|
||||
name: 'Dashboard',
|
||||
router: '/dashboard',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
bpid: 1,
|
||||
name: 'Users',
|
||||
icon: 'user',
|
||||
router: '/user',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
bpid: 1,
|
||||
name: 'Posts',
|
||||
icon: 'shopping-cart',
|
||||
router: '/post',
|
||||
},
|
||||
{
|
||||
id: 21,
|
||||
mpid: -1,
|
||||
bpid: 2,
|
||||
name: 'User Detail',
|
||||
router: '/user/:id',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
bpid: 1,
|
||||
name: 'Request',
|
||||
icon: 'api',
|
||||
router: '/request',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
bpid: 1,
|
||||
name: 'UI Element',
|
||||
icon: 'camera-o',
|
||||
},
|
||||
{
|
||||
id: 41,
|
||||
bpid: 4,
|
||||
mpid: 4,
|
||||
name: 'IconFont',
|
||||
icon: 'heart-o',
|
||||
router: '/UIElement/iconfont',
|
||||
},
|
||||
{
|
||||
id: 42,
|
||||
bpid: 4,
|
||||
mpid: 4,
|
||||
name: 'DataTable',
|
||||
icon: 'database',
|
||||
router: '/UIElement/dataTable',
|
||||
},
|
||||
{
|
||||
id: 43,
|
||||
bpid: 4,
|
||||
mpid: 4,
|
||||
name: 'DropOption',
|
||||
icon: 'bars',
|
||||
router: '/UIElement/dropOption',
|
||||
},
|
||||
{
|
||||
id: 44,
|
||||
bpid: 4,
|
||||
mpid: 4,
|
||||
name: 'Search',
|
||||
icon: 'search',
|
||||
router: '/UIElement/search',
|
||||
},
|
||||
{
|
||||
id: 45,
|
||||
bpid: 4,
|
||||
mpid: 4,
|
||||
name: 'Editor',
|
||||
icon: 'edit',
|
||||
router: '/UIElement/editor',
|
||||
},
|
||||
{
|
||||
id: 46,
|
||||
bpid: 4,
|
||||
mpid: 4,
|
||||
name: 'layer (Function)',
|
||||
icon: 'credit-card',
|
||||
router: '/UIElement/layer',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
bpid: 1,
|
||||
name: 'Recharts',
|
||||
icon: 'code-o',
|
||||
},
|
||||
{
|
||||
id: 51,
|
||||
bpid: 5,
|
||||
mpid: 5,
|
||||
name: 'LineChart',
|
||||
icon: 'line-chart',
|
||||
router: '/chart/lineChart',
|
||||
},
|
||||
{
|
||||
id: 52,
|
||||
bpid: 5,
|
||||
mpid: 5,
|
||||
name: 'BarChart',
|
||||
icon: 'bar-chart',
|
||||
router: '/chart/barChart',
|
||||
},
|
||||
{
|
||||
id: 53,
|
||||
bpid: 5,
|
||||
mpid: 5,
|
||||
name: 'AreaChart',
|
||||
icon: 'area-chart',
|
||||
router: '/chart/areaChart',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
bpid: 1,
|
||||
name: 'Test Navigation',
|
||||
icon: 'setting',
|
||||
},
|
||||
{
|
||||
id: 61,
|
||||
bpid: 6,
|
||||
mpid: 6,
|
||||
name: 'Test Navigation1',
|
||||
router: '/navigation/navigation1',
|
||||
},
|
||||
{
|
||||
id: 62,
|
||||
bpid: 6,
|
||||
mpid: 6,
|
||||
name: 'Test Navigation2',
|
||||
router: '/navigation/navigation2',
|
||||
},
|
||||
{
|
||||
id: 621,
|
||||
bpid: 62,
|
||||
mpid: 62,
|
||||
name: 'Test Navigation21',
|
||||
router: '/navigation/navigation2/navigation1',
|
||||
},
|
||||
{
|
||||
id: 622,
|
||||
bpid: 62,
|
||||
mpid: 62,
|
||||
name: 'Test Navigation22',
|
||||
router: '/navigation/navigation2/navigation2',
|
||||
},
|
||||
]
|
||||
Reference in New Issue
Block a user