From 34dd90c82dbbb1ab36ac8801a0ac8dd24e9cd59c Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Tue, 13 Oct 2020 00:44:24 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=8C=E5=96=84=E4=B8=AD=E9=97=B4?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/admin/InterfaceList.php | 8 ++++---- app/middleware/ApiAuth.php | 3 ++- app/middleware/ApiLog.php | 3 ++- app/middleware/ApiPermission.php | 3 ++- app/middleware/ApiResponse.php | 3 ++- app/middleware/RequestFilter.php | 3 ++- app/middleware/WikiAuth.php | 3 ++- install/apiRoute.tpl | 4 ++-- route/apiRoute.php | 4 ++-- 9 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/controller/admin/InterfaceList.php b/app/controller/admin/InterfaceList.php index 37dfde4..e9a3296 100644 --- a/app/controller/admin/InterfaceList.php +++ b/app/controller/admin/InterfaceList.php @@ -177,9 +177,9 @@ class InterfaceList extends Base { * @author zhaoxiang */ public function refresh(): Response { - $rootPath = Env::get('root_path'); + $rootPath = root_path(); $apiRoutePath = $rootPath . 'route/apiRoute.php'; - $tplPath = $rootPath . 'application/install/apiRoute.tpl'; + $tplPath = $rootPath . 'install/apiRoute.tpl'; $methodArr = ['*', 'POST', 'GET']; $tplOriginStr = file_get_contents($tplPath); @@ -187,9 +187,9 @@ class InterfaceList extends Base { $tplStr = []; foreach ($listInfo as $value) { if ($value['hash_type'] === 1) { - array_push($tplStr, 'Route::rule(\'' . addslashes($value->api_class) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);'); + array_push($tplStr, 'Route::rule(\'' . addslashes($value->api_class) . '\',\'api.' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([app\middleware\ApiAuth::class, app\middleware\ApiPermission::class, app\middleware\RequestFilter::class, app\middleware\ApiLog::class]);'); } else { - array_push($tplStr, 'Route::rule(\'' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);'); + array_push($tplStr, 'Route::rule(\'' . addslashes($value->hash) . '\',\'api.' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([app\middleware\ApiAuth::class, app\middleware\ApiPermission::class, app\middleware\RequestFilter::class, app\middleware\ApiLog::class]);'); } } $tplOriginStr = str_replace(['{$API_RULE}'], [implode($tplStr, PHP_EOL . ' ')], $tplOriginStr); diff --git a/app/middleware/ApiAuth.php b/app/middleware/ApiAuth.php index f923a8e..7764077 100644 --- a/app/middleware/ApiAuth.php +++ b/app/middleware/ApiAuth.php @@ -1,6 +1,7 @@ middleware('ApiResponse'); + Route::miss('api.Miss/index'); +})->middleware(app\middleware\ApiResponse::class); diff --git a/route/apiRoute.php b/route/apiRoute.php index 04c9232..f6dcc54 100644 --- a/route/apiRoute.php +++ b/route/apiRoute.php @@ -7,5 +7,5 @@ use think\facade\Route; Route::group('api', function() { //MISS路由定义 - Route::miss('api/Miss/index'); -})->middleware('ApiResponse'); + Route::miss('api.Miss/index'); +})->middleware(app\middleware\ApiResponse::class);