12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php namespace Manage\Api;
- use Dever;
- use Manage\Lib\Auth;
- class Menu extends Auth
- {
- public function info()
- {
- $this->top = false;
- $top = Dever::db('menu')->select(array('parent_id' => '0', 'system_id' => $this->user['select']['system_id']));
- $result = $menu = array();
- foreach ($top as $v) {
- $menu = $this->getMenu($v);
- }
- if ($menu) {
- $result[] = $menu;
- }
- $result[] = array
- (
- 'path' => '/:pathMatch(.*)*',
- 'component' => '@/views/403',
- 'name' => 'NotFound',
- 'meta' => array
- (
- 'hidden' => true,
- )
- );
- 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' => 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_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'] = '@/views/page/' . $v['path'];
- }
- return $info;
- }
- }
|