core/Route.php
public static function register(string $name, $route = null)
    {
        if (empty($name)) {
            return;
        }
        //默认数据
        $map = [
            'path' => 'app/' . $name,
            'namespace' => 'app\\' . $name,
            'base' => '/' . ($name == 'home' ? '' : $name),
            'rules' => [
                '@^/(\w+)/(\w+)/(\d+)$@i' => [
                    'ctl' => '$1',
                    'act' => '$2',
                    'id' => '$3',
                ],
                '@^/(\w+)/(\d+)$@i' => [
                    'ctl' => '$1',
                    'act' => 'index',
                    'id' => '$2',
                ],
                '@^/(\w+)/(\w+)$@i' => [
                    'ctl' => '$1',
                    'act' => '$2',
                ],
                '@^/(\w+)/?$@i' => [
                    'ctl' => '$1',
                    'act' => 'index',
                ],
                '@^/$@' => [
                    'ctl' => 'index',
                    'act' => 'index',
                ],
            ],
            'resolve' => function ($ctl, $act, $keys = []) {
                $url = '/{ctl}';
                if (!empty($act) && $act != 'index') {
                    $url .= '/{act}';
                }
                if (isset($keys['id'])) {
                    $url .= '/{id}';
                }
                return $url;
            }
        ];

        if ($route === null) {
            if (empty(self::$routePath)) {
                self::$routePath = Utils::path(ROOT_DIR, 'config');
            }
            $filePath = Utils::path(self::$routePath, $name . '.route.php');
            if (file_exists($filePath)) {
                $map = require $filePath;
            }
        } else if (is_array($route)) {
            $map = array_merge($map, $route);
        }
        $map['name'] = $name;
        $map['base'] = rtrim(empty($map['base']) ? '' : $map['base'], '/');
        $map['base_match'] = '@^' . preg_quote($map['base'], '@') . '(/.*)?$@i';
        $map['path'] = Utils::trimPath($map['path']);
        self::$routeMap[$name] = $map;
    }
public static function register(string $name, $route = null)
    {
        if (empty($name)) {
            return;
        }
        //默认数据
        $map = [
            'path' => 'app/' . $name,
            'namespace' => 'app\\' . $name,
            'base' => '/' . ($name == 'home' ? '' : $name),
            'rules' => [
                '@^/(\w+)/(\w+)/(\d+)$@i' => [
                    'ctl' => '$1',
                    'act' => '$2',
                    'id' => '$3',
                ],
                '@^/(\w+)/(\d+)$@i' => [
                    'ctl' => '$1',
                    'act' => 'index',
                    'id' => '$2',
                ],
                '@^/(\w+)/(\w+)$@i' => [
                    'ctl' => '$1',
                    'act' => '$2',
                ],
                '@^/(\w+)/?$@i' => [
                    'ctl' => '$1',
                    'act' => 'index',
                ],
                '@^/$@' => [
                    'ctl' => 'index',
                    'act' => 'index',
                ],
            ],
            'resolve' => function ($ctl, $act, $keys = []) {
                $url = '/{ctl}';
                if (!empty($act) && $act != 'index') {
                    $url .= '/{act}';
                }
                if (isset($keys['id'])) {
                    $url .= '/{id}';
                }
                return $url;
            }
        ];

        if ($route === null) {
            if (empty(self::$routePath)) {
                self::$routePath = Utils::path(ROOT_DIR, 'config');
            }
            $filePath = Utils::path(self::$routePath, $name . '.route.php');
            if (file_exists($filePath)) {
                $map = require $filePath;
            }
        } else if (is_array($route)) {
            $map = array_merge($map, $route);
        }
        $map['name'] = $name;
        $map['base'] = rtrim(empty($map['base']) ? '' : $map['base'], '/');
        $map['base_match'] = '@^' . preg_quote($map['base'], '@') . '(/.*)?$@i';
        $map['path'] = Utils::trimPath($map['path']);
        self::$routeMap[$name] = $map;
    }
注册路由规则
@param string $name
@param array|bool $route