diff --git a/.example.env b/.example.env index a14b899..4a98ed5 100644 --- a/.example.env +++ b/.example.env @@ -55,6 +55,6 @@ STRICT_EVENT=true # 严格要求每个页面都建立js文件 STRICT_VIEW_JS=true -MAKE_VIEW_JS_WHILE_MISSING=false +MAKE_VIEW_WHILE_MISSING=false UPDATE_LEVEL=production \ No newline at end of file diff --git a/extend/base/common/command/admin/VersionBase.php b/extend/base/common/command/admin/VersionBase.php index 8505012..97858cf 100644 --- a/extend/base/common/command/admin/VersionBase.php +++ b/extend/base/common/command/admin/VersionBase.php @@ -12,12 +12,12 @@ use think\console\Output; class VersionBase extends Command { - public const VERSION = 'v2.0.72'; + public const VERSION = 'v2.0.73'; public const LAYUI_VERSION = '2.8.17'; public const COMMENT = [ - '增加自动创建缺失的js配置项;', + '修改创建缺失文件逻辑;', '发布新版本', ]; diff --git a/extend/base/common/controller/AdminControllerBase.php b/extend/base/common/controller/AdminControllerBase.php index 18edf07..2cbd82e 100644 --- a/extend/base/common/controller/AdminControllerBase.php +++ b/extend/base/common/controller/AdminControllerBase.php @@ -6,7 +6,6 @@ use app\admin\model\SystemAdmin; use app\BaseController; use app\common\constants\AdminConstant; use app\common\service\AuthService; -use app\common\tools\PathTools; use think\facade\Env; use think\facade\View; use think\Model; @@ -159,12 +158,7 @@ class AdminControllerBase extends BaseController $content_js .= View::layout(false)->fetchJS($common_template); $content_js .= View::layout(false)->fetchJS($template); } catch (TemplateNotFoundException $th) { - if (Env::get('adminsystem.make_view_js_while_missing', false)) { - $template_file_path = $th->getTemplate(); - PathTools::intiDir($template_file_path); - file_put_contents($template_file_path, ''); - $content_js = ''; - } elseif (Env::get('adminsystem.strict_view_js', true)) { + if (Env::get('adminsystem.strict_view_js', true)) { throw $th; } } diff --git a/extend/think/view/driver/Think.php b/extend/think/view/driver/Think.php index 499a035..b485801 100644 --- a/extend/think/view/driver/Think.php +++ b/extend/think/view/driver/Think.php @@ -13,7 +13,9 @@ declare(strict_types=1); namespace think\view\driver; +use app\common\tools\PathTools; use think\App; +use think\facade\Env; use think\helper\Str; use think\Template; use think\template\exception\TemplateNotFoundException; @@ -206,15 +208,22 @@ class Think $view_file_path = ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); $file_path = ''; - if (is_file($app_path . $view_file_path)) { + $default_file_path = $app_path . $view_file_path; + if (is_file($default_file_path)) { // 优先app下的view - $file_path = $app_path . $view_file_path; + $file_path = $default_file_path; } elseif (is_file($base_app_path . $view_file_path)) { // 查找extend下的view $file_path = $base_app_path . $view_file_path; - } else { + } elseif (is_file($view_app_path . $view_file_path)) { // 查找根目录下的view $file_path = $view_app_path . $view_file_path; + } else { + $file_path = $default_file_path; + if (Env::get('adminsystem.make_view_while_missing', false)) { + PathTools::intiDir($file_path); + file_put_contents($file_path, ''); + } } $this->template->base_view_path = dirname($file_path) . DIRECTORY_SEPARATOR;