From 6ee13de48e7763f37484727f0118e4e18b232104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8=E6=A0=88=E5=B0=8F=E5=AD=A6=E7=94=9F?= <1518079521@qq.com> Date: Mon, 10 Mar 2025 15:38:46 +0800 Subject: [PATCH] Update Upgrade.php --- niucloud/app/upgrade/v101/Upgrade.php | 82 ++++++++++++++------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/niucloud/app/upgrade/v101/Upgrade.php b/niucloud/app/upgrade/v101/Upgrade.php index 6f31229ff..5d102592d 100644 --- a/niucloud/app/upgrade/v101/Upgrade.php +++ b/niucloud/app/upgrade/v101/Upgrade.php @@ -391,51 +391,53 @@ class Upgrade $addon_theme = $this->getVipcardTheme(); } - foreach ($addon_theme[ 'theme_color' ] as $k => $v) { - $data[] = [ - 'type' => 'app', - 'addon' => $value[ 'key' ], - 'site_id' => $site_id, - 'title' => $v[ 'title' ], - 'theme' => $v[ 'theme' ], - 'default_theme' => $v[ 'theme' ], - 'theme_type' => 'default', - 'is_selected' => $k == 0 ? 1 : 0, - 'create_time' => time(), - ]; - } - $addon_data = ( new addon() )->field('key')->where([ [ 'support_app', '=', $value[ 'key' ] ] ])->select()->toArray(); - if (!empty($addon_data)) { - foreach ($addon_data as $v) { - foreach ($addon_theme[ 'theme_color' ] as $theme_k => $theme_v) { - $data[] = [ - 'type' => 'addon', - 'addon' => $v[ 'key' ], - 'site_id' => $site_id, - 'title' => $theme_v[ 'title' ], - 'theme' => $theme_v[ 'theme' ], - 'default_theme' => $theme_v[ 'theme' ], - 'theme_type' => 'default', - 'is_selected' => $theme_k == 0 ? 1 : 0, - 'create_time' => time(), - ]; + if (!empty($addon_theme)) { + foreach ($addon_theme[ 'theme_color' ] as $k => $v) { + $data[] = [ + 'type' => 'app', + 'addon' => $value[ 'key' ], + 'site_id' => $site_id, + 'title' => $v[ 'title' ], + 'theme' => $v[ 'theme' ], + 'default_theme' => $v[ 'theme' ], + 'theme_type' => 'default', + 'is_selected' => $k == 0 ? 1 : 0, + 'create_time' => time(), + ]; + } + $addon_data = ( new addon() )->field('key')->where([ [ 'support_app', '=', $value[ 'key' ] ] ])->select()->toArray(); + if (!empty($addon_data)) { + foreach ($addon_data as $v) { + foreach ($addon_theme[ 'theme_color' ] as $theme_k => $theme_v) { + $data[] = [ + 'type' => 'addon', + 'addon' => $v[ 'key' ], + 'site_id' => $site_id, + 'title' => $theme_v[ 'title' ], + 'theme' => $theme_v[ 'theme' ], + 'default_theme' => $theme_v[ 'theme' ], + 'theme_type' => 'default', + 'is_selected' => $theme_k == 0 ? 1 : 0, + 'create_time' => time(), + ]; + } } } } } - $diy_theme_model = new DiyTheme(); - foreach ($data as $k => &$v) { - $theme_count = $diy_theme_model->where([ - [ 'site_id', "=", $site_id ], - [ 'title', "=", $v[ 'title' ] ], - [ 'addon', "=", $v[ 'addon' ] ] - ])->count(); - // 如果已有该主题风格颜色则不再添加 - if ($theme_count > 0) { - unset($data[ $k ]); - } - } if (!empty($data)) { + $diy_theme_model = new DiyTheme(); + foreach ($data as $k => &$v) { + $theme_count = $diy_theme_model->where([ + [ 'site_id', "=", $site_id ], + [ 'title', "=", $v[ 'title' ] ], + [ 'addon', "=", $v[ 'addon' ] ] + ])->count(); + // 如果已有该主题风格颜色则不再添加 + if ($theme_count > 0) { + unset($data[ $k ]); + } + } $diy_theme_model->insertAll($data); } return true;