mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
Merge branch 'master' of https://github.com/top-think/framework
This commit is contained in:
@@ -426,7 +426,7 @@ function xml($data = [], $code = 200, $options = [])
|
|||||||
* @param array $params 额外参数
|
* @param array $params 额外参数
|
||||||
* @return \think\response\Redirect
|
* @return \think\response\Redirect
|
||||||
*/
|
*/
|
||||||
function redirect($url = [], $code = 200, $params = [])
|
function redirect($url = [], $code = 302, $params = [])
|
||||||
{
|
{
|
||||||
return Response::create($url, 'redirect')->code($code)->params($params);
|
return Response::create($url, 'redirect')->code($code)->params($params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,6 @@ class Session
|
|||||||
* @param string $name session名称
|
* @param string $name session名称
|
||||||
* @param string|null $prefix
|
* @param string|null $prefix
|
||||||
* @return bool
|
* @return bool
|
||||||
* @internal param mixed $value session值
|
|
||||||
*/
|
*/
|
||||||
public static function has($name, $prefix = null)
|
public static function has($name, $prefix = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
namespace think\response;
|
namespace think\response;
|
||||||
|
|
||||||
|
use think\Request;
|
||||||
use think\Response;
|
use think\Response;
|
||||||
|
use think\Session;
|
||||||
use think\Url;
|
use think\Url;
|
||||||
|
|
||||||
class Redirect extends Response
|
class Redirect extends Response
|
||||||
@@ -30,10 +32,9 @@ class Redirect extends Response
|
|||||||
*/
|
*/
|
||||||
protected function output($data)
|
protected function output($data)
|
||||||
{
|
{
|
||||||
$this->isExit = true;
|
|
||||||
$url = preg_match('/^(https?:|\/)/', $data) ? $data : Url::build($data, $this->params);
|
$url = preg_match('/^(https?:|\/)/', $data) ? $data : Url::build($data, $this->params);
|
||||||
$this->header['Location'] = $url;
|
$this->header['Location'] = $url;
|
||||||
$this->header['status'] = isset($this->header['status']) ? $this->header['status'] : 301;
|
$this->header['status'] = isset($this->header['status']) ? $this->header['status'] : 302;
|
||||||
$this->header['Cache-control'] = 'no-cache,must-revalidate';
|
$this->header['Cache-control'] = 'no-cache,must-revalidate';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -43,4 +44,23 @@ class Redirect extends Response
|
|||||||
$this->params = $params;
|
$this->params = $params;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记住当前url后跳转
|
||||||
|
*/
|
||||||
|
public function remember()
|
||||||
|
{
|
||||||
|
Session::set('redirect_url', Request::instance()->url());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到上次记住的url
|
||||||
|
*/
|
||||||
|
public function restore()
|
||||||
|
{
|
||||||
|
if (Session::has('redirect_url')) {
|
||||||
|
$this->data = Session::get('redirect_url');
|
||||||
|
Session::delete('redirect_url');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user