noAuth); } protected function initialize(): void { header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); header("Access-Control-Allow-Headers: X-Requested-With"); if($this->needAuthToken()) { $token = $this->getHeaderToken(); $data = Cache::get($token); $this->tokenData = $data; if(empty($data)) { $this->error('无效的token'); } } BlurUtils::setNotNeedBlur(); } /** * $params $data */ public function makeModelData($data,$mapping): array { $info = []; foreach ($data as $k=>$v) { if($info[$mapping[$k]] ?? '') { continue; } $info[$mapping[$k]] = $v; } return $info; } public function getDecryptData($data): array { $key = 'zLxapoeqWYpoeqWY'; $info = Gm::decrypt($key,$data); return json_decode(base64_decode($info),true); } public function makeEncryptData($data) { $key = Config::get('gm.key'); $info = Gm::encrypt($key,(base64_encode(json_encode($data)))); return $info; } public function getHeaderToken(): string { $header = getallheaders(); $auth = $header['Authorization']; $data = explode(' ',$auth); return $data[1]; } }