12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php namespace Manage\Api;
- use Dever;
- use Manage\Lib\Auth;
- class Menu extends Auth
- {
- private $list = 'list,table,card';
- public function info()
- {
- $top = Dever::db('menu')->select(array('parent_key' => '/'));
- $result = $menu = array();
- foreach ($top as $v) {
- $menu = $this->getMenu($v);
- }
- $result[] = $menu;
- $result[] = array
- (
- 'path' => '/:pathMatch(.*)*',
- 'component' => '@/views/403',
- 'name' => 'NotFound',
- 'meta' => array
- (
- 'hidden' => true,
- )
- );
- return array('list' => $result);
- }
- private function getMenu($v)
- {
- $info = array
- (
- 'path' => $v['key'],
- 'name' => ucfirst($v['key']),
- 'meta' => array
- (
- 'title' => $v['name'],
- 'icon' => $v['icon'],
- //'noClosable' => true,
- //'breadcrumbHidden' => true,
- 'dynamicNewTab' => true,
- )
- );
- if ($v['show'] == 2) {
- $info['meta']['hidden'] = true;
- }
- if (isset($v['active']) && $v['active']) {
- $info['meta']['activeMenu'] = $v['active'];
- }
- if ($v['parent_key'] == '/') {
- $info['path'] = '/';
- $info['component'] = 'Layout';
- }
- $child = Dever::db('menu')->select(array('parent_key' => $v['key']))->fetchAll();
- if ($child) {
- foreach ($child as $v1) {
- $info['children'][] = $this->getMenu($v1);
- if (isset($v1['link']) && strstr($this->list, $v1['link'])) {
- $v1['active'] = '/' . $v1['key'];
- $v1['name'] .= '更新';
- $v1['link'] = 'update';
- $v1['key'] .= '/update';
- $v1['show'] = 2;
- $info['children'][] = $this->getMenu($v1);
- }
- }
- } elseif ($v['link']) {
- $info['component'] = '@/views/page/' . $v['link'];
- }
- return $info;
- }
- }
|