Merge branch 'feature-userinfo-daiyb' into dev

This commit is contained in:
戴育兵 2025-12-16 16:39:07 +08:00
commit a130bc03c8
2 changed files with 16 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"fonchain-fiee/pkg/model/login"
modelQwen "fonchain-fiee/pkg/model/qwen"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/utils"
"regexp"
"strings"
"time"
@ -217,6 +218,8 @@ func OneText(ctx *gin.Context) {
return
}
resultAll.Title, resultAll.Content = extractTitleAndContent(req.Prompt)
resultAll.Title = utils.TruncateString(resultAll.Title, 100)
resultAll.Content = utils.TruncateString(resultAll.Content, 200)
for _, v := range result.Output.Results {
resultAll.Result = append(resultAll.Result, struct {
Url string `json:"url"`
@ -384,6 +387,8 @@ func MoreText(ctx *gin.Context) {
}
resultAll.Content = contentRes.content
resultAll.Title = utils.TruncateString(resultAll.Title, 100)
resultAll.Content = utils.TruncateString(resultAll.Content, 200)
// 处理图片结果
if imageRes.err != nil {
service.Error(ctx, fmt.Errorf("生成图片失败: %v", imageRes.err))

View File

@ -7,3 +7,14 @@ func CleanString(s string) string {
fields := strings.Fields(s)
return strings.Join(fields, "")
}
func TruncateString(s string, maxLen int) string {
if maxLen <= 0 {
return ""
}
runes := []rune(s)
if len(runes) <= maxLen {
return s
}
return string(runes[:maxLen])
}