mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
改进Jump跳转地址支持Url::build 解析
This commit is contained in:
@@ -19,6 +19,7 @@ use think\exception\HttpResponseException;
|
|||||||
use think\Request;
|
use think\Request;
|
||||||
use think\Response;
|
use think\Response;
|
||||||
use think\response\Redirect;
|
use think\response\Redirect;
|
||||||
|
use think\Url;
|
||||||
use think\View as ViewTemplate;
|
use think\View as ViewTemplate;
|
||||||
|
|
||||||
trait Jump
|
trait Jump
|
||||||
@@ -39,11 +40,16 @@ trait Jump
|
|||||||
$code = $msg;
|
$code = $msg;
|
||||||
$msg = '';
|
$msg = '';
|
||||||
}
|
}
|
||||||
|
if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) {
|
||||||
|
$url = $_SERVER["HTTP_REFERER"];
|
||||||
|
} else {
|
||||||
|
$url = preg_match('/^(https?:|\/)/', $url) ? $url : Url::build($url);
|
||||||
|
}
|
||||||
$result = [
|
$result = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
'url' => is_null($url) && isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $url,
|
'url' => $url,
|
||||||
'wait' => $wait,
|
'wait' => $wait,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -71,11 +77,16 @@ trait Jump
|
|||||||
$code = $msg;
|
$code = $msg;
|
||||||
$msg = '';
|
$msg = '';
|
||||||
}
|
}
|
||||||
|
if (is_null($url)) {
|
||||||
|
$url = 'javascript:history.back(-1);';
|
||||||
|
} else {
|
||||||
|
$url = preg_match('/^(https?:|\/)/', $url) ? $url : Url::build($url);
|
||||||
|
}
|
||||||
$result = [
|
$result = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
'url' => is_null($url) ? 'javascript:history.back(-1);' : $url,
|
'url' => $url,
|
||||||
'wait' => $wait,
|
'wait' => $wait,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -104,7 +115,7 @@ trait Jump
|
|||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'time' => $_SERVER['REQUEST_TIME'],
|
'time' => $_SERVER['REQUEST_TIME'],
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
];
|
];
|
||||||
$type = $type ?: $this->getResponseType();
|
$type = $type ?: $this->getResponseType();
|
||||||
return Response::create($result, $type);
|
return Response::create($result, $type);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user