diff --git a/application/common/controller/Base.php b/application/common/controller/Base.php index da496bb3..dd4f5fc7 100644 --- a/application/common/controller/Base.php +++ b/application/common/controller/Base.php @@ -12,7 +12,15 @@ class Base extends Controller { // 调用Auth中间件进行用户权限验证 - protected $middleware = ['YanZheng']; + protected $middleware = [ + 'YanZheng'=>[ + 'except'=>[ + 'notfound', + 'mysuccess', + 'ajaxData' + ], + ], + ]; public function _empty() { diff --git a/application/common/controller/BaseError.php b/application/common/controller/BaseError.php new file mode 100644 index 00000000..42ae426b --- /dev/null +++ b/application/common/controller/BaseError.php @@ -0,0 +1,26 @@ +redirect(url('/notfound')); + } + + public function _empty() + { + $this->redirect(url('/notfound')); + } + +} diff --git a/application/error/controller/Index.php b/application/error/controller/Index.php deleted file mode 100644 index e3128a32..00000000 --- a/application/error/controller/Index.php +++ /dev/null @@ -1,22 +0,0 @@ -fetch(); - } - - -} diff --git a/application/home/controller/Error.php b/application/home/controller/Error.php index daf29391..132697e4 100644 --- a/application/home/controller/Error.php +++ b/application/home/controller/Error.php @@ -2,13 +2,10 @@ namespace app\home\controller; -use think\Controller; +// 引用空控制器基类 +use app\common\controller\BaseError; -class Error extends Controller +class Error extends BaseError { - public function index() - { - // 跳转页面 - $this->redirect(url('/notfound')); - } + } diff --git a/application/home/controller/Index.php b/application/home/controller/Index.php index a0674aa9..62a83df0 100644 --- a/application/home/controller/Index.php +++ b/application/home/controller/Index.php @@ -7,6 +7,45 @@ use app\common\controller\Base; class Index extends Base { - // 跳转页面 - $this->redirect(url('/notfound')); + + // /** + // * 操作成功跳转 + // * + // * @return \think\Response + // */ + public function mysuccess($msg = '操作成功~') + { + // 模版赋值 + $this->assign('msg',$msg); + + // 跳转页面 + return $this->fetch(); + } + + + /** + * 操作失败跳转 + * + * @return \think\Response + */ + public function notfound() + { + if (session('?msg')) + { + $msg = session('msg'); + session('msg', null); + }else{ + $msg = '不好意思,您访问的页面不存在~'; + } + + + // 模版赋值 + $this->assign('msg',$msg); + + // 跳转页面 + return $this->fetch(); + } + + + } diff --git a/application/error/view/index/index.html b/application/home/view/index/mysuccess.html similarity index 82% rename from application/error/view/index/index.html rename to application/home/view/index/mysuccess.html index f5b504a8..64a26d3a 100644 --- a/application/error/view/index/index.html +++ b/application/home/view/index/mysuccess.html @@ -17,19 +17,19 @@ -
- 404 +
+ 系统提示
-不好意思,您访问的页面不存在~
-您可以: +
{$msg}
+