优化error和success方法

This commit is contained in:
augushong
2020-12-06 22:12:43 +08:00
parent 542bcc3e22
commit 0b7dbe7163

View File

@@ -64,7 +64,8 @@ abstract class BaseController
// 初始化
protected function initialize()
{}
{
}
/**
* 验证数据
@@ -111,11 +112,13 @@ abstract class BaseController
} else {
if ($jump_to_url instanceof Url) {
$jump_to_url = $jump_to_url;
$jump_to_url = (string)$jump_to_url;
} else {
if (strpos($jump_to_url, 'http') !== 0) {
$jump_to_url = url($jump_to_url);
}
}
}
$data = [
'msg' => $msg,
@@ -124,7 +127,7 @@ abstract class BaseController
];
if (\request()->isAjax()) {
$data['jump_to_url'] = (string)$jump_to_url;
$data['jump_to_url'] = $jump_to_url;
if ($code == 200) {
$code = 0;
}
@@ -142,10 +145,11 @@ abstract class BaseController
} else {
if ($jump_to_url instanceof Url) {
$jump_to_url = $jump_to_url;
$jump_to_url = (string)$jump_to_url;
} else {
if (strpos($jump_to_url, 'http') !== 0) {
$jump_to_url = url($jump_to_url);
}
}
}
@@ -156,7 +160,7 @@ abstract class BaseController
];
if (\request()->isAjax()) {
$data['jump_to_url'] = (string)$jump_to_url;
$data['jump_to_url'] = $jump_to_url;
if ($code == 200) {
$code = 500;
}
@@ -166,5 +170,4 @@ abstract class BaseController
View::assign($data);
throw new HttpResponseException(response(View::fetch('common@tpl/error'), $code));
}
}