diff --git a/convention.php b/convention.php index 15e34963..31a0a0c1 100644 --- a/convention.php +++ b/convention.php @@ -116,6 +116,8 @@ return [ // +---------------------------------------------------------------------- 'template' => [ + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 + 'auto_rule' => 1, // 模板引擎类型 支持 php think 支持扩展 'type' => 'Think', // 视图基础目录,配置目录为所有模块的视图起始目录 diff --git a/helper.php b/helper.php index c2e7ffe9..12683cfd 100644 --- a/helper.php +++ b/helper.php @@ -443,9 +443,6 @@ if (!function_exists('view')) { */ function view($template = '', $vars = [], $replace = [], $code = 200) { - if ('' === $template) { - $template = Loader::parseName(request()->action(true)); - } return Response::create($template, 'view', $code)->replace($replace)->assign($vars); } } diff --git a/library/think/Controller.php b/library/think/Controller.php index 80b77d90..77225b73 100644 --- a/library/think/Controller.php +++ b/library/think/Controller.php @@ -117,10 +117,6 @@ class Controller */ protected function fetch($template = '', $vars = [], $replace = [], $config = []) { - if ('' === $template) { - $template = Loader::parseName($this->request->action(true)); - } - return $this->view->fetch($template, $vars, $replace, $config); } diff --git a/library/think/view/driver/Php.php b/library/think/view/driver/Php.php index fa505350..661932e0 100644 --- a/library/think/view/driver/Php.php +++ b/library/think/view/driver/Php.php @@ -132,7 +132,7 @@ class Php if ($controller) { if ('' == $template) { // 如果模板文件名为空 按照默认规则定位 - $template = str_replace('.', DS, $controller) . $depr . $request->action(); + $template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action()); } elseif (false === strpos($template, $depr)) { $template = str_replace('.', DS, $controller) . $depr . $template; } diff --git a/library/think/view/driver/Think.php b/library/think/view/driver/Think.php index 46829d51..b36eeff3 100644 --- a/library/think/view/driver/Think.php +++ b/library/think/view/driver/Think.php @@ -127,7 +127,7 @@ class Think if ($controller) { if ('' == $template) { // 如果模板文件名为空 按照默认规则定位 - $template = str_replace('.', DS, $controller) . $depr . $request->action(); + $template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action()); } elseif (false === strpos($template, $depr)) { $template = str_replace('.', DS, $controller) . $depr . $template; }