diff --git a/extend/catcher/CatchAdmin.php b/extend/catcher/CatchAdmin.php index ac5a4b3..5ac548a 100644 --- a/extend/catcher/CatchAdmin.php +++ b/extend/catcher/CatchAdmin.php @@ -126,6 +126,25 @@ class CatchAdmin return $modules; } + /** + * + * @time 2019年12月12日 + * @return array + */ + public static function getModulesInfo(): array + { + $modules = []; + foreach (self::getModulesDirectory() as $module) { + $moduleInfo = self::getModuleInfo($module); + $modules[] = [ + 'value' => $moduleInfo['alias'], + 'title' => $moduleInfo['name'], + ]; + } + + return $modules; + } + /** * * @time 2019年11月30日 diff --git a/extend/catcher/CatchForm.php b/extend/catcher/CatchForm.php index c8f0fae..a850ae1 100644 --- a/extend/catcher/CatchForm.php +++ b/extend/catcher/CatchForm.php @@ -355,12 +355,12 @@ class CatchForm */ private function selectField($field) { - $select = sprintf('', $field['name'], $field['verify'] ?? ''); $default = $field['default'] ?? ''; foreach ($field['options'] as $key => $option) { - $select .= sprintf('', $key, $default == $key ? ' selected' : '',$option); + $select .= sprintf('', $option['value'], $default == $key ? ' selected' : '',$option['title']); } return $select . ''; diff --git a/extend/catcher/CatchResponse.php b/extend/catcher/CatchResponse.php index a748d06..e97f682 100644 --- a/extend/catcher/CatchResponse.php +++ b/extend/catcher/CatchResponse.php @@ -1,7 +1,9 @@ $code, - 'msg' => $msg, - 'data' => $data, - ]); + if (request()->isAjax()) { + return json([ + 'code' => $code, + 'msg' => $msg, + 'data' => $data, + ]); + } } /** @@ -47,13 +51,18 @@ class CatchResponse * @time 2019年12月02日 * @param string $msg * @param int $code - * @return \think\response\Json + * @return mixed + * @throws \Exception */ - public static function fail($msg = '', $code = 10001): \think\response\Json + public static function fail($msg = '', $code = 10001) { - return json([ - 'code' => $code, - 'msg' => $msg, - ]); + if (request()->isAjax()) { + return json([ + 'code' => $code, + 'msg' => $msg, + ]); + } + + return Response::create(config('catch.error'), 'view', $code)->assign(['msg' => $msg]); } } diff --git a/extend/catcher/base/CatchController.php b/extend/catcher/base/CatchController.php index 68bdf17..d895071 100644 --- a/extend/catcher/base/CatchController.php +++ b/extend/catcher/base/CatchController.php @@ -6,6 +6,8 @@ use think\facade\View; abstract class CatchController { + protected $middleware = ['check_auth']; + /** * * @time 2019年11月28日 diff --git a/extend/catcher/exceptions/LoginFailedException.php b/extend/catcher/exceptions/LoginFailedException.php index 1470ca7..df56dd9 100644 --- a/extend/catcher/exceptions/LoginFailedException.php +++ b/extend/catcher/exceptions/LoginFailedException.php @@ -1,7 +1,7 @@