mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Url类增加root方法 用于指定URL地址的root(不含域名)
This commit is contained in:
@@ -19,6 +19,9 @@ use think\Route;
|
|||||||
|
|
||||||
class Url
|
class Url
|
||||||
{
|
{
|
||||||
|
// 生成URL地址的root
|
||||||
|
protected static $root;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL生成 支持路由反射
|
* URL生成 支持路由反射
|
||||||
* @param string $url URL表达式,
|
* @param string $url URL表达式,
|
||||||
@@ -113,7 +116,7 @@ class Url
|
|||||||
// 检测域名
|
// 检测域名
|
||||||
$domain = self::parseDomain($url, $domain);
|
$domain = self::parseDomain($url, $domain);
|
||||||
// URL组装
|
// URL组装
|
||||||
$url = $domain . Request::instance()->root() . '/' . ltrim($url, '/');
|
$url = $domain . (self::$root ?: Request::instance()->root()) . '/' . ltrim($url, '/');
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,4 +369,11 @@ class Url
|
|||||||
{
|
{
|
||||||
Cache::rm('think_route_map');
|
Cache::rm('think_route_map');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 指定当前生成URL地址的root
|
||||||
|
public static function root($root)
|
||||||
|
{
|
||||||
|
self::$root = $root;
|
||||||
|
Request::instance()->root($root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user