* +---------------------------------------------------------------------- */ use think\facade\Route; /** * crud 自动加载路由 * 自动加载crud目录下的所有路由文件 */ Route::group(function () { $path = $this->app->getRootPath() . 'app' . DS . 'adminapi' . DS . 'route' . DS . 'crud'; if (is_dir($path)) { $files = scandir($path); foreach ($files as $file) { if ($file != '.' && $file != '..') { include $path . DS . $file; } } } })->middleware([ \app\http\middleware\AllowOriginMiddleware::class, \app\adminapi\middleware\AdminAuthTokenMiddleware::class, \app\adminapi\middleware\AdminCheckRoleMiddleware::class, \app\adminapi\middleware\AdminLogMiddleware::class ])->option(['mark' => 'crud', 'mark_name' => '生成代码路由']);