Sfoglia il codice sorgente

fix 新版后台模板修正

magicblack 7 mesi fa
parent
commit
83b4f3e04c
2 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 1 0
      thinkphp/lang/zh-cn.php
  2. 11 1
      thinkphp/library/think/view/driver/Think.php

+ 1 - 0
thinkphp/lang/zh-cn.php

@@ -133,4 +133,5 @@ return [
     'invalid Request method'                                    => '无效的请求类型',
     'invalid token'                                             => '令牌数据无效',
     'not conform to the rules'                                  => '规则错误',
+    'Please copy file'                                          => '请复制',
 ];

+ 11 - 1
thinkphp/library/think/view/driver/Think.php

@@ -79,7 +79,17 @@ class Think
         }
         // 模板不存在 抛出异常
         if (!is_file($template)) {
-            throw new TemplateNotFoundException('template not exists:' . $template, $template);
+            // 新版后台自动复制模板
+            if (strpos($template, '/view_new') !== false) {
+                $sourcePath = str_replace('/view_new', '/view', $template);
+                if (file_exists($sourcePath)) {
+                    if (!copy($sourcePath, $template)) {
+                        throw new TemplateNotFoundException('Please copy file:' . $sourcePath . ' => ' . $template);
+                    }
+                }
+            }else{
+                throw new TemplateNotFoundException('template not exists:' . $template, $template);
+            }
         }
         // 记录视图信息
         App::$debug && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info');