更新内容

This commit is contained in:
2019-06-29 22:51:20 +08:00
parent 22d9666102
commit 6b5142674f
21 changed files with 938 additions and 11 deletions

View File

@@ -12,7 +12,7 @@
return [
// 生成应用公共文件
'__file__' => ['common.php'],
'__dir__' => ['controller', 'model', 'view'],
'__dir__' => ['controller', 'model', 'view', 'validate'],
'controller' => ['Index', 'admin/Config', 'admin/Menu', 'admin/Member', 'admin/Content', 'admin/Action', 'admin/Ad', 'admin/Attribute', 'admin/Category', 'admin/Channel', 'admin/Client', 'admin/Database', 'admin/Model', 'admin/Link', 'admin/Seo', 'admin/Addons', 'admin/Form', 'admin/Group'],
'model' => ['Member', 'Config', 'Content', 'Channel', 'Client', 'Model', 'Link', 'Ad', 'AdPlace'],
'view' => ['admin/index/index', 'admin/config/group', 'admin/member/index', 'admin/content/index', 'admin/category/index'],

View File

@@ -16,6 +16,7 @@ use app\BaseController;
class Admin extends BaseController {
protected $middleware = [
'\app\middleware\Validate',
'\app\middleware\AdminAuth' => ['except' => ['login']],
'\app\middleware\Admin'
];

View File

@@ -7,11 +7,51 @@ class Index extends BaseController {
protected $middleware = ['\app\middleware\Front'];
/**
* @title 网站首页
*/
public function index() {
return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V6<br/><span style="font-size:30px">13载初心不改 - 你值得信赖的PHP框架</span></p></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="eab4b9f840753f8e7"></think>';
}
public function miss($name = 'ThinkPHP6') {
return 'hello,' . $name;
/**
* @title 搜索页
*/
public function search() {
}
/**
* @title 专题页
*/
public function topic() {
}
/**
* @title 模型数据列表
*/
public function lists() {
}
/**
* @title 栏目数据列表
*/
public function category() {
}
/**
* @title 模型数据详情
*/
public function detail() {
}
/**
* @title 未知页面调整到此方法
*/
public function miss() {
}
}

View File

@@ -22,6 +22,15 @@ class Index extends Admin{
public function index(){
}
/**
* @title 更新缓存
*/
public function clear(){
}
/**
* @title 后台登录
*/
public function login(){
if ($this->request->isAjax()) {
Session::set('user', ['uid'=>1,'username'=>'admin']);

View File

@@ -10,7 +10,7 @@ namespace app\controller\admin;
use app\controller\Admin;
class Member extends Admin{
class User extends Admin{
/**
* @title 系统首页

View File

@@ -0,0 +1,8 @@
<?php
namespace app\controller\api;
use app\BaseController;
class Index extends BaseController {
}

View File

@@ -0,0 +1,8 @@
<?php
namespace app\controller\user;
use app\BaseController;
class Index extends BaseController {
}

View File

@@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\middleware;
use think\Response;
class Validate {
/**
* @param \think\Request $request
* @param \Closure $next
* @return mixed|\think\response\Json
*/
public function handle($request, \Closure $next) {
//获取当前参数
$params = $request->param();
//获取访问控制器
$controller = strtr(strtolower($request->controller()), '.', '\\');
//获取操作名,用于验证场景scene
$scene = $request->action();
$validate = "app\\validate\\" . $controller;
//仅当验证器存在时 进行校验
if (class_exists($validate) && $request->isPost()) {
$v = new $validate;
//仅当存在验证场景才校验
if ($v->hasScene($scene)) {
//设置当前验证场景
$v->scene($scene);
if (!$v->check($params)) {
//校验不通过则直接返回错误信息
$data = array(
'msg' => $v->getError(),
'code' => 1,
'data' => '',
'time' => time(),
);
return Response::create($data, 'json', 200);
}
}
}
return $next($request);
}
}

View File

@@ -0,0 +1,29 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\validate\admin;
use think\Validate;
class Index extends Validate {
protected $rule = [
'username' => 'require',
'password' => 'require',
];
protected $message = [];
/**
* @title 登录验证
*/
public function sceneLogin() {
return $this->only(['username','password']);
}
}

227
app/view/admin/base.html Normal file
View File

@@ -0,0 +1,227 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
<meta charset="utf-8">
<title>SentCMS后台管理系统-{$meta|default="后台首页"}</title>
<link href="__static__/libs/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<link href="__static__/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="__static__/libs/nanoscroller/nanoscroller.css" />
<link href="__css__/theme_styles.css" rel="stylesheet"/>
{block name="style"}{/block}
</meta>
</head>
<body>
<div id="theme-wrapper">
<header class="navbar" id="header-navbar">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#header-nav">
<span class="sr-only">菜单</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{:url('admin/index/index')}" id="logo">
<img alt="" class="normal-logo logo-white" src="__static__/images/logo.png"/>
<img alt="" class="normal-logo logo-black" src="__static__/images/logo.png"/>
<img alt="" class="small-logo hidden-xs hidden-sm hidden" src="__static__/images/logo.png"/>
</a>
<ul class="nav navbar-nav pull-right visible-xs">
<li class="dropdown profile-dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="/static/images/samples/scarlet-159.png" alt=""/>
<span class="hidden-xs">admin</span> <b class="caret"></b>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<a href="/admin/user/edit.html">
<i class="fa fa-user"></i>
修改资料
</a>
</li>
<li>
<a href="/admin/user/editpwd.html">
<i class="fa fa-cog"></i>
修改密码
</a>
</li>
<li>
<a href="/admin/logout.html">
<i class="fa fa-power-off"></i>
退出后台
</a>
</li>
<li>
<a href="http://www.tensent.cn" target="_blank">
<i class="fa fa-home"></i>
前台首页
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="nav-no-collapse navbar-left pull-left hidden-sm hidden-xs">
<ul class="nav navbar-nav pull-left">
<li>
<a class="btn" id="make-small-nav"> <i class="fa fa-bars"></i>
</a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse" id="header-nav">
<ul class="nav navbar-nav">
<li class="active">
<a href="/admin/index/index.html">
<i class="fa fa-home"></i>
<span>首页</span>
</a>
</li>
<li class="">
<a href="/admin/config/group.html">
<i class="fa fa-laptop"></i>
<span>系统</span>
</a>
</li>
<li class="">
<a href="/admin/category/index.html">
<i class="fa fa-list"></i>
<span>内容</span>
</a>
</li>
<li class="">
<a href="/admin/user/index.html">
<i class="fa fa-user"></i>
<span>会员</span>
</a>
</li>
<li class="">
<a href="/admin/link/index.html">
<i class="fa fa-th"></i>
<span>运营</span>
</a>
</li>
<li class="">
<a href="/admin/addons/index.html">
<i class="fa fa-tags"></i>
<span>扩展</span>
</a>
</li>
<li class="">
<a href="/admin/client/index.html">
<i class="fa fa-android"></i>
<span>客户端</span>
</a>
</li>
</ul>
<ul class="nav navbar-nav pull-right">
<li class="dropdown profile-dropdown hidden-sm hidden-xs">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="/static/images/samples/scarlet-159.png" alt=""/>
<span class="hidden-xs">admin</span> <b class="caret"></b>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<a href="/admin/user/edit.html">
<i class="fa fa-user"></i>
修改资料
</a>
</li>
<li>
<a href="/admin/user/editpwd.html">
<i class="fa fa-cog"></i>
修改密码
</a>
</li>
<li>
<a href="/admin/logout.html">
<i class="fa fa-power-off"></i>
退出后台
</a>
</li>
<li>
<a href="http://www.tensent.cn" target="_blank">
<i class="fa fa-home"></i>
前台首页
</a>
</li>
</ul>
</li>
<li class="visible-lg">
<a href="#" class="btn" onclick="helpIntro();">
<i class="fa fa-question-circle"></i>
操作指南
</a>
</li>
</ul>
</div>
</div>
</header>
<div id="page-wrapper" class="container nav-small">
<div class="row">
<div id="nav-col">
<section id="col-left" class="col-left-nano">
<div id="col-left-inner" class="col-left-nano-content">
<div id="sidebar-nav">
<ul class="nav nav-pills nav-stacked">
<li class="nav-header hidden-sm hidden-xs">后台首页</li>
<li class="">
<a href="/admin/index/clear.html">
<i class="fa fa-refresh"></i>
<span>更新缓存</span>
</a>
</li>
</ul>
</div>
</div>
</section>
<div id="nav-col-submenu"></div>
</div>
<div id="content-wrapper">
<div class="row">
<div class="col-lg-12">
<div class="row">
<div class="col-lg-12">
<div id="content-header" class="clearfix">
<div class="pull-left">
<ol class="breadcrumb">
<li>
<a href="/Admin/index/index.html">后台首页</a>
</li>
<li class="active">
<span>后台首页</span>
</li>
</ol>
</div>
<div class="pull-right hidden-xs">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
{block name="body"}内容{/block}
</div>
</div>
</div>
</div>
<footer id="footer-bar" class="row">
<p id="footer-copyright" class="col-xs-12">Powered by <a href="http://www.tensent.cn" target="_blank">TenSent,Inc.</a></p>
</footer>
</div>
</div>
</div>
</div>
{include file="admin/setting"}
<script src="__js__/skin-changer.js"></script>
<script src="__static__/libs/jquery/jquery.min.js"></script>
<script src="__static__/libs/bootstrap/js/bootstrap.min.js"></script>
<script src="__static__/libs/nanoscroller/jquery.nanoscroller.min.js"></script>
<script type="text/javascript" src="__static__/js/jquery.slimscroll.min.js"></script>
<script type="text/javascript" src="__js__/app.js"></script>
{block name="script"}{/block}
</body>
</html>

View File

@@ -0,0 +1 @@
{extend name="admin/base"/}

View File

@@ -0,0 +1 @@
{extend name="admin/base"/}

View File

@@ -0,0 +1 @@
{extend name="admin/base"/}

View File

@@ -40,13 +40,13 @@
<div class="form-group">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-user"></i></span>
<input type="text" class="form-control" placeholder="用户名" aria-describedby="basic-addon1">
<input type="text" class="form-control" name="username" placeholder="用户名" aria-describedby="basic-addon1">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-lock"></i></span>
<input type="password" class="form-control" placeholder="密码" aria-describedby="basic-addon1">
<input type="password" class="form-control" name="password" placeholder="密码" aria-describedby="basic-addon1">
</div>
</div>
<button class="btn btn-default btn-block" type="submit">确认登录</button>
@@ -64,6 +64,7 @@
</div>
<script src="__static__/libs/jquery/jquery.min.js"></script>
<script src="__static__/libs/layui/layui.all.js"></script>
<script type="text/javascript">
$(function () {
//表单提交
@@ -79,14 +80,14 @@ $(function () {
return false;
function success(data){
if(data.code){
if(data.code == 0){
layer.msg(data.msg, {time:3000, end:function(){
window.location.href = data.url;
}});
} else {
layer.msg(data.msg, {time:3000, end:function(){
//刷新验证码
$(".reloadverify").click();
//$(".reloadverify").click();
}});
}
}

View File

@@ -0,0 +1 @@
{extend name="admin/base"/}

508
app/view/error.tpl Normal file
View File

@@ -0,0 +1,508 @@
<?php
if(!function_exists('parse_padding')){
function parse_padding($source)
{
$length = strlen(strval(count($source['source']) + $source['first']));
return 40 + ($length - 1) * 8;
}
}
if(!function_exists('parse_class')){
function parse_class($name)
{
$names = explode('\\', $name);
return '<abbr title="'.$name.'">'.end($names).'</abbr>';
}
}
if(!function_exists('parse_file')){
function parse_file($file, $line)
{
return '<a class="toggle" title="'."{$file} line {$line}".'">'.basename($file)." line {$line}".'</a>';
}
}
if(!function_exists('parse_args')){
function parse_args($args)
{
$result = [];
foreach ($args as $key => $item) {
switch (true) {
case is_object($item):
$value = sprintf('<em>object</em>(%s)', parse_class(get_class($item)));
break;
case is_array($item):
if(count($item) > 3){
$value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3)));
} else {
$value = sprintf('[%s]', parse_args($item));
}
break;
case is_string($item):
if(strlen($item) > 20){
$value = sprintf(
'\'<a class="toggle" title="%s">%s...</a>\'',
htmlentities($item),
htmlentities(substr($item, 0, 20))
);
} else {
$value = sprintf("'%s'", htmlentities($item));
}
break;
case is_int($item):
case is_float($item):
$value = $item;
break;
case is_null($item):
$value = '<em>null</em>';
break;
case is_bool($item):
$value = '<em>' . ($item ? 'true' : 'false') . '</em>';
break;
case is_resource($item):
$value = '<em>resource</em>';
break;
default:
$value = htmlentities(str_replace("\n", '', var_export(strval($item), true)));
break;
}
$result[] = is_int($key) ? $value : "'{$key}' => {$value}";
}
return implode(', ', $result);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>系统发生错误</title>
<meta name="robots" content="noindex,nofollow" />
<style>
/* Base */
body {
color: #333;
font: 16px Verdana, "Helvetica Neue", helvetica, Arial, 'Microsoft YaHei', sans-serif;
margin: 0;
padding: 0 20px 20px;
}
h1{
margin: 10px 0 0;
font-size: 28px;
font-weight: 500;
line-height: 32px;
}
h2{
color: #4288ce;
font-weight: 400;
padding: 6px 0;
margin: 6px 0 0;
font-size: 18px;
border-bottom: 1px solid #eee;
}
h3{
margin: 12px;
font-size: 16px;
font-weight: bold;
}
abbr{
cursor: help;
text-decoration: underline;
text-decoration-style: dotted;
}
a{
color: #868686;
cursor: pointer;
}
a:hover{
text-decoration: underline;
}
.line-error{
background: #f8cbcb;
}
.echo table {
width: 100%;
}
.echo pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border: 0;
border-radius: 3px;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
.echo pre > pre {
padding: 0;
margin: 0;
}
/* Exception Info */
.exception {
margin-top: 20px;
}
.exception .message{
padding: 12px;
border: 1px solid #ddd;
border-bottom: 0 none;
line-height: 18px;
font-size:16px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
}
.exception .code{
float: left;
text-align: center;
color: #fff;
margin-right: 12px;
padding: 16px;
border-radius: 4px;
background: #999;
}
.exception .source-code{
padding: 6px;
border: 1px solid #ddd;
background: #f9f9f9;
overflow-x: auto;
}
.exception .source-code pre{
margin: 0;
}
.exception .source-code pre ol{
margin: 0;
color: #4288ce;
display: inline-block;
min-width: 100%;
box-sizing: border-box;
font-size:14px;
font-family: "Century Gothic",Consolas,"Liberation Mono",Courier,Verdana;
padding-left: <?php echo (isset($source) && !empty($source)) ? parse_padding($source) : 40; ?>px;
}
.exception .source-code pre li{
border-left: 1px solid #ddd;
height: 18px;
line-height: 18px;
}
.exception .source-code pre code{
color: #333;
height: 100%;
display: inline-block;
border-left: 1px solid #fff;
font-size:14px;
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
}
.exception .trace{
padding: 6px;
border: 1px solid #ddd;
border-top: 0 none;
line-height: 16px;
font-size:14px;
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
}
.exception .trace ol{
margin: 12px;
}
.exception .trace ol li{
padding: 2px 4px;
}
.exception div:last-child{
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
/* Exception Variables */
.exception-var table{
width: 100%;
margin: 12px 0;
box-sizing: border-box;
table-layout:fixed;
word-wrap:break-word;
}
.exception-var table caption{
text-align: left;
font-size: 16px;
font-weight: bold;
padding: 6px 0;
}
.exception-var table caption small{
font-weight: 300;
display: inline-block;
margin-left: 10px;
color: #ccc;
}
.exception-var table tbody{
font-size: 13px;
font-family: Consolas,"Liberation Mono",Courier,"微软雅黑";
}
.exception-var table td{
padding: 0 6px;
vertical-align: top;
word-break: break-all;
}
.exception-var table td:first-child{
width: 28%;
font-weight: bold;
white-space: nowrap;
}
.exception-var table td pre{
margin: 0;
}
/* Copyright Info */
.copyright{
margin-top: 24px;
padding: 12px 0;
border-top: 1px solid #eee;
}
/* SPAN elements with the classes below are added by prettyprint. */
pre.prettyprint .pln { color: #000 } /* plain text */
pre.prettyprint .str { color: #080 } /* string content */
pre.prettyprint .kwd { color: #008 } /* a keyword */
pre.prettyprint .com { color: #800 } /* a comment */
pre.prettyprint .typ { color: #606 } /* a type name */
pre.prettyprint .lit { color: #066 } /* a literal value */
/* punctuation, lisp open bracket, lisp close bracket */
pre.prettyprint .pun, pre.prettyprint .opn, pre.prettyprint .clo { color: #660 }
pre.prettyprint .tag { color: #008 } /* a markup tag name */
pre.prettyprint .atn { color: #606 } /* a markup attribute name */
pre.prettyprint .atv { color: #080 } /* a markup attribute value */
pre.prettyprint .dec, pre.prettyprint .var { color: #606 } /* a declaration; a variable name */
pre.prettyprint .fun { color: red } /* a function name */
</style>
</head>
<body>
<div class="echo">
<?php echo $echo;?>
</div>
<?php if(\think\facade\App::isDebug()) { ?>
<div class="exception">
<div class="message">
<div class="info">
<div>
<h2>[<?php echo $code; ?>]&nbsp;<?php echo sprintf('%s in %s', parse_class($name), parse_file($file, $line)); ?></h2>
</div>
<div><h1><?php echo nl2br(htmlentities($message)); ?></h1></div>
</div>
</div>
<?php if(!empty($source)){?>
<div class="source-code">
<pre class="prettyprint lang-php"><ol start="<?php echo $source['first']; ?>"><?php foreach ((array) $source['source'] as $key => $value) { ?><li class="line-<?php echo $key + $source['first']; ?>"><code><?php echo htmlentities($value); ?></code></li><?php } ?></ol></pre>
</div>
<?php }?>
<div class="trace">
<h2>Call Stack</h2>
<ol>
<li><?php echo sprintf('in %s', parse_file($file, $line)); ?></li>
<?php foreach ((array) $trace as $value) { ?>
<li>
<?php
// Show Function
if($value['function']){
echo sprintf(
'at %s%s%s(%s)',
isset($value['class']) ? parse_class($value['class']) : '',
isset($value['type']) ? $value['type'] : '',
$value['function'],
isset($value['args'])?parse_args($value['args']):''
);
}
// Show line
if (isset($value['file']) && isset($value['line'])) {
echo sprintf(' in %s', parse_file($value['file'], $value['line']));
}
?>
</li>
<?php } ?>
</ol>
</div>
</div>
<?php } else { ?>
<div class="exception">
<div class="info"><h1><?php echo htmlentities($message); ?></h1></div>
</div>
<?php } ?>
<?php if(!empty($datas)){ ?>
<div class="exception-var">
<h2>Exception Datas</h2>
<?php foreach ((array) $datas as $label => $value) { ?>
<table>
<?php if(empty($value)){ ?>
<caption><?php echo $label; ?><small>empty</small></caption>
<?php } else { ?>
<caption><?php echo $label; ?></caption>
<tbody>
<?php foreach ((array) $value as $key => $val) { ?>
<tr>
<td><?php echo htmlentities($key); ?></td>
<td>
<?php
if(is_array($val) || is_object($val)){
echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
} else if(is_bool($val)) {
echo $val ? 'true' : 'false';
} else if(is_scalar($val)) {
echo htmlentities($val);
} else {
echo 'Resource';
}
?>
</td>
</tr>
<?php } ?>
</tbody>
<?php } ?>
</table>
<?php } ?>
</div>
<?php } ?>
<?php if(!empty($tables)){ ?>
<div class="exception-var">
<h2>Environment Variables</h2>
<?php foreach ((array) $tables as $label => $value) { ?>
<table>
<?php if(empty($value)){ ?>
<caption><?php echo $label; ?><small>empty</small></caption>
<?php } else { ?>
<caption><?php echo $label; ?></caption>
<tbody>
<?php foreach ((array) $value as $key => $val) { ?>
<tr>
<td><?php echo htmlentities($key); ?></td>
<td>
<?php
if(is_array($val) || is_object($val)){
echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
} else if(is_bool($val)) {
echo $val ? 'true' : 'false';
} else if(is_scalar($val)) {
echo htmlentities($val);
} else {
echo 'Resource';
}
?>
</td>
</tr>
<?php } ?>
</tbody>
<?php } ?>
</table>
<?php } ?>
</div>
<?php } ?>
<div class="copyright">
<a title="官方网站" href="http://www.thinkphp.cn">ThinkPHP</a>
<span>V<?php echo \think\facade\App::version(); ?></span>
<span>{ -API开发设计的高性能框架 }</span>
<span>- <a title="官方手册" href="https://www.kancloud.cn/special/thinkphp5_quickstart">官方手册系列</a></span>
</div>
<?php if(\think\facade\App::isDebug()) { ?>
<script>
var LINE = <?php echo $line; ?>;
function $(selector, node){
var elements;
node = node || document;
if(document.querySelectorAll){
elements = node.querySelectorAll(selector);
} else {
switch(selector.substr(0, 1)){
case '#':
elements = [node.getElementById(selector.substr(1))];
break;
case '.':
if(document.getElementsByClassName){
elements = node.getElementsByClassName(selector.substr(1));
} else {
elements = get_elements_by_class(selector.substr(1), node);
}
break;
default:
elements = node.getElementsByTagName();
}
}
return elements;
function get_elements_by_class(search_class, node, tag) {
var elements = [], eles,
pattern = new RegExp('(^|\\s)' + search_class + '(\\s|$)');
node = node || document;
tag = tag || '*';
eles = node.getElementsByTagName(tag);
for(var i = 0; i < eles.length; i++) {
if(pattern.test(eles[i].className)) {
elements.push(eles[i])
}
}
return elements;
}
}
$.getScript = function(src, func){
var script = document.createElement('script');
script.async = 'async';
script.src = src;
script.onload = func || function(){};
$('head')[0].appendChild(script);
}
;(function(){
var files = $('.toggle');
var ol = $('ol', $('.prettyprint')[0]);
var li = $('li', ol[0]);
//
for(var i = 0; i < files.length; i++){
files[i].ondblclick = function(){
var title = this.title;
this.title = this.innerHTML;
this.innerHTML = title;
}
}
//
var err_line = $('.line-' + LINE, ol[0])[0];
err_line.className = err_line.className + ' line-error';
$.getScript('//cdn.bootcss.com/prettify/r298/prettify.min.js', function(){
prettyPrint();
// Firefox浏览器一个很诡异的问题
// ol的行号莫名其妙的错位
// li里面的html重新渲染就没有问题了
if(window.navigator.userAgent.indexOf('Firefox') >= 0){
ol[0].innerHTML = ol[0].innerHTML;
}
});
})();
</script>
<?php } ?>
</body>
</html>

37
app/view/exception.html Normal file
View File

@@ -0,0 +1,37 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>系统发生错误</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0;}
.full-height {height: 100vh;}
.flex-center {align-items: center;display: flex;justify-content: center;}
.position-ref {position: relative;}
.top-right {position: absolute;right: 10px;top: 18px;}
.content {text-align: center;}
.title {font-size: 84px;}
.links > a {color: #636b6f;padding: 0 25px; font-size: 12px;font-weight: 600;letter-spacing: .1rem;text-decoration: none;text-transform: uppercase;}
.m-b-md {margin-bottom: 30px;}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
系统错误
</div>
<div class="links">
<?php echo nl2br(htmlentities($message)); ?>
</div>
</div>
</div>
</body>
</html>

View File

@@ -32,6 +32,7 @@ html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans
<a href="https://www.kancloud.cn/tensent/sentcms3/169624" target="_blank">文档</a>
<a href="https://www.tensent.cn" target="_blank">资讯</a>
<a href="https://gitee.com/sentcms/sentcms" target="_blank">Gitee</a>
<a href="{:url('admin.index/index')}" target="_blank">后台管理</a>
</div>
</div>
</div>

View File

@@ -38,7 +38,9 @@ return [
'default_timezone' => 'Asia/Shanghai',
// 异常页面的模板文件
'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',
// 'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',
'exception_tmpl' => app()->getAppPath() . 'view/error.tpl',
// 'exception_tmpl' => app()->getAppPath() . 'view/exception.html',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',

View File

@@ -10,9 +10,12 @@
// +----------------------------------------------------------------------
use think\facade\Route;
Route::rule('/', 'index/index');
Route::rule('search', 'index/search');
Route::rule('topic-:id', 'index/topic');
Route::group('admin', function(){
Route::rule('/', 'admin.index/index');
//Route::rule(':controller', 'admin.:controller/index');
Route::rule('login', 'admin.index/login');
Route::rule(':controller/:function', 'admin.:controller/:function');
});