feat: add cover image functionality for articles

- Implemented `resolveApiURL` function to handle various URL formats.
- Updated `ArticleDetail` and `UpdateArticleRequest` interfaces to include `cover_asset_url`.
- Enhanced `ArticleEditorView` to manage cover image uploads, including a new `CoverPickerModal` component.
- Added cover image requirements logic in `cover-requirements.ts` to enforce platform-specific cover image rules.
- Modified backend services to handle cover image uploads and validations, including checks for required cover images for specific platforms.
- Improved error handling for cover image requirements during article publishing.
This commit is contained in:
2026-04-07 09:19:03 +08:00
parent 1e844704e4
commit 9f721f6088
13 changed files with 1360 additions and 129 deletions
@@ -263,6 +263,7 @@ type ArticleDetailResponse struct {
TemplateName *string `json:"template_name"`
GenerationMode *string `json:"generation_mode"`
Platforms []string `json:"platforms"`
CoverAssetURL *string `json:"cover_asset_url"`
GenerateStatus string `json:"generate_status"`
PublishStatus string `json:"publish_status"`
Title *string `json:"title"`
@@ -310,6 +311,7 @@ func (s *ArticleService) Detail(ctx context.Context, id int64) (*ArticleDetailRe
}
d.GenerationMode = resolveArticleGenerationMode(dbSourceType, inputParamsJSON)
d.Platforms = resolveArticlePlatforms(wizardStateJSON, inputParamsJSON)
d.CoverAssetURL = resolveArticleCoverAssetURL(wizardStateJSON)
d.WordCount = resolveWordCount(d.MarkdownContent, d.WordCount)
return &d, nil
}
@@ -366,6 +368,7 @@ type UpdateArticleRequest struct {
Title string `json:"title"`
MarkdownContent string `json:"markdown_content"`
Platforms []string `json:"platforms"`
CoverAssetURL *string `json:"cover_asset_url"`
}
type ArticleImageUploadResponse struct {
@@ -418,7 +421,7 @@ func (s *ArticleService) Update(ctx context.Context, id int64, req UpdateArticle
wordCount := countArticleWords(markdown)
sourceLabel := "手动编辑"
nextWizardStateJSON, err := mergeArticleWizardState(wizardStateJSON, title, req.Platforms)
nextWizardStateJSON, err := mergeArticleWizardState(wizardStateJSON, title, req.Platforms, req.CoverAssetURL)
if err != nil {
return nil, response.ErrInternal(50012, "update_failed", "failed to update article metadata")
}