From 46a41c86ea8308d8754b040e4bf28bb67e1ea202 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Tue, 17 Dec 2019 09:03:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Elayout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/base/CatchController.php | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/extend/catcher/base/CatchController.php b/extend/catcher/base/CatchController.php index cd13bd6..058d26b 100644 --- a/extend/catcher/base/CatchController.php +++ b/extend/catcher/base/CatchController.php @@ -8,6 +8,10 @@ abstract class CatchController { protected $data = []; + public function __construct() + { + $this->loadConfig(); + } /** * * @time 2019年11月28日 @@ -21,15 +25,16 @@ abstract class CatchController $stack = \debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $end = end($stack); - View::config([ - 'view_path' => CatchAdmin::getViews()[$this->getModule($end['class'])] + 'view_path' => CatchAdmin::getViews()[$this->getModule($end['class'])], ]); if (!empty($this->data)) { $data = array_merge($this->data, $data); } + $data['layout'] = root_path('view') . 'layout.html'; + return View::fetch($template ? : $this->getTemp($end['class'], $end['function']), $data); } @@ -67,6 +72,23 @@ abstract class CatchController return explode('\\', $class)[1]; } + /** + * + * + * @time 2019年12月15日 + * @return void + */ + protected function loadConfig() + { + $module = explode('\\', get_class($this))[1]; + + $moduleConfig = CatchAdmin::moduleDirectory($module) . 'config.php'; + + if (file_exists(CatchAdmin::moduleDirectory($module) . 'config.php')) { + app()->config->load($moduleConfig); + } + } + /** * * @time 2019年12月13日