mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-23 07:40:18 +00:00
refactor:优化初始化接口的上传配置 key
This commit is contained in:
parent
e9e0792b2a
commit
863b0de034
@ -39,7 +39,7 @@ class Index extends Backend
|
||||
'version' => get_sys_config('version'),
|
||||
'cdnUrl' => full_url(),
|
||||
'apiUrl' => Config::get('buildadmin.api_url'),
|
||||
'upload' => keys_to_camel_case(get_upload_config()),
|
||||
'upload' => keys_to_camel_case(get_upload_config(), ['max_size', 'save_name', 'allowed_suffixes', 'allowed_mime_types']),
|
||||
],
|
||||
'terminal' => [
|
||||
'installServicePort' => Config::get('terminal.install_service_port'),
|
||||
|
@ -72,7 +72,7 @@ class Index extends Frontend
|
||||
'recordNumber' => get_sys_config('record_number'),
|
||||
'version' => get_sys_config('version'),
|
||||
'cdnUrl' => full_url(),
|
||||
'upload' => keys_to_camel_case(get_upload_config()),
|
||||
'upload' => keys_to_camel_case(get_upload_config(), ['max_size', 'save_name', 'allowed_suffixes', 'allowed_mime_types']),
|
||||
],
|
||||
'openMemberCenter' => Config::get('buildadmin.open_member_center'),
|
||||
'userInfo' => $this->auth->getUserInfo(),
|
||||
|
@ -433,16 +433,18 @@ if (!function_exists('get_auth_token')) {
|
||||
if (!function_exists('keys_to_camel_case')) {
|
||||
|
||||
/**
|
||||
* 将数组所有 key 的命名方式转换为小写驼峰
|
||||
* @param array $array
|
||||
* 将数组 key 的命名方式转换为小写驼峰
|
||||
* @param array $array 被转换的数组
|
||||
* @param array $keys 要转换的 key,默认所有
|
||||
* @return array
|
||||
*/
|
||||
function keys_to_camel_case(array $array): array
|
||||
function keys_to_camel_case(array $array, array $keys = []): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($array as $key => $value) {
|
||||
// 将键名转换为驼峰命名
|
||||
$camelCaseKey = parse_name($key, 1, false);
|
||||
$camelCaseKey = $keys && in_array($key, $keys) ? parse_name($key, 1, false) : $key;
|
||||
|
||||
if (is_array($value)) {
|
||||
// 如果值是数组,递归转换
|
||||
$result[$camelCaseKey] = keys_to_camel_case($value);
|
||||
|
Loading…
Reference in New Issue
Block a user