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);