fix: 去除 blob 使用

This commit is contained in:
邹景立 2024-09-01 00:56:00 +08:00
parent 9c6b1c430e
commit 836d327971
3 changed files with 27 additions and 16 deletions

View File

@ -18,6 +18,8 @@ declare (strict_types=1);
namespace think\admin; namespace think\admin;
use SplFileInfo;
use think\admin\extend\ToolsExtend;
use think\admin\service\RuntimeService; use think\admin\service\RuntimeService;
use think\admin\support\command\Database; use think\admin\support\command\Database;
use think\admin\support\command\Package; use think\admin\support\command\Package;
@ -106,7 +108,9 @@ class Library extends Service
{ {
// 动态加载全局配置 // 动态加载全局配置
[$dir, $ext] = [$this->app->getBasePath(), $this->app->getConfigExt()]; [$dir, $ext] = [$this->app->getBasePath(), $this->app->getConfigExt()];
foreach (glob("{$dir}*/sys{$ext}") as $file) include_once $file; ToolsExtend::findFilesYield($dir, static function (SplFileInfo $info) use ($ext) {
$info->getBasename() === "sys{$ext}" && include_once $info->getPathname();
});
if (is_file($file = "{$dir}common{$ext}")) include_once $file; if (is_file($file = "{$dir}common{$ext}")) include_once $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);

View File

@ -20,6 +20,7 @@ namespace think\admin\extend;
use Exception; use Exception;
use Phinx\Db\Adapter\AdapterInterface; use Phinx\Db\Adapter\AdapterInterface;
use SplFileInfo;
use think\admin\Library; use think\admin\Library;
use think\admin\model\SystemMenu; use think\admin\model\SystemMenu;
use think\admin\service\ProcessService; use think\admin\service\ProcessService;
@ -290,20 +291,22 @@ CODE;
*/ */
private static function nextFile(string $class): string private static function nextFile(string $class): string
{ {
[$filename, $versions, $start] = [Str::snake($class), [], 20009999999999]; [$filename, $versions, $startVersion] = [Str::snake($class), [], 20009999999999];
if (count($files = glob(syspath('database/migrations/*.php'))) > 0) { ToolsExtend::findFilesYield(syspath('database/migrations'), static function (SplFileInfo $info) use ($class, $filename, &$versions) {
foreach ($files as $file) { $bname = pathinfo($info->getBasename(), PATHINFO_FILENAME);
$versions[] = $version = intval(substr($bname = pathinfo($file, 8), 0, 14)); $versions[] = $version = intval(substr($bname, 0, 14));
if ($filename === substr($bname, 15) && unlink($file)) { if ($filename === substr($bname, 15) && unlink($info->getRealPath())) {
echo " ** Notify: Class {$class} already exists and has been replaced." . PHP_EOL; echo " ** Notify: Class {$class} already exists and has been replaced." . PHP_EOL;
if (is_dir($dataPath = dirname($file) . DIRECTORY_SEPARATOR . $version)) { if (is_dir($dataPath = dirname($info->getRealPath()) . DIRECTORY_SEPARATOR . $version)) {
ToolsExtend::removeEmptyDirectory($dataPath); ToolsExtend::removeEmptyDirectory($dataPath);
}
} }
} }
$version = min($versions) - 1; });
}
if (!isset($version) || $version > $start) $version = $start; // 计算下一个版本号
$version = !empty($versions) ? min($versions) - 1 : $startVersion;
$version = min($version, $startVersion);
return "{$version}_{$filename}.php"; return "{$version}_{$filename}.php";
} }
} }

View File

@ -19,6 +19,8 @@ declare (strict_types=1);
namespace think\admin\support\middleware; namespace think\admin\support\middleware;
use Closure; use Closure;
use SplFileInfo;
use think\admin\extend\ToolsExtend;
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;
@ -165,9 +167,11 @@ 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}")) include_once $file;
foreach (glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $ext) as $file) { ToolsExtend::findFilesYield($appPath . 'config', static function (SplFileInfo $info) use ($ext) {
$this->app->config->load($file, $fmaps[] = pathinfo($file, PATHINFO_FILENAME)); if (strtolower(".{$info->getExtension()}") === "{$ext}") {
} $this->app->config->load($info->getPathname(), $info->getBasename($ext));
}
});
if (in_array('route', $fmaps) && method_exists($this->app->route, 'reload')) { if (in_array('route', $fmaps) && method_exists($this->app->route, 'reload')) {
$this->app->route->reload(); $this->app->route->reload();
} }