diff --git a/extend/base/admin/service/AdminUpdateServiceBase.php b/extend/base/admin/service/AdminUpdateServiceBase.php index 4e4da10..a05d5ca 100644 --- a/extend/base/admin/service/AdminUpdateServiceBase.php +++ b/extend/base/admin/service/AdminUpdateServiceBase.php @@ -344,6 +344,8 @@ class AdminUpdateServiceBase // 对比 composer.json 依赖差异 $this->compareComposerRequire($current_version_dir, $last_version_dir, $output); + $this->showPostUpdateGuidance($need_process_files, $output); + $output->writeln('更新完成'); // 更新完成 @@ -374,6 +376,48 @@ class AdminUpdateServiceBase $this->cleanWorkpaceDir(); } + protected function showPostUpdateGuidance(array $need_process_files, Output $output): void + { + if (empty($need_process_files)) { + return; + } + + $file_paths = array_keys($need_process_files); + $guidance = []; + + // Check if composer.json changed + foreach ($file_paths as $path) { + if ($path === 'composer.json') { + $guidance[] = ['composer install', 'composer.json 已变更,请更新依赖']; + break; + } + } + + // Check if database migrations changed + foreach ($file_paths as $path) { + if (str_starts_with($path, 'database/migrations/')) { + $guidance[] = ['php think migrate:run', '数据库迁移文件已变更,请执行迁移']; + break; + } + } + + // Check if extend/base or config changed (affects cache) + foreach ($file_paths as $path) { + if (str_starts_with($path, 'extend/base/') || str_starts_with($path, 'config/')) { + $guidance[] = ['php think clear', '框架核心或配置已变更,请清理缓存']; + break; + } + } + + if (!empty($guidance)) { + $output->writeln(''); + $output->writeln('建议执行以下后续操作:'); + foreach ($guidance as $item) { + $output->writeln(" [{$item[1]}] → {$item[0]}"); + } + } + } + protected function testIsOptionalFiles($file_path) { // 如果file_path以app或config开头,则是可选更新的文件