mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
改进controller类的redirect方法和助手函数redirect
This commit is contained in:
@@ -407,11 +407,15 @@ function xml($data = [], $code = 200, $options = [])
|
|||||||
/**
|
/**
|
||||||
* 获取\think\response\Redirect对象实例
|
* 获取\think\response\Redirect对象实例
|
||||||
* @param mixed $url 重定向地址 支持Url::build方法的地址
|
* @param mixed $url 重定向地址 支持Url::build方法的地址
|
||||||
|
* @param array|integer $params 额外参数
|
||||||
* @param integer $code 状态码
|
* @param integer $code 状态码
|
||||||
* @param array $params 额外参数
|
|
||||||
* @return \think\response\Redirect
|
* @return \think\response\Redirect
|
||||||
*/
|
*/
|
||||||
function redirect($url = [], $code = 302, $params = [])
|
function redirect($url = [], $params = [], $code = 302)
|
||||||
{
|
{
|
||||||
|
if (is_integer($params)) {
|
||||||
|
$code = $params;
|
||||||
|
$params = [];
|
||||||
|
}
|
||||||
return Response::create($url, 'redirect')->code($code)->params($params);
|
return Response::create($url, 'redirect')->code($code)->params($params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,13 +105,17 @@ trait Jump
|
|||||||
* URL重定向
|
* URL重定向
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $url 跳转的URL表达式
|
* @param string $url 跳转的URL表达式
|
||||||
|
* @param array|integer $params 其它URL参数
|
||||||
* @param integer $code http code
|
* @param integer $code http code
|
||||||
* @param array $params 其它URL参数
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function redirect($url, $code = 301, $params = [])
|
public function redirect($url, $params = [], $code = 302)
|
||||||
{
|
{
|
||||||
$response = new Redirect($url);
|
$response = new Redirect($url);
|
||||||
|
if (is_integer($params)) {
|
||||||
|
$code = $params;
|
||||||
|
$params = [];
|
||||||
|
}
|
||||||
$response->code($code)->params($params);
|
$response->code($code)->params($params);
|
||||||
throw new HttpResponseException($response);
|
throw new HttpResponseException($response);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user