feat(update): 后更新引导提示

This commit is contained in:
augushong
2026-05-25 21:41:55 +08:00
parent 65b196e768
commit 07d5823c81

View File

@@ -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开头则是可选更新的文件