core/Route.php
public static function url($url = null, array $query = [])
    {
        if (is_array($url)) {
            $url['app'] = isset($url['app']) ? $url['app'] : self::get('app');
            $url['ctl'] = isset($url['ctl']) ? $url['ctl'] : self::get('ctl');
            $url['act'] = isset($url['act']) ? $url['act'] : self::get('act');
            $temp = '^/' . $url['app'] . '/' . $url['ctl'] . '/' . $url['act'];
            unset($url['app']);
            unset($url['ctl']);
            unset($url['act']);
            if (!empty($url) && is_array($query)) {
                $query = array_merge($url, $query);
            }
            $url = $temp;
        }
        if (!is_string($url)) {
            return $url;
        }
        $innerUri = (isset($url[1]) && ($url[0] == '~' || $url[0] == '^') && $url[1] == '/');
        if (!$innerUri) {
            if ($query == null || count($query) == 0) {
                return $url;
            }
        }
        $info = parse_url($url);
        $path = isset($info['path']) ? $info['path'] : '';
        $str_query = isset($info['query']) ? $info['query'] : '';
        $query = is_array($query) ? $query : [];
        //合并参数
        if (!empty($str_query)) {
            $temp = [];
            parse_str($str_query, $temp);
            $query = array_merge($temp, $query);
        }
        if (!$innerUri) {
            $str_query = http_build_query($query);
            if (!empty($str_query)) {
                return $path . '?' . $str_query;
            }
            return $path;
        }
        if ($url[0] == '~') {
            $app = self::get('app');
            $path = substr($path, 1);
            return self::resolve($app, $path, $query);
        }
        if (!preg_match('@^\^/(\w+)((?:/\w+){1,2})?$@', $path, $data)) {
            return $url;
        }
        $app = isset($data[1]) ? $data[1] : self::get('app');
        $path = isset($data[2]) ? $data[2] : self::get('path');
        $path = empty($path) ? '/' : $path;
        return self::resolve($app, $path, $query);
    }
public static function url($url = null, array $query = [])
    {
        if (is_array($url)) {
            $url['app'] = isset($url['app']) ? $url['app'] : self::get('app');
            $url['ctl'] = isset($url['ctl']) ? $url['ctl'] : self::get('ctl');
            $url['act'] = isset($url['act']) ? $url['act'] : self::get('act');
            $temp = '^/' . $url['app'] . '/' . $url['ctl'] . '/' . $url['act'];
            unset($url['app']);
            unset($url['ctl']);
            unset($url['act']);
            if (!empty($url) && is_array($query)) {
                $query = array_merge($url, $query);
            }
            $url = $temp;
        }
        if (!is_string($url)) {
            return $url;
        }
        $innerUri = (isset($url[1]) && ($url[0] == '~' || $url[0] == '^') && $url[1] == '/');
        if (!$innerUri) {
            if ($query == null || count($query) == 0) {
                return $url;
            }
        }
        $info = parse_url($url);
        $path = isset($info['path']) ? $info['path'] : '';
        $str_query = isset($info['query']) ? $info['query'] : '';
        $query = is_array($query) ? $query : [];
        //合并参数
        if (!empty($str_query)) {
            $temp = [];
            parse_str($str_query, $temp);
            $query = array_merge($temp, $query);
        }
        if (!$innerUri) {
            $str_query = http_build_query($query);
            if (!empty($str_query)) {
                return $path . '?' . $str_query;
            }
            return $path;
        }
        if ($url[0] == '~') {
            $app = self::get('app');
            $path = substr($path, 1);
            return self::resolve($app, $path, $query);
        }
        if (!preg_match('@^\^/(\w+)((?:/\w+){1,2})?$@', $path, $data)) {
            return $url;
        }
        $app = isset($data[1]) ? $data[1] : self::get('app');
        $path = isset($data[2]) ? $data[2] : self::get('path');
        $path = empty($path) ? '/' : $path;
        return self::resolve($app, $path, $query);
    }
获取生成的URL
~/ctl/act
^/admin/ctl/act
@param string $url
@param array $query
@return bool|mixed|null|string