改写View类的instance方法

This commit is contained in:
thinkphp
2015-12-24 16:15:19 +08:00
parent 0f57228759
commit 222f913eb0
4 changed files with 37 additions and 22 deletions

View File

@@ -165,24 +165,26 @@ class Response
*/
public static function success($msg = '', $data = '', $url = '', $wait = 3)
{
$code = 1;
if(is_numeric($msg)){
$code = $msg;
$msg = '';
$code = 1;
if (is_numeric($msg)) {
$code = $msg;
$msg = '';
}
$result = [
$result = [
'code' => $code,
'msg' => $msg,
'data' => $data,
'url' => $url ?: $_SERVER["HTTP_REFERER"],
'wait' => $wait,
];
$type = Config::get('default_return_type');
if (IS_AJAX) {
$type = Config::get('default_ajax_return');
$type = Config::get('default_ajax_return');
} else {
$type = Config::get('default_return_type');
}
if ('html' == $type) {
$result = \think\View::getInstance()->fetch(Config::get('dispatch_jump_tmpl'), $result);
$result = \think\View::instance()->fetch(Config::get('dispatch_jump_tmpl'), $result);
}
self::type($type);
return $result;
@@ -199,24 +201,26 @@ class Response
*/
public static function error($msg = '', $data = '', $url = '', $wait = 3)
{
$code = 0;
if(is_numeric($msg)){
$code = $msg;
$msg = '';
$code = 0;
if (is_numeric($msg)) {
$code = $msg;
$msg = '';
}
$result = [
$result = [
'code' => $code,
'msg' => $msg,
'data' => $data,
'url' => $url ?: 'javascript:history.back(-1);',
'wait' => $wait,
];
$type = Config::get('default_return_type');
if (IS_AJAX) {
$type = Config::get('default_ajax_return');
$type = Config::get('default_ajax_return');
} else {
$type = Config::get('default_return_type');
}
if ('html' == $type) {
$result = \think\View::getInstance()->fetch(Config::get('dispatch_jump_tmpl'), $result);
$result = \think\View::instance()->fetch(Config::get('dispatch_jump_tmpl'), $result);
}
self::type($type);
return $result;