From 8dfcb6547cd347f6ab4ccbb01eea5c80ef5292e8 Mon Sep 17 00:00:00 2001 From: Jackzhou Date: Thu, 27 Aug 2026 18:00:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E5=8A=A9=E6=89=8Bbu?= =?UTF-8?q?g=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/official_account_article_service.go | 4 + .../internal/api/official_account_delivery.go | 3 +- .../internal/api/official_account_workflow.go | 21 +- .../model/official_account_article.go | 1 + .../workbench/OfficialAccountWorkflowPage.vue | 584 ++++++++++++++++-- 5 files changed, 573 insertions(+), 40 deletions(-) diff --git a/eai_ap_app/backend-go/internal/api/official_account_article_service.go b/eai_ap_app/backend-go/internal/api/official_account_article_service.go index 6047959..ce3baad 100644 --- a/eai_ap_app/backend-go/internal/api/official_account_article_service.go +++ b/eai_ap_app/backend-go/internal/api/official_account_article_service.go @@ -35,6 +35,7 @@ func ensureOfficialAccountArticle(task model.WorkerTask, workflow officialAccoun OutlineStyle: normalizeOfficialAccountOutlineStyle(workflow.Form.OutlineStyle), OutlineWords: normalizeOfficialAccountOutlineWords(workflow.Form.OutlineWords), ContentTargetWords: normalizeOfficialAccountContentTargetWords(workflow.Form.ContentTargetWords), + MaxContentImages: normalizeOfficialAccountMaxContentImages(workflow.Form.MaxContentImages), Status: "draft", } if err := store.DB.Create(row).Error; err != nil { @@ -56,6 +57,7 @@ func syncWorkflowFromOfficialAccountArticle(workflow *officialAccountWorkflowSta workflow.Form.OutlineStyle = normalizeOfficialAccountOutlineStyle(article.OutlineStyle) workflow.Form.OutlineWords = normalizeOfficialAccountOutlineWords(article.OutlineWords) workflow.Form.ContentTargetWords = normalizeOfficialAccountContentTargetWords(article.ContentTargetWords) + workflow.Form.MaxContentImages = normalizeOfficialAccountMaxContentImages(article.MaxContentImages) if strings.TrimSpace(article.TopicCandidatesJSON) != "" { var items []officialAccountTopicCandidate @@ -110,6 +112,7 @@ func syncOfficialAccountArticleFromWorkflow(article *model.OfficialAccountArticl article.OutlineStyle = normalizeOfficialAccountOutlineStyle(workflow.Form.OutlineStyle) article.OutlineWords = normalizeOfficialAccountOutlineWords(workflow.Form.OutlineWords) article.ContentTargetWords = normalizeOfficialAccountContentTargetWords(workflow.Form.ContentTargetWords) + article.MaxContentImages = normalizeOfficialAccountMaxContentImages(workflow.Form.MaxContentImages) article.SelectedTopic = workflow.Shared.SelectedTopic article.SelectedTitle = workflow.Shared.SelectedTitle article.Outline = workflow.Shared.Outline @@ -174,6 +177,7 @@ func resetOfficialAccountArticle(article *model.OfficialAccountArticle, req offi article.OutlineWords = normalizeOfficialAccountOutlineWords(req.OutlineWords) article.Outline = "" article.ContentTargetWords = normalizeOfficialAccountContentTargetWords(req.ContentTargetWords) + article.MaxContentImages = normalizeOfficialAccountMaxContentImages(req.MaxContentImages) article.Content = "" article.ContentWithPrompts = "" article.ImagePromptsJSON = "[]" diff --git a/eai_ap_app/backend-go/internal/api/official_account_delivery.go b/eai_ap_app/backend-go/internal/api/official_account_delivery.go index 1c5c75c..67d075c 100644 --- a/eai_ap_app/backend-go/internal/api/official_account_delivery.go +++ b/eai_ap_app/backend-go/internal/api/official_account_delivery.go @@ -147,6 +147,7 @@ func executeOfficialAccountPageMarkdownStep(workflow *officialAccountWorkflowSta func buildOfficialAccountImagePrompts(workflow *officialAccountWorkflowState) []officialAccountImagePrompt { title := firstNonEmpty(workflow.Shared.SelectedTitle, workflow.Form.Keyword, "公众号文章") sections := extractOfficialAccountSections(workflow.Shared.Content) + maxContentImages := normalizeOfficialAccountMaxContentImages(workflow.Form.MaxContentImages) prompts := []officialAccountImagePrompt{ { Key: "cover", @@ -155,7 +156,7 @@ func buildOfficialAccountImagePrompts(workflow *officialAccountWorkflowState) [] }, } for idx, item := range sections { - if idx >= 3 { + if maxContentImages > 0 && idx >= maxContentImages { break } prompts = append(prompts, officialAccountImagePrompt{ diff --git a/eai_ap_app/backend-go/internal/api/official_account_workflow.go b/eai_ap_app/backend-go/internal/api/official_account_workflow.go index b9be3d7..3ec2dbb 100644 --- a/eai_ap_app/backend-go/internal/api/official_account_workflow.go +++ b/eai_ap_app/backend-go/internal/api/official_account_workflow.go @@ -46,6 +46,7 @@ type officialAccountTaskCreateReq struct { OutlineStyle string `json:"outline_style"` OutlineWords int `json:"outline_words"` ContentTargetWords int `json:"content_target_words"` + MaxContentImages int `json:"max_content_images"` } type officialAccountStepReq struct { @@ -67,6 +68,7 @@ type officialAccountTaskUpdateReq struct { OutlineStyle string `json:"outline_style"` OutlineWords int `json:"outline_words"` ContentTargetWords int `json:"content_target_words"` + MaxContentImages int `json:"max_content_images"` } type officialAccountWorkflowState struct { @@ -87,6 +89,7 @@ type officialAccountForm struct { OutlineStyle string `json:"outline_style"` OutlineWords int `json:"outline_words"` ContentTargetWords int `json:"content_target_words"` + MaxContentImages int `json:"max_content_images"` } type officialAccountSharedState struct { @@ -275,7 +278,8 @@ func UpdateOfficialAccountTask(c *gin.Context) { oldWorkflow.Form.Requirements != req.Requirements || oldWorkflow.Form.OutlineStyle != normalizeOfficialAccountOutlineStyle(req.OutlineStyle) || oldWorkflow.Form.OutlineWords != normalizeOfficialAccountOutlineWords(req.OutlineWords) || - oldWorkflow.Form.ContentTargetWords != normalizeOfficialAccountContentTargetWords(req.ContentTargetWords) + oldWorkflow.Form.ContentTargetWords != normalizeOfficialAccountContentTargetWords(req.ContentTargetWords) || + oldWorkflow.Form.MaxContentImages != normalizeOfficialAccountMaxContentImages(req.MaxContentImages) workflow := oldWorkflow if changed { @@ -289,6 +293,7 @@ func UpdateOfficialAccountTask(c *gin.Context) { OutlineStyle: req.OutlineStyle, OutlineWords: req.OutlineWords, ContentTargetWords: req.ContentTargetWords, + MaxContentImages: req.MaxContentImages, }) } else { workflow.Form.BusinessDomain = resolveOfficialAccountBusinessDomain(req.BusinessDomain, req.Keyword) @@ -300,6 +305,7 @@ func UpdateOfficialAccountTask(c *gin.Context) { workflow.Form.OutlineStyle = normalizeOfficialAccountOutlineStyle(req.OutlineStyle) workflow.Form.OutlineWords = normalizeOfficialAccountOutlineWords(req.OutlineWords) workflow.Form.ContentTargetWords = normalizeOfficialAccountContentTargetWords(req.ContentTargetWords) + workflow.Form.MaxContentImages = normalizeOfficialAccountMaxContentImages(req.MaxContentImages) } if changed { @@ -352,6 +358,7 @@ func UpdateOfficialAccountTask(c *gin.Context) { "outline_style": normalizeOfficialAccountOutlineStyle(req.OutlineStyle), "outline_words": normalizeOfficialAccountOutlineWords(req.OutlineWords), "content_target_words": normalizeOfficialAccountContentTargetWords(req.ContentTargetWords), + "max_content_images": normalizeOfficialAccountMaxContentImages(req.MaxContentImages), }) logsJSON, _ := json.Marshal([]string{ fmt.Sprintf("%s 已切换主题并重置流程", now.Format("15:04:05")), @@ -556,6 +563,7 @@ func newOfficialAccountWorkflow(req officialAccountTaskCreateReq) officialAccoun OutlineStyle: normalizeOfficialAccountOutlineStyle(req.OutlineStyle), OutlineWords: normalizeOfficialAccountOutlineWords(req.OutlineWords), ContentTargetWords: normalizeOfficialAccountContentTargetWords(req.ContentTargetWords), + MaxContentImages: normalizeOfficialAccountMaxContentImages(req.MaxContentImages), }, Steps: map[string]*officialAccountStepState{}, Shared: officialAccountSharedState{ @@ -611,6 +619,16 @@ func normalizeOfficialAccountContentTargetWords(value int) int { return value } +func normalizeOfficialAccountMaxContentImages(value int) int { + if value <= 0 { + return 0 + } + if value > 20 { + return 20 + } + return value +} + func parseOfficialAccountWorkflow(value string) officialAccountWorkflowState { if strings.TrimSpace(value) == "" { return newOfficialAccountWorkflow(officialAccountTaskCreateReq{}) @@ -634,6 +652,7 @@ func parseOfficialAccountWorkflow(value string) officialAccountWorkflowState { if workflow.Form.Tone == "" { workflow.Form.Tone = "专业但好懂" } + workflow.Form.MaxContentImages = normalizeOfficialAccountMaxContentImages(workflow.Form.MaxContentImages) if workflow.Steps == nil { workflow.Steps = map[string]*officialAccountStepState{} } diff --git a/eai_ap_app/backend-go/internal/model/official_account_article.go b/eai_ap_app/backend-go/internal/model/official_account_article.go index 3426348..8284edf 100644 --- a/eai_ap_app/backend-go/internal/model/official_account_article.go +++ b/eai_ap_app/backend-go/internal/model/official_account_article.go @@ -23,6 +23,7 @@ type OfficialAccountArticle struct { OutlineWords int `gorm:"not null;default:600" json:"outline_words"` Outline string `gorm:"type:text" json:"outline"` ContentTargetWords int `gorm:"not null;default:1400" json:"content_target_words"` + MaxContentImages int `gorm:"not null;default:0" json:"max_content_images"` Content string `gorm:"type:text" json:"content"` ContentWithPrompts string `gorm:"type:text" json:"content_with_prompts"` ImagePromptsJSON string `gorm:"type:text" json:"image_prompts_json"` diff --git a/eai_ap_app/frontend/src/views/workbench/OfficialAccountWorkflowPage.vue b/eai_ap_app/frontend/src/views/workbench/OfficialAccountWorkflowPage.vue index 4d8adf6..dbdbb08 100644 --- a/eai_ap_app/frontend/src/views/workbench/OfficialAccountWorkflowPage.vue +++ b/eai_ap_app/frontend/src/views/workbench/OfficialAccountWorkflowPage.vue @@ -16,6 +16,14 @@ + + +
当前将按「{{ taskResolvedBusinessDomain.label }}」处理热点源、评分规则和 Prompt @@ -80,7 +88,7 @@ @@ -437,7 +488,7 @@