diff --git a/app/BaseController.php b/app/BaseController.php index f3d35a3..0de3c8d 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -100,102 +100,6 @@ abstract class BaseController return $v->failException(true)->check($data); } - /** - * 操作错误跳转 - * @param mixed $msg 提示信息 - * @param string $url 跳转的URL地址 - * @param mixed $data 返回的数据 - * @param integer $wait 跳转等待时间 - * @param array $header 发送的Header信息 - * @return void - */ - protected function error($msg = '', string $url = null, $data = '', int $wait = 3, array $header = []): Response - { - if (is_null($url)) { - $url = request()->isAjax() ? '' : 'javascript:history.back(-1);'; - } elseif ($url) { - $url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : app('route')->buildUrl($url); - } - - $result = [ - 'code' => 0, - 'msg' => $msg, - 'data' => $data, - 'url' => $url, - 'wait' => $wait, - ]; - - $type = (request()->isJson() || request()->isAjax()) ? 'json' : 'html'; - if ('html' == strtolower($type)) { - $type = 'jump'; - } - - $response = Response::create($result, $type)->header($header)->options(['jump_template' => app('config')->get('app.dispatch_error_tmpl')]); - - throw new HttpResponseException($response); - } - - /** - * 返回封装后的API数据到客户端 - * @param mixed $data 要返回的数据 - * @param integer $code 返回的code - * @param mixed $msg 提示信息 - * @param string $type 返回数据格式 - * @param array $header 发送的Header信息 - * @return Response - */ - protected function result($data, int $code = 0, $msg = '', string $type = '', array $header = []): Response - { - $result = [ - 'code' => $code, - 'msg' => $msg, - 'time' => time(), - 'data' => $data, - ]; - - $type = $type ?: 'json'; - $response = Response::create($result, $type)->header($header); - - throw new HttpResponseException($response); - } - - /** - * 操作成功跳转 - * @param mixed $msg 提示信息 - * @param string $url 跳转的URL地址 - * @param mixed $data 返回的数据 - * @param integer $wait 跳转等待时间 - * @param array $header 发送的Header信息 - * @return void - */ - protected function success($msg = '', string $url = null, $data = '', int $wait = 3, array $header = []): Response - { - if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) { - $url = $_SERVER["HTTP_REFERER"]; - } elseif ($url) { - $url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : app('route')->buildUrl($url); - } - - $result = [ - 'code' => 1, - 'msg' => $msg, - 'data' => $data, - 'url' => $url, - 'wait' => $wait, - ]; - - $type = (request()->isJson() || request()->isAjax()) ? 'json' : 'html'; - // 把跳转模板的渲染下沉,这样在 response_send 行为里通过getData()获得的数据是一致性的格式 - if ('html' == strtolower($type)) { - $type = 'jump'; - } - - $response = Response::create($result, $type)->header($header)->options(['jump_template' => app('config')->get('app.dispatch_success_tmpl')]); - - throw new HttpResponseException($response); - } - - //显示网站设置 protected function getSystem() { diff --git a/app/admin/controller/addon/Addons.php b/app/admin/controller/addon/Addons.php index bec3001..3e39204 100644 --- a/app/admin/controller/addon/Addons.php +++ b/app/admin/controller/addon/Addons.php @@ -34,12 +34,6 @@ class Addons extends AdminController */ public function index() { -// if(Request::isAjax()) { -// $data = Request::param(); -// if(!isset($data['type'])) $data['type'] = 'onlineAddons'; -// if(!isset($data['selector'])) $data['selector'] = 'all'; -// return $this->getList($data); -// } return View::fetch(); } @@ -101,123 +95,6 @@ class Addons extends AdminController return json(['code' => -1, 'msg' => '未获取到服务器信息']); } - - /** - * 插件动态列表 - * @param $data - * @return Json - */ - public function getList() - { - $data = Request::param(); - if(!isset($data['type'])) $data['type'] = 'onlineAddons'; - if(!isset($data['selector'])) $data['selector'] = 'all'; - $res = []; - //本地插件列表 - $addonsList = Files::getDirName('../addons/'); - $response = HttpHelper::withHost()->get('/v1/addons'); - $addons = $response->toJson(); - switch($data['type']){ - //已安装 - case 'installed': - if($addonsList){ - $res = ['code'=>0,'msg'=>'','count'=>5]; - $res['col'] = [ - ['type' => 'numbers'], - ['field' => 'name','title'=> '插件', 'width'=> 120], - ['field'=> 'title','title'=> '标题', 'width'=> 100], - ['field'=> 'version','title'=> '版本', 'templet' => '