Browse Source

[增加]系统异常自定义模板,默认关闭Debug

Anyon 7 years ago
parent
commit
a0a5bb6afe

+ 4 - 4
application/config.php

@@ -19,7 +19,7 @@ return [
     // 应用命名空间
     'app_namespace'          => 'app',
     // 应用调试模式
-    'app_debug'              => true,
+    'app_debug'              => false,
     // 应用Trace
     'app_trace'              => false,
     // 应用模式状态
@@ -136,13 +136,13 @@ return [
     // 视图输出字符串内容替换
     'view_replace_str'       => [],
     // 默认跳转页面对应的模板文件
-    'dispatch_success_tmpl'  => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
-    'dispatch_error_tmpl'    => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
+    'dispatch_success_tmpl'  => APP_PATH . 'extra' . DS . 'view' . DS . 'handler.jump.html',
+    'dispatch_error_tmpl'    => APP_PATH . 'extra' . DS . 'view' . DS . 'handler.jump.html',
     // +----------------------------------------------------------------------
     // | 异常及错误设置
     // +----------------------------------------------------------------------
     // 异常页面的模板文件
-    'exception_tmpl'         => THINK_PATH . 'tpl' . DS . 'think_exception.tpl',
+    'exception_tmpl'         => APP_PATH . 'extra' . DS . 'view' . DS . 'handler.exception.html',
     // 错误显示信息,非调试模式有效
     'error_message'          => '页面错误!请稍后再试~',
     // 显示错误信息

+ 50 - 0
application/extra/view/handler.exception.html

@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+        <title><?php echo \think\Lang::get('System Error'); ?></title>
+        <style type="text/css">
+            html{background:url('http://plugs.cdn.cuci.cc/theme/default/img/paper.jpg')!important;}
+            a,fieldset,img{border:0;}
+            a{color:#221919;text-decoration:none;outline:none;}
+            a:hover{color:#3366cc;text-decoration:underline;}
+            body{font-size:24px;color:#B7AEB4;}
+            body a.link,body h1,body p{-webkit-transition:opacity 0.5s ease-in-out;-moz-transition:opacity 0.5s ease-in-out;transition:opacity 0.5s ease-in-out;}
+            #wrapper{text-align:center;margin:100px auto;width:594px;}
+            a.link{text-shadow:0px 1px 2px white;font-weight:600;color:#3366cc;opacity:0;}
+            h1{text-shadow:0px 1px 2px white;font-size:24px;opacity:0;}
+            img{-webkit-transition:opacity 1s ease-in-out;-moz-transition:opacity 1s ease-in-out;transition:opacity 1s ease-in-out;height:202px;width:199px;opacity:0;}
+            p{text-shadow:0px 1px 2px white;font-weight:normal;font-weight:200;opacity:0;}
+            .fade{opacity:1;}
+            @media only screen and (min-device-width:320px) and (max-device-width:480px){
+                #wrapper{margin:40px auto;text-align:center;width:315px;}
+            }
+        </style>
+        <script src="http://cdn.bootcss.com/jquery/1.7.1/jquery.min.js"></script>
+        <!--解决 IE6 背景缓存-->
+        <!--[if IE 6]><script type="text/javascript">document.execCommand("BackgroundImageCache", false, true);</script><![endif]-->
+        <script type="text/javascript">
+            $(document).ready(function () {
+                if (!$.browser.msie) {
+                    $("img").addClass('fade').delay(300).queue(function (next) {
+                        $("h1, p").addClass("fade");
+                        $("a.link").css("opacity", 1);
+                        next();
+                    });
+                } else {
+                    $("img, h1, p").addClass('fade');
+                    $('a.link').css('opacity', 1);
+                }
+            });
+        </script>
+    </head>
+    <body>
+        <div id="wrapper">
+            <a href="javascript:void(0)"><img src="http://plugs.cdn.cuci.cc/theme/default/img/505_icon.png"></a>
+            <div>
+                <h1></h1>
+                <p><?php echo nl2br(htmlentities($message)); ?></p>
+            </div>
+        </div>
+    </body>
+</html>

+ 49 - 0
application/extra/view/handler.jump.html

@@ -0,0 +1,49 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+        <title>跳转提示</title>
+        <style type="text/css">
+            *{ padding: 0; margin: 0; }
+            body{ background: #fff; font-family: "Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif; color: #333; font-size: 16px; }
+            .system-message{ padding: 24px 48px; }
+            .system-message h1{ font-size: 100px; font-weight: normal; line-height: 120px; margin-bottom: 12px; }
+            .system-message .jump{ padding-top: 10px; }
+            .system-message .jump a{ color: #333; }
+            .system-message .success,.system-message .error{ line-height: 1.8em; font-size: 36px; }
+            .system-message .detail{ font-size: 12px; line-height: 20px; margin-top: 12px; display: none; }
+        </style>
+    </head>
+    <body>
+        <div class="system-message">
+            <?php switch ($code) {?>
+            <?php case 1:?>
+            <h1>:)</h1>
+            <p class="success"><?php echo(strip_tags($msg));?></p>
+            <?php break;?>
+            <?php case 0:?>
+            <h1>:(</h1>
+            <p class="error"><?php echo(strip_tags($msg));?></p>
+            <?php break;?>
+            <?php } ?>
+            <p class="detail"></p>
+            <p class="jump">
+                页面自动 <a id="href" href="<?php echo($url);?>">跳转</a> 等待时间: <b id="wait"><?php echo($wait);?></b>
+            </p>
+        </div>
+        <script type="text/javascript">
+            (function () {
+                var wait = document.getElementById('wait'),
+                        href = document.getElementById('href').href;
+                var interval = setInterval(function () {
+                    var time = --wait.innerHTML;
+                    if (time <= 0) {
+                        location.href = href;
+                        clearInterval(interval);
+                    }
+                    ;
+                }, 1000);
+            })();
+        </script>
+    </body>
+</html>