diff --git a/app/admin/controller/YunzerController.php b/app/admin/controller/YunzerController.php index 9d0dd89..aabcc43 100644 --- a/app/admin/controller/YunzerController.php +++ b/app/admin/controller/YunzerController.php @@ -405,30 +405,49 @@ class YunzerController extends Base } # 配置值 public function configvalue() - { - $req = request(); - if ($req->isPost()) { - $post = input('post.'); - if (empty($post)) { - Log::record('更新配置值', 0, '数据不能为空', '系统配置'); - $this->returnCode(1, '数据不能为空'); - } - $oConfig = new YzAdminConfig(); - $updateAll = $oConfig->updateAll($post); - if (empty($updateAll)) { - Log::record('更新配置值', 0, '更新配置值失败', '系统配置'); - $this->returnCode(1, '更新配置值失败'); - } - Log::record('更新配置值', 1, '', '系统配置'); - $this->returnCode(0); - } else { - $lists = AdminConfig::order('config_sort DESC,config_id')->select(); - View::assign([ - 'lists' => $lists - ]); - return View::fetch(); - } - } + { + $req = request(); + if ($req->isPost()) { + $post = input('post.'); + if (empty($post)) { + Log::record('更新配置值', 0, '数据不能为空', '系统配置'); + $this->returnCode(1, '数据不能为空'); + } + + // 获取所有配置项,检查 config_type 为 4 的项 + $allConfigs = AdminConfig::order('config_sort DESC,config_id')->select(); + foreach ($allConfigs as $config) { + if ($config['config_type'] == 4) { + $checkboxName = $config['config_name'] . '_checkbox'; + $configName = $config['config_name']; + if (!isset($post[$checkboxName])) { + // 复选框未选中,手动添加对应的值为 0 + $post[$configName] = 0; + } else { + // 复选框选中,确保值为 1 + $post[$configName] = 1; + } + // 移除 checkbox 字段 + unset($post[$checkboxName]); + } + } + + $oConfig = new YzAdminConfig(); + $updateAll = $oConfig->updateAll($post); + if (empty($updateAll)) { + Log::record('更新配置值', 0, '更新配置值失败', '系统配置'); + $this->returnCode(1, '更新配置值失败'); + } + Log::record('更新配置值', 1, '', '系统配置'); + $this->returnCode(0); + } else { + $lists = AdminConfig::order('config_sort DESC,config_id')->select(); + View::assign([ + 'lists' => $lists + ]); + return View::fetch(); + } + } // 邮件配置 diff --git a/app/admin/view/yunzer/configvalue.php b/app/admin/view/yunzer/configvalue.php index 7bd8318..90968c8 100644 --- a/app/admin/view/yunzer/configvalue.php +++ b/app/admin/view/yunzer/configvalue.php @@ -6,6 +6,7 @@ border-radius: 8px; /* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); */ } + .config-header { display: flex; align-items: center; @@ -13,15 +14,18 @@ padding-bottom: 15px; border-bottom: 1px solid #eee; } + .config-header span { font-size: 18px; color: #2c3e50; font-weight: 500; margin-right: 20px; } + .config-header a { text-decoration: none; } + .config-header a span { padding: 6px 15px; background: #f8f9fa; @@ -30,56 +34,70 @@ font-size: 14px; transition: all 0.3s; } + .config-header a span:hover { background: #e9ecef; color: #409EFF; } + .layui-form-item { margin-bottom: 25px; } + .layui-form-label { color: #606266; font-weight: 500; } + .layui-input { border-radius: 4px; } + .layui-input:focus { border-color: #409EFF; } + .layui-textarea { border-radius: 4px; min-height: 100px; } + .layui-word-aux { color: #909399; } + .layui-btn { border-radius: 4px; - box-shadow: 0 2px 5px rgba(0,0,0,0.1); + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); transition: all 0.3s; } + .layui-btn:hover { transform: translateY(-1px); - box-shadow: 0 4px 8px rgba(0,0,0,0.15); + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); } + .upload-preview { margin-top: 10px; } + .upload-preview img { border-radius: 4px; - box-shadow: 0 2px 5px rgba(0,0,0,0.1); + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); transition: all 0.3s; } + .upload-preview img:hover { transform: scale(1.02); } + .save-button-container { text-align: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid #eee; } + .save-button-container .layui-btn { padding: 0 50px; height: 40px; @@ -95,69 +113,84 @@ 站点管理 --> - +