From a8b01c3e3d189a9101577a5bb02dc17beca65ed1 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 2 Nov 2020 11:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=A4=9A=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/composer/installed.json | 8 +++---- vendor/services.php | 2 +- .../zoujingli/think-library/src/Library.php | 2 +- .../think-library/src/multiple/BuildUrl.php | 24 ++++++++++++------- .../think-library/src/multiple/Multiple.php | 17 +++++++------ 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 4d72fd2f8..83cc6371b 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -941,12 +941,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "a7bf1dc5a4a4bcddcfcdf9f8e7472dbc07890f83" + "reference": "dcefe85f14c712583408aebf35c3e9dcb70b1e96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a7bf1dc5a4a4bcddcfcdf9f8e7472dbc07890f83", - "reference": "a7bf1dc5a4a4bcddcfcdf9f8e7472dbc07890f83", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/dcefe85f14c712583408aebf35c3e9dcb70b1e96", + "reference": "dcefe85f14c712583408aebf35c3e9dcb70b1e96", "shasum": "", "mirrors": [ { @@ -963,7 +963,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-10-31T06:54:57+00:00", + "time": "2020-11-02T03:28:32+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index a1b49b68c..127434723 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/Library.php b/vendor/zoujingli/think-library/src/Library.php index cd7f0451b..d57dfd38a 100644 --- a/vendor/zoujingli/think-library/src/Library.php +++ b/vendor/zoujingli/think-library/src/Library.php @@ -41,7 +41,7 @@ class Library extends Service /** * 版本号 */ - const VERSION = '6.0.19'; + const VERSION = '6.0.20'; /** * 启动服务 diff --git a/vendor/zoujingli/think-library/src/multiple/BuildUrl.php b/vendor/zoujingli/think-library/src/multiple/BuildUrl.php index 31aca36b2..2857268e2 100644 --- a/vendor/zoujingli/think-library/src/multiple/BuildUrl.php +++ b/vendor/zoujingli/think-library/src/multiple/BuildUrl.php @@ -45,7 +45,7 @@ class BuildUrl extends Url $url = $this->app->http->getName() . '/' . $request->controller() . '/' . $request->action(); } else { $path = explode('/', $url); - $action = array_pop($path); + $action = empty($path) ? $request->action() : array_pop($path); $controller = empty($path) ? $request->controller() : array_pop($path); $app = empty($path) ? $this->app->http->getName() : array_pop($path); $url = Str::snake($controller) . '/' . $action; @@ -137,17 +137,25 @@ class BuildUrl extends Url } } // 还原 URL 分隔符 - $depr = $this->route->config('pathinfo_depr'); - $url = str_replace('/', $depr, $url); $file = $request->baseFile(); - if ($file && 0 !== strpos($request->url(), $file)) { + $depr = $this->route->config('pathinfo_depr'); + [$uri, $url] = [$request->url(), str_replace('/', $depr, $url)]; + if ($file && 0 !== strpos($uri, $file)) { $file = str_replace('\\', '/', dirname($file)); } + /*=====- 多应用绑定 URL 生成处理 -=====*/ + $app = $this->app->http->getName(); + if ($this->app->http->isBind()) { + if (preg_match("#^{$app}({$depr}|\.|$)#i", $url)) { + $url = trim(substr($url, strlen($app)), $depr); + } elseif (substr_count($url, $depr) >= 2) { + $file = 'index.php'; + } + } /*=====- 插件 Addons URL 处理 - 开始 -=====*/ - $name = $this->app->http->getName(); - if (preg_match("#{$depr}addons-{$name}({$depr}|\.|$)#i", $request->url())) { - [$_name, $_attr] = explode($depr, $url . $depr, 2); - if ($_name === $name) $url = "addons-{$name}{$depr}" . rtrim($_attr, $depr); + if (preg_match("#^{$depr}addons-{$app}({$depr}|\.|$)#i", $uri)) { + [$prefix, $suffix] = explode($depr, $url . $depr, 2); + if ($prefix === $app) $url = rtrim("addons-{$app}{$depr}{$suffix}", $depr); } /*=====- 插件 Addons URL 处理 - 结束 -=====*/ $url = rtrim($file, '/') . '/' . ltrim($url, '/'); diff --git a/vendor/zoujingli/think-library/src/multiple/Multiple.php b/vendor/zoujingli/think-library/src/multiple/Multiple.php index 9f2fbdb4a..ca3efa4ec 100644 --- a/vendor/zoujingli/think-library/src/multiple/Multiple.php +++ b/vendor/zoujingli/think-library/src/multiple/Multiple.php @@ -78,13 +78,13 @@ class Multiple */ protected function parseMultiApp(): bool { - $scriptName = $this->scriptName(); $defaultApp = $this->app->config->get('app.default_app') ?: 'index'; - if ($this->name || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) { - $appName = $this->name ?: $scriptName; - $this->app->http->setBind(); + [$script, $path] = [$this->scriptName(), $this->app->request->pathinfo()]; + if ($this->name || ($script && !in_array($script, ['index', 'router', 'think']))) { + $appName = $this->name ?: $script; + $this->app->http->setBind(true); + $this->app->request->setPathinfo(preg_replace("#^{$script}\.php(/|\.|$)#i", '', $path) ?: '/'); } else { - // 自动多应用识别 $appName = null; $this->app->http->setBind(false); $bind = $this->app->config->get('app.domain_bind', []); @@ -93,17 +93,16 @@ class Multiple $subDomain = $this->app->request->subDomain(); if (isset($bind[$domain])) { $appName = $bind[$domain]; - $this->app->http->setBind(); + $this->app->http->setBind(true); } elseif (isset($bind[$subDomain])) { $appName = $bind[$subDomain]; - $this->app->http->setBind(); + $this->app->http->setBind(true); } elseif (isset($bind['*'])) { $appName = $bind['*']; - $this->app->http->setBind(); + $this->app->http->setBind(true); } } if (!$this->app->http->isBind()) { - $path = $this->app->request->pathinfo(); $map = $this->app->config->get('app.app_map', []); $deny = $this->app->config->get('app.deny_app_list', []); $name = current(explode('/', $path));