mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 16:12:49 +08:00
改进Response类的type方法
This commit is contained in:
@@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\Config;
|
||||||
|
use think\View;
|
||||||
|
|
||||||
class Response
|
class Response
|
||||||
{
|
{
|
||||||
// 输出数据的转换方法
|
// 输出数据的转换方法
|
||||||
@@ -94,7 +97,7 @@ class Response
|
|||||||
public static function type($type = null)
|
public static function type($type = null)
|
||||||
{
|
{
|
||||||
if (is_null($type)) {
|
if (is_null($type)) {
|
||||||
return self::$type ?: Config::get('default_return_type');
|
return self::$type ?: (IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'));
|
||||||
}
|
}
|
||||||
self::$type = $type;
|
self::$type = $type;
|
||||||
}
|
}
|
||||||
@@ -175,7 +178,7 @@ class Response
|
|||||||
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||||
|
|
||||||
if ('html' == $type) {
|
if ('html' == $type) {
|
||||||
$result = \think\View::instance()->fetch(Config::get('dispatch_success_tmpl'), $result);
|
$result = View::instance()->fetch(Config::get('dispatch_success_tmpl'), $result);
|
||||||
}
|
}
|
||||||
self::type($type);
|
self::type($type);
|
||||||
return $result;
|
return $result;
|
||||||
@@ -208,7 +211,7 @@ class Response
|
|||||||
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||||
|
|
||||||
if ('html' == $type) {
|
if ('html' == $type) {
|
||||||
$result = \think\View::instance()->fetch(Config::get('dispatch_error_tmpl'), $result);
|
$result = View::instance()->fetch(Config::get('dispatch_error_tmpl'), $result);
|
||||||
}
|
}
|
||||||
self::type($type);
|
self::type($type);
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
Reference in New Issue
Block a user