From 57a8c9932019ce4ad33e1d03f52f997611243d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Fri, 13 Oct 2023 18:38:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E6=A8=A1=E5=9D=97=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E6=96=87=E4=BB=B6=E5=A4=87=E4=BB=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/library/module/Manage.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/admin/library/module/Manage.php b/app/admin/library/module/Manage.php index 398a3f78..dc7eee43 100644 --- a/app/admin/library/module/Manage.php +++ b/app/admin/library/module/Manage.php @@ -401,9 +401,14 @@ class Manage } // 备份 + $dependJsonFiles = [ + 'composer' => 'composer.json', + 'webPackage' => 'web' . DIRECTORY_SEPARATOR . 'package.json', + 'webNuxtPackage' => 'web-nuxt' . DIRECTORY_SEPARATOR . 'package.json', + ]; $dependWaitInstall = []; if ($delComposerDepend) { - $conflictFile[] = 'composer.json'; + $conflictFile[] = $dependJsonFiles['composer']; $dependWaitInstall[] = [ 'pm' => false, 'command' => 'composer.update', @@ -411,7 +416,7 @@ class Manage ]; } if ($delNpmDepend) { - $conflictFile[] = 'web' . DIRECTORY_SEPARATOR . 'package.json'; + $conflictFile[] = $dependJsonFiles['webPackage']; $dependWaitInstall[] = [ 'pm' => true, 'command' => 'web-install', @@ -419,7 +424,7 @@ class Manage ]; } if ($delNuxtNpmDepend) { - $conflictFile[] = 'web-nuxt' . DIRECTORY_SEPARATOR . 'package.json'; + $conflictFile[] = $dependJsonFiles['webNuxtPackage']; $dependWaitInstall[] = [ 'pm' => true, 'command' => 'nuxt-install', @@ -430,8 +435,15 @@ class Manage // 如果是模块自带文件需要备份,加上模块目录前缀 $overwriteDir = Server::getOverwriteDir(); foreach ($conflictFile as $key => $item) { - $paths = explode(DIRECTORY_SEPARATOR, $item); - $conflictFile[$key] = in_array($paths[0], $overwriteDir) ? $item : Filesystem::fsFit(str_replace(root_path(), '', $this->modulesDir . $item)); + $paths = explode(DIRECTORY_SEPARATOR, $item); + if (in_array($paths[0], $overwriteDir) || in_array($item, $dependJsonFiles)) { + $conflictFile[$key] = $item; + } else { + $conflictFile[$key] = Filesystem::fsFit(str_replace(root_path(), '', $this->modulesDir . $item)); + } + if (!is_file(root_path() . $conflictFile[$key])) { + unset($conflictFile[$key]); + } } $backupsZip = $this->backupsDir . $this->uid . '-disable-' . date('YmdHis') . '.zip'; Filesystem::zip($conflictFile, $backupsZip);