app = $app; $this->request = $this->app->request; // 控制器初始化 return $this->redirectTo('/admin'); // $this->initialize(); } // 初始化 protected function initialize() { $params = [ 'module' => \think\facade\App::initialize()->http->getName(), 'controller' => app('request')->controller(), 'action' => app('request')->action(), 'isLogin' => 0, 'uid' => 0, 'nickname' => '', 'mobile_status' => 0, 'version' => get_config('webconfig.version'), ]; $login_top = ''; $info = $this->checkLogin(); if ($info) { $login_top = '' . $info['username'] . '' . $info['username'] . ''; $params['isLogin'] = 1; $params['uid'] = $info['id']; $params['nickname'] = $info['nickname']; $params['username'] = $info['username']; } $COMMON_NAV = get_navs('NAV_HOME'); View::assign('COMMON_NAV', $COMMON_NAV); View::assign('webconfig', get_config('webconfig')); View::assign('params', $params); View::assign('login_top', $login_top); } // 检测用户登录状态 protected function checkLogin() { $session_user = get_config('app.session_user'); $login_user = \think\facade\Session::get($session_user); if ($login_user && is_array($login_user)) { return $login_user; } else { return false; } } //页面跳转方法 public function redirectTo(...$args) { throw new HttpResponseException(redirect(...$args)); } }