top = true; $top = Dever::db('menu')->select(array('parent_id' => '0', 'system_id' => $this->user['select']['system_id'])); $result = $menu = array(); $result[] = array ( 'path' => '/', 'name' => 'Root', 'component' => 'Layout', 'meta' => array ( 'title' => '首页', 'icon' => 'home-2-line', 'breadcrumbHidden' => true, ), 'children' => array ( array ( 'path' => 'index', 'name' => 'Index', 'component' => '@/dever/index/index', 'meta' => array ( 'title' => '控制台', 'icon' => 'home-2-line', 'noClosable' => true, ) ), ) ); foreach ($top as $v) { $menu = $this->getMenu($v); } if ($menu) { $result[] = $menu; } return array('list' => $result); } private function getMenu($v, $parent = '') { $info = array ( 'path' => $parent ? '/' . $parent . '/' . $v['key'] : $v['key'], 'name' => $v['key'], 'meta' => array ( 'title' => $v['name'], 'icon' => $v['icon'], //'noClosable' => true, 'breadcrumbHidden' => false, 'dynamicNewTab' => true, ) ); if ($v['show'] == 2) { $info['meta']['hidden'] = true; } if (isset($v['active']) && $v['active']) { $info['meta']['activeMenu'] = $v['active']; } if ($v['parent_id'] <= 0) { if ($this->top) { $info['path'] = '/' . $v['key']; } else { $this->top = true; $info['path'] = '/'; } $info['component'] = 'Layout'; } $where = array('parent_id' => $v['id'], 'system_id' => $this->user['select']['system_id']); $child = Dever::db('menu')->select($where)->fetchAll(); if ($child) { foreach ($child as $v1) { if ($v1['func'] == 1 && $this->checkMenu($v1['id'])) { continue; } $info['children'][] = $this->getMenu($v1, $v['key']); } } elseif ($v['path']) { $info['component'] = '@/dever/page/' . $v['path']; } return $info; } }