*/ class MaintainMiddleware { /** * @param Request $request * @param \Closure $closure * @return mixed */ public function handle(Request $request, \Closure $closure) { if(!env('MAINTAIN')){ return $closure($request); } $appName = app('http')->getName(); halt($request); if ($appName === 'admin') { return $this->adminApp($request, $closure); } // // 如有其他应用自定义处理方式 // return ResponseJson::fail(lang('maintain s')); } /** * 后台管理处理 * @param Request $request * @param \Closure $closure * @return mixed|Response|\think\response\Json */ private function adminApp(Request $request, \Closure $closure) { if (!Administrators::LoginCheck() || admin_session('maintain') === true) { return $closure($request); } if ($request->isAjax()) { return ResponseJson::fail(lang('maintain s')); }else{ return Response::create($this->html()); } } /** * 维护html展示 * @return string */ private function html() { $lang = lang(lang('maintain s')); return << body{ background: #efefef; } div{ font-size: 50px; position: absolute; width:100%; height: 100%; line-height: 100%; } p{ position: absolute; top: 50%; left: 50%; height: 50px; text-align: center; font-weight: bold; width: 300px; color: red; margin: -25px 0 0 -150px; text-shadow: white -1px -1px, black 1px 1px; }

{$lang}

HTML; } }