内核更新

This commit is contained in:
2016-07-29 13:48:52 +08:00
parent 75125bb298
commit 9da53fc969
27 changed files with 770 additions and 530 deletions

View File

@@ -27,11 +27,11 @@ trait Jump
/**
* 操作成功跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @return array
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @return void
*/
protected function success($msg = '', $url = null, $data = '', $wait = 3)
{
@@ -42,7 +42,7 @@ trait Jump
}
if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) {
$url = $_SERVER["HTTP_REFERER"];
} else {
} elseif ('' !== $url) {
$url = preg_match('/^(https?:|\/)/', $url) ? $url : Url::build($url);
}
$result = [
@@ -58,16 +58,17 @@ trait Jump
$result = ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str'))
->fetch(Config::get('dispatch_success_tmpl'), $result);
}
return Response::create($result, $type);
$response = Response::create($result, $type);
throw new HttpResponseException($response);
}
/**
* 操作错误跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @return void
*/
protected function error($msg = '', $url = null, $data = '', $wait = 3)
@@ -79,7 +80,7 @@ trait Jump
}
if (is_null($url)) {
$url = 'javascript:history.back(-1);';
} else {
} elseif ('' !== $url) {
$url = preg_match('/^(https?:|\/)/', $url) ? $url : Url::build($url);
}
$result = [
@@ -102,11 +103,11 @@ trait Jump
/**
* 返回封装后的API数据到客户端
* @access protected
* @param mixed $data 要返回的数据
* @param integer $code 返回的code
* @param mixed $msg 提示信息
* @param string $type 返回数据格式
* @return mixed
* @param mixed $data 要返回的数据
* @param integer $code 返回的code
* @param mixed $msg 提示信息
* @param string $type 返回数据格式
* @return void
*/
protected function result($data, $code = 0, $msg = '', $type = '')
{
@@ -116,16 +117,17 @@ trait Jump
'time' => $_SERVER['REQUEST_TIME'],
'data' => $data,
];
$type = $type ?: $this->getResponseType();
return Response::create($result, $type);
$type = $type ?: $this->getResponseType();
$response = Response::create($result, $type);
throw new HttpResponseException($response);
}
/**
* URL重定向
* @access protected
* @param string $url 跳转的URL表达式
* @param array|integer $params 其它URL参数
* @param integer $code http code
* @param string $url 跳转的URL表达式
* @param array|integer $params 其它URL参数
* @param integer $code http code
* @return void
*/
protected function redirect($url, $params = [], $code = 302)