From e7d5d1b567915620ad22025a5665c2db0b1f0cee Mon Sep 17 00:00:00 2001 From: whwyy Date: Fri, 10 Jul 2026 15:57:45 +0800 Subject: [PATCH] eee --- src/Router.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Router.php b/src/Router.php index 8923e0a..b0de5a7 100644 --- a/src/Router.php +++ b/src/Router.php @@ -255,12 +255,14 @@ class Router } } - if (!empty($appChangedFiles)) { + if (!empty($appChangedFiles) && (bool)($scanConfig['expand_dependencies'] ?? false)) { $appChangedFiles = $scanner->expandDependentFiles($appChangedFiles, APP_PATH . 'app/'); } $usedArtifact = false; - if (($scanConfig['cache_enabled'] ?? false) && $artifactState->has(static::$type)) { + $canUseArtifact = $artifactState->has(static::$type) + && (!empty($changedFiles) || ($scanConfig['cache_enabled'] ?? false)); + if ($canUseArtifact) { $artifact = $artifactState->load(static::$type); $router = $container->get(DataGrip::class)->get(static::$type); $usedArtifact = $router->importArtifact($artifact, $appChangedFiles); @@ -270,12 +272,12 @@ class Router // route artifact 只加速注解路由,不能替代 routes/*.php 的注册副作用。 $this->read_dir_file(APP_PATH . 'routes'); - if (!empty($appChangedFiles) && ($scanConfig['cache_enabled'] ?? false)) { - $scanner->scanFiles($appChangedFiles, APP_PATH . 'app/', null, true); + if (!empty($appChangedFiles) && (($scanConfig['cache_enabled'] ?? false) || $usedArtifact)) { + $scanner->scanFiles($appChangedFiles, APP_PATH . 'app/', null, true, !$usedArtifact); } elseif (!$usedArtifact) { $scanner->scan(APP_PATH . 'app/'); } else { - $scanner->scanFiles([], APP_PATH . 'app/', null, false); + $scanner->scanFiles([], APP_PATH . 'app/', null, false, false); } $this->reset($container); $artifactState->store(static::$type, $container->get(DataGrip::class)->get(static::$type)->exportArtifact());