diff --git a/library/think/app.php b/library/think/app.php index e403b31e..c28bf47a 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -111,7 +111,7 @@ class App // 操作方法执行完成监听 APP_HOOK && Hook::listen('action_end', $data); // 输出数据 - return Response::send($data, '', Config::get('response_return')); + return Response::send($data, Config::get('default_return_type'), Config::get('response_return')); } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); diff --git a/library/think/response.php b/library/think/response.php index cba81750..ecdf0bc5 100644 --- a/library/think/response.php +++ b/library/think/response.php @@ -137,11 +137,7 @@ class Response 'time' => NOW_TIME, 'data' => $data, ]; - - self::$data = $result; - if ($type) { - self::$type = $type; - } + return $result; } /** @@ -159,20 +155,16 @@ class Response 'code' => 1, 'msg' => $msg, 'data' => $data, - 'url' => $url ? $url : $_SERVER["HTTP_REFERER"], + 'url' => $url ?: $_SERVER["HTTP_REFERER"], 'wait' => $wait, ]; - $type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'); - if ('html' == $type) { - $view = new \think\View(); - $result = $view->fetch(Config::get('dispatch_jump_tmpl'), $result); + if(IS_AJAX){ + Config::set('default_return_type', Config::get('default_ajax_return')); } - self::$data = $result; - if ($type) { - self::$type = $type; + if ('html' == Config::get('default_return_type')) { + $result = \think\View::getInstance()->fetch(Config::get('dispatch_jump_tmpl'), $result); } - self::$isExit = true; - self::send(); + return $result; } /** @@ -190,20 +182,16 @@ class Response 'code' => 0, 'msg' => $msg, 'data' => $data, - 'url' => $url ? $url : 'javascript:history.back(-1);', + 'url' => $url ?: 'javascript:history.back(-1);', 'wait' => $wait, ]; - $type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'); - if ('html' == $type) { - $view = new \think\View(); - $result = $view->fetch(Config::get('dispatch_jump_tmpl'), $result); + if(IS_AJAX){ + Config::set('default_return_type', Config::get('default_ajax_return')); } - self::$data = $result; - if ($type) { - self::$type = $type; + if ('html' == Config::get('default_return_type')) { + $result = \think\View::getInstance()->fetch(Config::get('dispatch_jump_tmpl'), $result); } - self::$isExit = true; - self::send(); + return $result; } /**