mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-07 12:38:11 +08:00
fix: 更新文件加载
This commit is contained in:
parent
4a896ae268
commit
eed59e2413
@ -30,6 +30,7 @@ use think\admin\support\command\Sysmenu;
|
|||||||
use think\admin\support\middleware\JwtSession;
|
use think\admin\support\middleware\JwtSession;
|
||||||
use think\admin\support\middleware\MultAccess;
|
use think\admin\support\middleware\MultAccess;
|
||||||
use think\admin\support\middleware\RbacAccess;
|
use think\admin\support\middleware\RbacAccess;
|
||||||
|
use think\exception\HttpException;
|
||||||
use think\exception\HttpResponseException;
|
use think\exception\HttpResponseException;
|
||||||
use think\middleware\LoadLangPack;
|
use think\middleware\LoadLangPack;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
@ -100,6 +101,21 @@ class Library extends Service
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态加载文件
|
||||||
|
* @param string $file
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function load(string $file)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return include $file;
|
||||||
|
} catch (\Throwable|\Error $error) {
|
||||||
|
trace_file($error);
|
||||||
|
throw new HttpException(500, $error->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化服务
|
* 初始化服务
|
||||||
* @return void
|
* @return void
|
||||||
@ -109,9 +125,9 @@ class Library extends Service
|
|||||||
// 动态加载全局配置
|
// 动态加载全局配置
|
||||||
[$dir, $ext] = [$this->app->getBasePath(), $this->app->getConfigExt()];
|
[$dir, $ext] = [$this->app->getBasePath(), $this->app->getConfigExt()];
|
||||||
ToolsExtend::find($dir, 2, function (SplFileInfo $info) use ($ext) {
|
ToolsExtend::find($dir, 2, function (SplFileInfo $info) use ($ext) {
|
||||||
$info->isFile() && $info->getBasename() === "sys{$ext}" && include_once $info->getPathname();
|
$info->isFile() && $info->getBasename() === "sys{$ext}" && Library::load($info->getPathname());
|
||||||
});
|
});
|
||||||
if (is_file($file = "{$dir}common{$ext}")) include_once $file;
|
if (is_file($file = "{$dir}common{$ext}")) Library::load($file);
|
||||||
if (is_file($file = "{$dir}provider{$ext}")) $this->app->bind(include $file);
|
if (is_file($file = "{$dir}provider{$ext}")) $this->app->bind(include $file);
|
||||||
if (is_file($file = "{$dir}event{$ext}")) $this->app->loadEvent(include $file);
|
if (is_file($file = "{$dir}event{$ext}")) $this->app->loadEvent(include $file);
|
||||||
if (is_file($file = "{$dir}middleware{$ext}")) $this->app->middleware->import(include $file, 'app');
|
if (is_file($file = "{$dir}middleware{$ext}")) $this->app->middleware->import(include $file, 'app');
|
||||||
|
|||||||
@ -21,6 +21,7 @@ namespace think\admin\support\middleware;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use SplFileInfo;
|
use SplFileInfo;
|
||||||
use think\admin\extend\ToolsExtend;
|
use think\admin\extend\ToolsExtend;
|
||||||
|
use think\admin\Library;
|
||||||
use think\admin\Plugin;
|
use think\admin\Plugin;
|
||||||
use think\admin\service\NodeService;
|
use think\admin\service\NodeService;
|
||||||
use think\admin\service\SystemService;
|
use think\admin\service\SystemService;
|
||||||
@ -168,7 +169,7 @@ class MultAccess
|
|||||||
{
|
{
|
||||||
[$ext, $fmaps] = [$this->app->getConfigExt(), []];
|
[$ext, $fmaps] = [$this->app->getConfigExt(), []];
|
||||||
// 加载应用函数文件
|
// 加载应用函数文件
|
||||||
if (is_file($file = "{$appPath}common{$ext}")) include_once $file;
|
if (is_file($file = "{$appPath}common{$ext}")) Library::load($file);
|
||||||
// 加载应用配置文件
|
// 加载应用配置文件
|
||||||
ToolsExtend::find($appPath . 'config', 1, function (SplFileInfo $info) use ($ext) {
|
ToolsExtend::find($appPath . 'config', 1, function (SplFileInfo $info) use ($ext) {
|
||||||
if ($info->isFile() && strtolower(".{$info->getExtension()}") === $ext) {
|
if ($info->isFile() && strtolower(".{$info->getExtension()}") === $ext) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user