mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-17 21:25:06 +00:00
rebuild bread,menu,router
This commit is contained in:
@@ -3,6 +3,7 @@ import menu from './menu'
|
||||
import request from './request'
|
||||
import classnames from 'classnames'
|
||||
import { color } from './theme'
|
||||
import lodash from 'lodash'
|
||||
|
||||
// 连字符转驼峰
|
||||
String.prototype.hyphenToHump = function () {
|
||||
@@ -52,6 +53,52 @@ const queryURL = (name) => {
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组内查询
|
||||
* @param {array} array
|
||||
* @param {String} id
|
||||
* @param {String} keyAlias
|
||||
* @return {Array}
|
||||
*/
|
||||
const queryArray = (array, key, keyAlias = 'key') => {
|
||||
if (!(array instanceof Array)) {
|
||||
return null
|
||||
}
|
||||
const item = array.filter(_ => _[keyAlias] === key)
|
||||
if (item.length) {
|
||||
return item[0]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组格式转树状结构
|
||||
* @param {array} array
|
||||
* @param {String} id
|
||||
* @param {String} pid
|
||||
* @param {String} children
|
||||
* @return {Array}
|
||||
*/
|
||||
const arrayToTree = (array, id = 'id', pid = 'pid', chindren = 'chindren') => {
|
||||
let data = lodash.cloneDeep(array)
|
||||
let result = []
|
||||
let hash = {}
|
||||
data.forEach((item, index) => {
|
||||
hash[data[index][id]] = data[index]
|
||||
})
|
||||
|
||||
data.forEach((item) => {
|
||||
let hashVP = hash[item[pid]]
|
||||
if (hashVP) {
|
||||
!hashVP[chindren] && (hashVP[chindren] = [])
|
||||
hashVP[chindren].push(item)
|
||||
} else {
|
||||
result.push(item)
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
config,
|
||||
menu,
|
||||
@@ -59,4 +106,6 @@ module.exports = {
|
||||
color,
|
||||
classnames,
|
||||
queryURL,
|
||||
queryArray,
|
||||
arrayToTree,
|
||||
}
|
||||
|
||||
+122
-77
@@ -1,102 +1,147 @@
|
||||
module.exports = [
|
||||
{
|
||||
key: 'dashboard',
|
||||
name: 'Dashboard',
|
||||
id: 1,
|
||||
icon: 'laptop',
|
||||
name: 'Dashboard',
|
||||
router: '/dashboard',
|
||||
},
|
||||
{
|
||||
key: 'users',
|
||||
id: 2,
|
||||
bpid: 1,
|
||||
name: 'User Manage',
|
||||
icon: 'user',
|
||||
router: '/users',
|
||||
},
|
||||
{
|
||||
key: 'request',
|
||||
id: 3,
|
||||
bpid: 1,
|
||||
name: 'Request',
|
||||
icon: 'api',
|
||||
router: '/request',
|
||||
},
|
||||
{
|
||||
key: 'UIElement',
|
||||
id: 4,
|
||||
bpid: 1,
|
||||
name: 'UI Element',
|
||||
icon: 'camera-o',
|
||||
clickable: false,
|
||||
child: [
|
||||
{
|
||||
key: 'iconfont',
|
||||
name: 'IconFont',
|
||||
icon: 'heart-o',
|
||||
},
|
||||
{
|
||||
key: 'dataTable',
|
||||
name: 'DataTable',
|
||||
icon: 'database',
|
||||
},
|
||||
{
|
||||
key: 'dropOption',
|
||||
name: 'DropOption',
|
||||
icon: 'bars',
|
||||
},
|
||||
{
|
||||
key: 'search',
|
||||
name: 'Search',
|
||||
icon: 'search',
|
||||
},
|
||||
{
|
||||
key: 'editor',
|
||||
name: 'Editor',
|
||||
icon: 'edit',
|
||||
},
|
||||
{
|
||||
key: 'layer',
|
||||
name: 'layer (Function)',
|
||||
icon: 'credit-card',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'chart',
|
||||
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',
|
||||
child: [
|
||||
{
|
||||
key: 'lineChart',
|
||||
name: 'LineChart',
|
||||
icon: 'line-chart',
|
||||
},
|
||||
{
|
||||
key: 'barChart',
|
||||
name: 'BarChart',
|
||||
icon: 'bar-chart',
|
||||
},
|
||||
{
|
||||
key: 'areaChart',
|
||||
name: 'AreaChart',
|
||||
icon: 'area-chart',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'navigation',
|
||||
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/lineChart',
|
||||
},
|
||||
{
|
||||
id: 53,
|
||||
bpid: 5,
|
||||
mpid: 5,
|
||||
name: 'AreaChart',
|
||||
icon: 'area-chart',
|
||||
router: '/chart/areaChart',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
bpid: 1,
|
||||
name: 'Test Navigation',
|
||||
icon: 'setting',
|
||||
child: [
|
||||
{
|
||||
key: 'navigation1',
|
||||
name: 'Test Navigation1',
|
||||
},
|
||||
{
|
||||
key: 'navigation2',
|
||||
name: 'Test Navigation2',
|
||||
child: [
|
||||
{
|
||||
key: 'navigation21',
|
||||
name: 'Test Navigation21',
|
||||
},
|
||||
{
|
||||
key: 'navigation22',
|
||||
name: 'Test Navigation22',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
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: 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