全栈小学生 bee973460f up
2024-12-12 18:29:24 +08:00

76 lines
2.6 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 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace core\dict;
use app\service\admin\addon\AddonService;
class WebLink extends BaseDict
{
/**
* 系统weblink页面链接
* @param array $params
* @return array|false|mixed|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function load(array $params = [])
{
if (!empty($params[ 'params' ][ 'addon' ])) {
$addons = [ $params[ 'params' ][ 'addon' ] ];
} else {
$addons = $this->getLocalAddons();
}
$link_files = [];
foreach ($addons as $v) {
$link_path = $this->getAddonDictPath($v) . "web" . DIRECTORY_SEPARATOR . "web_links.php";
if (is_file($link_path)) {
$link_files[ $v ] = $link_path;
}
}
$addon_service = new AddonService();
$addon_info_list = $addon_service->getAddonListByKeys(array_keys($link_files));
if (!empty($params[ 'params' ][ 'query' ]) && $params[ 'params' ][ 'query' ] == 'addon') {
$list_key = array_column($addon_info_list, 'key');
$addon_info_list = array_combine($list_key, $addon_info_list);
return $addon_info_list;
} else {
$links = $params[ 'data' ];
foreach ($link_files as $k => $v) {
$addon_link = include $v;
if (!empty($addon_link)) {
$addon_info = [];
foreach ($addon_info_list as $ck => $cv) {
if ($cv[ 'key' ] == $k) {
$addon_info = $cv;
break;
}
}
foreach ($addon_link as $ck => $cv) {
$addon_link[ $ck ][ 'addon_info' ] = $addon_info;
}
$links = array_merge($links, $addon_link);
}
}
return $links;
}
}
}