mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 优化细节
This commit is contained in:
parent
15bc6119f6
commit
6368462a18
@ -241,9 +241,9 @@ class Auth extends Base {
|
|||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
$newList[$key]['title'] = $value['name'];
|
$newList[$key]['title'] = $value['name'];
|
||||||
$newList[$key]['key'] = $value['url'];
|
$newList[$key]['key'] = $value['url'];
|
||||||
if (isset($value['_child'])) {
|
if (isset($value['children'])) {
|
||||||
$newList[$key]['expand'] = true;
|
$newList[$key]['expand'] = true;
|
||||||
$newList[$key]['children'] = $this->buildList($value['_child'], $rules);
|
$newList[$key]['children'] = $this->buildList($value['children'], $rules);
|
||||||
} else {
|
} else {
|
||||||
if (in_array($value['url'], $rules)) {
|
if (in_array($value['url'], $rules)) {
|
||||||
$newList[$key]['checked'] = true;
|
$newList[$key]['checked'] = true;
|
||||||
|
@ -20,12 +20,13 @@ class Menu extends Base {
|
|||||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
$list = (new AdminMenu)->order('sort', 'ASC')->select();
|
$origin = (new AdminMenu)->order('sort', 'ASC')->select();
|
||||||
$list = Tools::buildArrFromObj($list);
|
$origin = Tools::buildArrFromObj($origin);
|
||||||
$list = Tools::formatTree(Tools::listToTree($list));
|
$list = Tools::listToTree($origin);
|
||||||
|
$choose = Tools::formatTree($list);
|
||||||
return $this->buildSuccess([
|
return $this->buildSuccess([
|
||||||
'list' => $list
|
'list' => $list,
|
||||||
|
'choose' => $choose
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class Tools {
|
|||||||
* @param string $root
|
* @param string $root
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function listToTree($list, $pk='id', $pid = 'fid', $child = '_child', $root = '0') {
|
public static function listToTree($list, $pk='id', $pid = 'fid', $child = 'children', $root = '0') {
|
||||||
$tree = array();
|
$tree = array();
|
||||||
if(is_array($list)) {
|
if(is_array($list)) {
|
||||||
$refer = array();
|
$refer = array();
|
||||||
@ -153,11 +153,11 @@ class Tools {
|
|||||||
$val['lv'] = $lv;
|
$val['lv'] = $lv;
|
||||||
$val['namePrefix'] = $lv == 0 ? '' : $title_prefix;
|
$val['namePrefix'] = $lv == 0 ? '' : $title_prefix;
|
||||||
$val['showName'] = $lv == 0 ? $val[$title] : $title_prefix.$val[$title];
|
$val['showName'] = $lv == 0 ? $val[$title] : $title_prefix.$val[$title];
|
||||||
if(!array_key_exists('_child', $val)){
|
if(!array_key_exists('children', $val)){
|
||||||
array_push($formatTree, $val);
|
array_push($formatTree, $val);
|
||||||
}else{
|
}else{
|
||||||
$child = $val['_child'];
|
$child = $val['children'];
|
||||||
unset($val['_child']);
|
unset($val['children']);
|
||||||
array_push($formatTree, $val);
|
array_push($formatTree, $val);
|
||||||
$middle = self::formatTree($child, $lv+1, $title); //进行下一层递归
|
$middle = self::formatTree($child, $lv+1, $title); //进行下一层递归
|
||||||
$formatTree = array_merge($formatTree, $middle);
|
$formatTree = array_merge($formatTree, $middle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user