refactor: 上传相关优化

This commit is contained in:
2025-06-12 14:50:20 +08:00
parent 6867563746
commit 5fa0556bb6
2 changed files with 75 additions and 7 deletions

View File

@@ -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;
}