mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-04 14:22:48 +08:00
改进Response类的send方法 去除 REQUEST_METHOD IS_GET IS_POST IS_PUT IS_DELETE IS_AJAX __EXT__ 常量 由应用自己定义
This commit is contained in:
@@ -16,6 +16,7 @@ namespace traits\controller;
|
||||
|
||||
use think\Config;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\Request;
|
||||
use think\Response;
|
||||
use think\response\Redirect;
|
||||
use think\View as ViewTemplate;
|
||||
@@ -46,7 +47,7 @@ trait Jump
|
||||
'wait' => $wait,
|
||||
];
|
||||
|
||||
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
$type = $this->getResponseType();
|
||||
if ('html' == strtolower($type)) {
|
||||
$result = ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str'))
|
||||
->fetch(Config::get('dispatch_success_tmpl'), $result);
|
||||
@@ -78,7 +79,7 @@ trait Jump
|
||||
'wait' => $wait,
|
||||
];
|
||||
|
||||
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
$type = $this->getResponseType();
|
||||
if ('html' == strtolower($type)) {
|
||||
$result = ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str'))
|
||||
->fetch(Config::get('dispatch_error_tmpl'), $result);
|
||||
@@ -120,4 +121,14 @@ trait Jump
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的response 输出类型
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getResponseType()
|
||||
{
|
||||
$isAjax = Request::instance()->isAjax();
|
||||
return $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user