mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
兼容多应用地址生成
This commit is contained in:
parent
e8c8139587
commit
a8b01c3e3d
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -941,12 +941,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "a7bf1dc5a4a4bcddcfcdf9f8e7472dbc07890f83"
|
"reference": "dcefe85f14c712583408aebf35c3e9dcb70b1e96"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a7bf1dc5a4a4bcddcfcdf9f8e7472dbc07890f83",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/dcefe85f14c712583408aebf35c3e9dcb70b1e96",
|
||||||
"reference": "a7bf1dc5a4a4bcddcfcdf9f8e7472dbc07890f83",
|
"reference": "dcefe85f14c712583408aebf35c3e9dcb70b1e96",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -963,7 +963,7 @@
|
|||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"topthink/framework": "^6.0"
|
"topthink/framework": "^6.0"
|
||||||
},
|
},
|
||||||
"time": "2020-10-31T06:54:57+00:00",
|
"time": "2020-11-02T03:28:32+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2020-10-31 14:59:58
|
// This file is automatically generated at:2020-11-02 11:34:57
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\admin\\Library',
|
0 => 'think\\admin\\Library',
|
||||||
|
@ -41,7 +41,7 @@ class Library extends Service
|
|||||||
/**
|
/**
|
||||||
* 版本号
|
* 版本号
|
||||||
*/
|
*/
|
||||||
const VERSION = '6.0.19';
|
const VERSION = '6.0.20';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动服务
|
* 启动服务
|
||||||
|
@ -45,7 +45,7 @@ class BuildUrl extends Url
|
|||||||
$url = $this->app->http->getName() . '/' . $request->controller() . '/' . $request->action();
|
$url = $this->app->http->getName() . '/' . $request->controller() . '/' . $request->action();
|
||||||
} else {
|
} else {
|
||||||
$path = explode('/', $url);
|
$path = explode('/', $url);
|
||||||
$action = array_pop($path);
|
$action = empty($path) ? $request->action() : array_pop($path);
|
||||||
$controller = empty($path) ? $request->controller() : array_pop($path);
|
$controller = empty($path) ? $request->controller() : array_pop($path);
|
||||||
$app = empty($path) ? $this->app->http->getName() : array_pop($path);
|
$app = empty($path) ? $this->app->http->getName() : array_pop($path);
|
||||||
$url = Str::snake($controller) . '/' . $action;
|
$url = Str::snake($controller) . '/' . $action;
|
||||||
@ -137,17 +137,25 @@ class BuildUrl extends Url
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 还原 URL 分隔符
|
// 还原 URL 分隔符
|
||||||
$depr = $this->route->config('pathinfo_depr');
|
|
||||||
$url = str_replace('/', $depr, $url);
|
|
||||||
$file = $request->baseFile();
|
$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));
|
$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 处理 - 开始 -=====*/
|
/*=====- 插件 Addons URL 处理 - 开始 -=====*/
|
||||||
$name = $this->app->http->getName();
|
if (preg_match("#^{$depr}addons-{$app}({$depr}|\.|$)#i", $uri)) {
|
||||||
if (preg_match("#{$depr}addons-{$name}({$depr}|\.|$)#i", $request->url())) {
|
[$prefix, $suffix] = explode($depr, $url . $depr, 2);
|
||||||
[$_name, $_attr] = explode($depr, $url . $depr, 2);
|
if ($prefix === $app) $url = rtrim("addons-{$app}{$depr}{$suffix}", $depr);
|
||||||
if ($_name === $name) $url = "addons-{$name}{$depr}" . rtrim($_attr, $depr);
|
|
||||||
}
|
}
|
||||||
/*=====- 插件 Addons URL 处理 - 结束 -=====*/
|
/*=====- 插件 Addons URL 处理 - 结束 -=====*/
|
||||||
$url = rtrim($file, '/') . '/' . ltrim($url, '/');
|
$url = rtrim($file, '/') . '/' . ltrim($url, '/');
|
||||||
|
@ -78,13 +78,13 @@ class Multiple
|
|||||||
*/
|
*/
|
||||||
protected function parseMultiApp(): bool
|
protected function parseMultiApp(): bool
|
||||||
{
|
{
|
||||||
$scriptName = $this->scriptName();
|
|
||||||
$defaultApp = $this->app->config->get('app.default_app') ?: 'index';
|
$defaultApp = $this->app->config->get('app.default_app') ?: 'index';
|
||||||
if ($this->name || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) {
|
[$script, $path] = [$this->scriptName(), $this->app->request->pathinfo()];
|
||||||
$appName = $this->name ?: $scriptName;
|
if ($this->name || ($script && !in_array($script, ['index', 'router', 'think']))) {
|
||||||
$this->app->http->setBind();
|
$appName = $this->name ?: $script;
|
||||||
|
$this->app->http->setBind(true);
|
||||||
|
$this->app->request->setPathinfo(preg_replace("#^{$script}\.php(/|\.|$)#i", '', $path) ?: '/');
|
||||||
} else {
|
} else {
|
||||||
// 自动多应用识别
|
|
||||||
$appName = null;
|
$appName = null;
|
||||||
$this->app->http->setBind(false);
|
$this->app->http->setBind(false);
|
||||||
$bind = $this->app->config->get('app.domain_bind', []);
|
$bind = $this->app->config->get('app.domain_bind', []);
|
||||||
@ -93,17 +93,16 @@ class Multiple
|
|||||||
$subDomain = $this->app->request->subDomain();
|
$subDomain = $this->app->request->subDomain();
|
||||||
if (isset($bind[$domain])) {
|
if (isset($bind[$domain])) {
|
||||||
$appName = $bind[$domain];
|
$appName = $bind[$domain];
|
||||||
$this->app->http->setBind();
|
$this->app->http->setBind(true);
|
||||||
} elseif (isset($bind[$subDomain])) {
|
} elseif (isset($bind[$subDomain])) {
|
||||||
$appName = $bind[$subDomain];
|
$appName = $bind[$subDomain];
|
||||||
$this->app->http->setBind();
|
$this->app->http->setBind(true);
|
||||||
} elseif (isset($bind['*'])) {
|
} elseif (isset($bind['*'])) {
|
||||||
$appName = $bind['*'];
|
$appName = $bind['*'];
|
||||||
$this->app->http->setBind();
|
$this->app->http->setBind(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$this->app->http->isBind()) {
|
if (!$this->app->http->isBind()) {
|
||||||
$path = $this->app->request->pathinfo();
|
|
||||||
$map = $this->app->config->get('app.app_map', []);
|
$map = $this->app->config->get('app.app_map', []);
|
||||||
$deny = $this->app->config->get('app.deny_app_list', []);
|
$deny = $this->app->config->get('app.deny_app_list', []);
|
||||||
$name = current(explode('/', $path));
|
$name = current(explode('/', $path));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user