From ede9cb269efb7d5dbf13ca9beb83d00a7c3750de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E6=9C=88=E6=B4=9E=E5=A4=A9?= <409791659@qq.com> Date: Sat, 18 Apr 2020 13:47:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=90=E8=A1=8C=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/model/Config.php | 12 ++++++++++++ application/common/controller/Adminbase.php | 16 ++++++++++++++++ yzncms.sql | 5 +++++ 3 files changed, 33 insertions(+) diff --git a/application/admin/model/Config.php b/application/admin/model/Config.php index 5e6a11b3..8ca38ae3 100644 --- a/application/admin/model/Config.php +++ b/application/admin/model/Config.php @@ -81,5 +81,17 @@ class Config extends Model } return $newConfigs; } + + public function getGroupConfig($group = 'dev'){ + $result = []; + + $configs = self::where('group', '=', $group)->field('name,value')->select(); + + foreach ($configs as $config) { + $result[$config['name']] = $config['value']; + } + + return $result; + } } diff --git a/application/common/controller/Adminbase.php b/application/common/controller/Adminbase.php index 0f1f37ba..6eb39c60 100644 --- a/application/common/controller/Adminbase.php +++ b/application/common/controller/Adminbase.php @@ -33,6 +33,10 @@ class Adminbase extends Base protected function initialize() { parent::initialize(); + + //系统运行模式配置 + $this->config(); + $this->rule = strtolower($this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action()); // 检测是否需要验证登录 if (!$this->match($this->noNeedLogin)) { @@ -182,5 +186,17 @@ class Adminbase extends Base } return $map; } + + //系统运行模式配置 + private function config() + { + $config = model('admin/Config')->getGroupConfig('dev'); + if ($config['dev_statue'] == 1) { + config('app_debug', $config['dev_debug']== 1 ? true : false); + config('app_trace', $config['dev_trace']== 1 ? true : false); + config('trace.type', $config['dev_trace_type'] == 1 ? 'Html' : 'Console'); + } + + } } diff --git a/yzncms.sql b/yzncms.sql index 5e1e2391..7640c2a9 100644 --- a/yzncms.sql +++ b/yzncms.sql @@ -211,6 +211,11 @@ INSERT INTO `yzn_config` VALUES ('20', 'upload_thumb_water_pic', 'image', '水 INSERT INTO `yzn_config` VALUES ('21', 'upload_thumb_water_position', 'radio', '水印位置', 'upload', '1:左上角\r\n2:上居中\r\n3:右上角\r\n4:左居中\r\n5:居中\r\n6:右居中\r\n7:左下角\r\n8:下居中\r\n9:右下角', '只有开启水印功能才生效', '1552435257', '1552436082', '1', '9', '7'); INSERT INTO `yzn_config` VALUES ('22', 'upload_thumb_water_alpha', 'text', '水印透明度', 'upload', '', '请输入0~100之间的数字,数字越小,透明度越高', '1552435299', '1552436083', '1', '50', '8'); +INSERT INTO `yzn_config` VALUES ('23', 'dev_statue', 'switch', '配置状态', 'dev', '', '', '1587188343', '1587188343', '1', '1', '100'); +INSERT INTO `yzn_config` VALUES ('24', 'dev_debug', 'radio', 'Debug模式', 'dev', '1:开启\r\n2:关闭', '', '1587188385', '1587188506', '1', '2', '110'); +INSERT INTO `yzn_config` VALUES ('25', 'dev_trace', 'radio', 'Trace模式', 'dev', '1:开启\r\n2:关闭', '', '1587188425', '1587188510', '1', '2', '120'); +INSERT INTO `yzn_config` VALUES ('26', 'dev_trace_type', 'radio', 'Trace类型', 'dev', '1:Html\r\n2:Console', '', '1587188472', '1587188513', '1', '1', '130'); + -- ---------------------------- -- Table structure for `yzn_field_type` -- ---------------------------- -- Gitee