From 773799e6e02842aa688da030973f709f515fb15a Mon Sep 17 00:00:00 2001 From: cjy Date: Fri, 16 Jan 2026 11:51:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8E=BB=E6=8E=89=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E5=A4=9A=E4=BD=99=E7=9A=84=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/cast/tag.go | 7 +++++++ pkg/utils/string.go | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/service/cast/tag.go b/pkg/service/cast/tag.go index 2dfa6f3..5cd9956 100644 --- a/pkg/service/cast/tag.go +++ b/pkg/service/cast/tag.go @@ -326,6 +326,13 @@ func GenerateAutoHashtags(ctx context.Context, post string, max int32, position, return nil, nil, false, errors.New("自动生成标签失败") } + if resp.Post == "" { + return nil, nil, false, errors.New("自动生成标签返回的帖子内容为空") + } + + // 去掉自动标签返回的帖子内容多余的引号 + resp.Post = utils.CleanAutoHashtagsQuote(resp.Post) + // 提取生成后的标签 afterTags := utils.ExtractTags(resp.Post) zap.L().Info("GenerateAutoHashtags afterTags", zap.Strings("afterTags", afterTags)) diff --git a/pkg/utils/string.go b/pkg/utils/string.go index 2924c28..e680913 100644 --- a/pkg/utils/string.go +++ b/pkg/utils/string.go @@ -41,3 +41,13 @@ func ExtractTags(s string) []string { return tags } + +// 去掉自动标签里面多余的引号 +func CleanAutoHashtagsQuote(input string) string { + if input == "" { + return "" + } + cleaned := strings.ReplaceAll(input, "\\\"", "") + cleaned = strings.ReplaceAll(cleaned, "\"", "") + return cleaned +}