feat: 添加获取系统前台各模块url接口

This commit is contained in:
2025-03-14 17:58:36 +08:00
parent 78dc1188f7
commit 67f5a529ca
7 changed files with 178 additions and 4 deletions

View File

@@ -7,10 +7,11 @@ if (!function_exists('array_to_tree')) {
* @param array $data 数据
* @param int $pid 父级ID
* @param string $with 转换依据字段
* @param int $level 层级
* @param int|bool $level 层级
* @param bool $keep_pid 是否保留pid
* @return array
*/
function array_to_tree(array $data, int $pid, string $with = 'pid', int|false $level = 1)
function array_to_tree(array $data, int $pid, string $with = 'pid', int|bool $level = 1, bool $keep_pid = true)
{
$ret = [];
foreach ($data as $item) {
@@ -20,6 +21,9 @@ if (!function_exists('array_to_tree')) {
$item['level'] = $level;
$lv = $level + 1;
}
if ($keep_pid === false) {
unset($item[$with]);
}
$children = array_to_tree($data, $item['id'], $with, $lv);
if ($children) {
$item['children'] = $children;