niucloud-admin/niucloud/app/service/api/diy/DiyConfigService.php
全栈小学生 e539980215 update
2024-09-28 09:31:13 +08:00

101 lines
3.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\api\diy;
use app\service\core\addon\CoreAddonService;
use app\service\core\diy\CoreDiyConfigService;
use core\base\BaseApiService;
/**
* 自定义页面相关配置服务层
* Class DiyConfigService
* @package app\service\admin\diy
*/
class DiyConfigService extends BaseApiService
{
/**
* 获取底部导航列表
* @param array $params
* @return array|mixed
*/
public function getBottomList($params = [])
{
$list = ( new CoreDiyConfigService() )->getBottomList($params);
$apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]);
$bottom_list_keys = array_column($list, 'key');
// 排除没有底部导航的应用
foreach ($apps as $k => $v) {
if (!in_array($v[ 'key' ], $bottom_list_keys)) {
unset($apps[ $k ]);
}
}
$apps = array_values($apps);
// 单应用,排除 系统 底部导航设置
if (count($list) > 1 && count($apps) == 1) {
foreach ($list as $k => $v) {
if ($v[ 'key' ] = 'app') {
unset($list[ $k ]);
break;
}
}
$list = array_values($list);
}
$res = [];
foreach ($list as $k => $v) {
$res[] = $this->getBottomConfig($v[ 'key' ]);
}
return $res;
}
/**
* 获取底部导航配置
* @param $key
* @return array
*/
public function getBottomConfig($key)
{
// 检测当前站点是多应用还是单应用
if ($key == 'app') {
$apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]);
$list = ( new CoreDiyConfigService() )->getBottomList();
$bottom_list_keys = array_column($list, 'key');
// 排除没有底部导航的应用
foreach ($apps as $k => $v) {
if (!in_array($v[ 'key' ], $bottom_list_keys)) {
unset($apps[ $k ]);
}
}
$apps = array_values($apps);
if (count($apps) == 1) {
$key = $apps[ 0 ][ 'key' ];
}
}
return ( new CoreDiyConfigService() )->getBottomConfig($key);
}
/**
* 获取启动页配置
* @return array
*/
public function getStartUpPageConfig($type)
{
return ( new CoreDiyConfigService() )->getStartUpPageConfig($type);
}
}