diff --git a/app/Console/Commands/SablogImport.php b/app/Console/Commands/SablogImport.php index eaef55a..3d00897 100644 --- a/app/Console/Commands/SablogImport.php +++ b/app/Console/Commands/SablogImport.php @@ -340,7 +340,9 @@ class SablogImport extends Command continue; } - $tag = Tag::query()->where('name', $tagName)->where('type', 'post')->first(); + // spatie/tags 的 name 是 JSON 翻译字段,直接 where('name', ...) 匹配不到, + // 必须用 findFromString(内部按 locale 查询 JSON 键),否则每次导入都重复建标签 + $tag = Tag::findFromString($tagName, 'post'); if (! $tag) { $tag = new Tag(['name' => $tagName, 'type' => 'post']); $tag->slug = SlugGenerator::make($tagName, 'tags', 'slug', fallback: 'tag-'.crc32($tagName));