app = $app; $this->request = $this->app->request; // $this->request['Accept'] = 'application/json'; $route = [ '/index/Token/getToken', '/index/index', '/index/user/login', '/index/admin/login', '/index/setting/read', '' ]; if (!in_array($this->request->baseUrl(),$route)){ if (empty($this->request->header('token'))) { throw new ApiException('token不为空'); }else{ $token = new Token(); $decodeToken = $token->decodeToken(); $this->userId = $decodeToken['userId']; } // $token = new Token(); // $decodeToken = $token->decodeToken(); // $this->userId = $decodeToken['userId']; } // 控制器初始化 $this->initialize(); } // 初始化 protected function initialize() {} protected function isAdmin() { if (request()->header('flag') === 'admin'){ return true; } return false; } }