架构调整路由加载
This commit is contained in:
parent
2d95212973
commit
2c18af0aa7
@ -6,6 +6,7 @@ namespace catcher\event;
|
|||||||
use catchAdmin\permissions\PermissionsMiddleware;
|
use catchAdmin\permissions\PermissionsMiddleware;
|
||||||
use catchAdmin\user\AuthTokenMiddleware;
|
use catchAdmin\user\AuthTokenMiddleware;
|
||||||
use catcher\CatchAdmin;
|
use catcher\CatchAdmin;
|
||||||
|
use think\App;
|
||||||
use think\Route;
|
use think\Route;
|
||||||
|
|
||||||
class LoadModuleRoutes
|
class LoadModuleRoutes
|
||||||
@ -19,28 +20,21 @@ class LoadModuleRoutes
|
|||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$router = app(Route::class);
|
$router = app(Route::class);
|
||||||
|
|
||||||
$domain = config('catch.domain');
|
$domain = config('catch.domain');
|
||||||
|
$paths = app(App::class)->make('routePath')->get();
|
||||||
$routes = CatchAdmin::getRoutes();
|
// $routeMiddleware = config('catch.route_middleware');
|
||||||
|
|
||||||
$routeMiddleware = config('catch.route_middleware');
|
|
||||||
|
|
||||||
if ($domain) {
|
if ($domain) {
|
||||||
$router->domain($domain, function () use ($router, $routes) {
|
$router->domain($domain, function () use ($router, $paths) {
|
||||||
foreach ($routes as $route) {
|
foreach ($paths as $path) {
|
||||||
include $route;
|
include $path;
|
||||||
}
|
}
|
||||||
})->middleware($routeMiddleware);
|
});
|
||||||
} else {
|
} else {
|
||||||
$router->group(function () use ($router, $routes) {
|
$router->group(function () use ($router, $paths) {
|
||||||
foreach ($routes as $route) {
|
foreach ($paths as $path) {
|
||||||
include $route;
|
include $path;
|
||||||
}
|
}
|
||||||
})->middleware($routeMiddleware);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 单独加载登录
|
|
||||||
include CatchAdmin::moduleDirectory('login') . 'route.php';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user