From b76e9a4190402a21c13d055a1dfd2fc35aac043f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 10 Aug 2016 12:11:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bcontroller=E7=B1=BB=E7=9A=84s?= =?UTF-8?q?uccess=20error=20result=20=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0h?= =?UTF-8?q?eader=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/traits/controller/Jump.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/library/traits/controller/Jump.php b/library/traits/controller/Jump.php index b8b2b573..a867548e 100644 --- a/library/traits/controller/Jump.php +++ b/library/traits/controller/Jump.php @@ -31,9 +31,10 @@ trait Jump * @param string $url 跳转的URL地址 * @param mixed $data 返回的数据 * @param integer $wait 跳转等待时间 + * @param array $header 发送的Header信息 * @return void */ - protected function success($msg = '', $url = null, $data = '', $wait = 3) + protected function success($msg = '', $url = null, $data = '', $wait = 3, array $header = []) { $code = 1; if (is_numeric($msg)) { @@ -58,7 +59,7 @@ trait Jump $result = ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str')) ->fetch(Config::get('dispatch_success_tmpl'), $result); } - $response = Response::create($result, $type); + $response = Response::create($result, $type)->header($header); throw new HttpResponseException($response); } @@ -69,9 +70,10 @@ trait Jump * @param string $url 跳转的URL地址 * @param mixed $data 返回的数据 * @param integer $wait 跳转等待时间 + * @param array $header 发送的Header信息 * @return void */ - protected function error($msg = '', $url = null, $data = '', $wait = 3) + protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = []) { $code = 0; if (is_numeric($msg)) { @@ -96,7 +98,7 @@ trait Jump $result = ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str')) ->fetch(Config::get('dispatch_error_tmpl'), $result); } - $response = Response::create($result, $type); + $response = Response::create($result, $type)->header($header); throw new HttpResponseException($response); } @@ -107,9 +109,10 @@ trait Jump * @param integer $code 返回的code * @param mixed $msg 提示信息 * @param string $type 返回数据格式 + * @param array $header 发送的Header信息 * @return void */ - protected function result($data, $code = 0, $msg = '', $type = '') + protected function result($data, $code = 0, $msg = '', $type = '', array $header = []) { $result = [ 'code' => $code, @@ -118,7 +121,7 @@ trait Jump 'data' => $data, ]; $type = $type ?: $this->getResponseType(); - $response = Response::create($result, $type); + $response = Response::create($result, $type)->header($header); throw new HttpResponseException($response); }