feat: add generation_mode to RecentArticle and related components

- Updated RecentArticle interface to include generation_mode.
- Modified workspace_service to map generation_mode from database.
- Adjusted domain model for RecentArticle to accommodate generation_mode.
- Enhanced SQL queries to retrieve generation_mode from generation_tasks.
- Created ArticleActionGroup component for article action buttons.
- Implemented ArticleGenerateStatus component to display generation status.
- Developed ArticlePublishStatus component to show publish status and related platforms.
- Introduced ArticleSourceMeta component to display article source information.
- Added utility functions for article actions and clipboard content generation.
This commit is contained in:
2026-04-07 16:07:21 +08:00
parent 9f721f6088
commit 98ebb12fa1
19 changed files with 1350 additions and 385 deletions
@@ -61,6 +61,7 @@ func (s *WorkspaceService) RecentArticles(ctx context.Context) ([]domain.RecentA
GenerateStatus: row.GenerateStatus,
PublishStatus: row.PublishStatus,
SourceType: row.SourceType,
GenerationMode: row.GenerationMode,
CreatedAt: row.CreatedAt,
Title: row.Title,
WordCount: row.WordCount,
@@ -16,6 +16,7 @@ type RecentArticle struct {
GenerateStatus string `json:"generate_status"`
PublishStatus string `json:"publish_status"`
SourceType string `json:"source_type"`
GenerationMode *string `json:"generation_mode"`
WordCount int `json:"word_count"`
SourceLabel *string `json:"source_label"`
CreatedAt time.Time `json:"created_at"`
@@ -95,10 +95,21 @@ func (q *Queries) GetQuotaSummary(ctx context.Context, tenantID int64) (int32, e
const getRecentArticles = `-- name: GetRecentArticles :many
SELECT a.id, a.generate_status, a.publish_status, a.source_type, a.created_at,
av.title, av.markdown_content, av.word_count, av.source_label,
t.template_name
t.template_name,
COALESCE(
NULLIF(gt.input_params_json ->> 'generation_mode', ''),
CASE WHEN a.source_type = 'custom_generation' THEN 'instant' ELSE NULL END
) AS generation_mode
FROM articles a
LEFT JOIN article_versions av ON av.id = a.current_version_id
LEFT JOIN article_templates t ON t.id = a.template_id
LEFT JOIN LATERAL (
SELECT input_params_json
FROM generation_tasks
WHERE article_id = a.id
ORDER BY created_at DESC
LIMIT 1
) gt ON true
WHERE a.tenant_id = $1 AND a.deleted_at IS NULL
ORDER BY a.created_at DESC
LIMIT 10
@@ -115,6 +126,7 @@ type GetRecentArticlesRow struct {
WordCount pgtype.Int4 `json:"word_count"`
SourceLabel pgtype.Text `json:"source_label"`
TemplateName pgtype.Text `json:"template_name"`
GenerationMode pgtype.Text `json:"generation_mode"`
}
func (q *Queries) GetRecentArticles(ctx context.Context, tenantID int64) ([]GetRecentArticlesRow, error) {
@@ -137,6 +149,7 @@ func (q *Queries) GetRecentArticles(ctx context.Context, tenantID int64) ([]GetR
&i.WordCount,
&i.SourceLabel,
&i.TemplateName,
&i.GenerationMode,
); err != nil {
return nil, err
}
@@ -13,10 +13,21 @@ WHERE tenant_id = sqlc.arg(tenant_id) AND deleted_at IS NULL;
-- name: GetRecentArticles :many
SELECT a.id, a.generate_status, a.publish_status, a.source_type, a.created_at,
av.title, av.markdown_content, av.word_count, av.source_label,
t.template_name
t.template_name,
COALESCE(
NULLIF(gt.input_params_json ->> 'generation_mode', ''),
CASE WHEN a.source_type = 'custom_generation' THEN 'instant' ELSE NULL END
) AS generation_mode
FROM articles a
LEFT JOIN article_versions av ON av.id = a.current_version_id
LEFT JOIN article_templates t ON t.id = a.template_id
LEFT JOIN LATERAL (
SELECT input_params_json
FROM generation_tasks
WHERE article_id = a.id
ORDER BY created_at DESC
LIMIT 1
) gt ON true
WHERE a.tenant_id = sqlc.arg(tenant_id) AND a.deleted_at IS NULL
ORDER BY a.created_at DESC
LIMIT 10;
@@ -15,6 +15,7 @@ type WorkspaceRecentArticle struct {
GenerateStatus string
PublishStatus string
SourceType string
GenerationMode *string
CreatedAt time.Time
Title *string
WordCount int
@@ -72,6 +73,7 @@ func (r *workspaceRepository) GetRecentArticles(ctx context.Context, tenantID in
GenerateStatus: row.GenerateStatus,
PublishStatus: row.PublishStatus,
SourceType: row.SourceType,
GenerationMode: nullableText(row.GenerationMode),
CreatedAt: timeFromTimestamp(row.CreatedAt),
Title: nullableText(row.Title),
WordCount: resolveWorkspaceWordCount(row.MarkdownContent, intFromInt4(row.WordCount)),