refactor: 上传相关优化
This commit is contained in:
@@ -171,8 +171,25 @@ class SiteConfig
|
||||
if (!empty($configs)) {
|
||||
$configs_map = [];
|
||||
foreach ($configs as $cfg) {
|
||||
$configs_map[$cfg['name']] = $cfg;
|
||||
$current = &$configs_map;
|
||||
|
||||
// 根据name中"."拆分为多维数组
|
||||
$parts = explode('.', $cfg['name']);
|
||||
foreach ($parts as $part) {
|
||||
if (!isset($current[$part])) {
|
||||
$current[$part] = [];
|
||||
}
|
||||
$current = &$current[$part];
|
||||
}
|
||||
$current = [
|
||||
'id' => $cfg['id'],
|
||||
'title' => $cfg['title'],
|
||||
'name' => $cfg['name'],
|
||||
'value' => $cfg['value']
|
||||
];
|
||||
}
|
||||
unset($current);
|
||||
|
||||
return $configs_map;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user