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:
@@ -0,0 +1,49 @@
|
||||
import type { ArticleDetail } from "@geo/shared-types";
|
||||
|
||||
export interface ArticleActionState {
|
||||
showPublish: boolean;
|
||||
showEdit: boolean;
|
||||
showPreview: boolean;
|
||||
showCopy: boolean;
|
||||
showDelete: boolean;
|
||||
}
|
||||
|
||||
export function resolveArticleActionState(generateStatus?: string | null): ArticleActionState {
|
||||
if (generateStatus === "completed") {
|
||||
return {
|
||||
showPublish: true,
|
||||
showEdit: true,
|
||||
showPreview: true,
|
||||
showCopy: true,
|
||||
showDelete: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (generateStatus === "draft" || generateStatus === "failed") {
|
||||
return {
|
||||
showPublish: false,
|
||||
showEdit: true,
|
||||
showPreview: false,
|
||||
showCopy: false,
|
||||
showDelete: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
showPublish: false,
|
||||
showEdit: false,
|
||||
showPreview: true,
|
||||
showCopy: false,
|
||||
showDelete: true,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildArticleClipboardContent(detail: Pick<ArticleDetail, "title" | "markdown_content">): string {
|
||||
return [
|
||||
detail.title ? `# ${detail.title}` : "",
|
||||
detail.markdown_content ?? "",
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("\n\n")
|
||||
.trim();
|
||||
}
|
||||
Reference in New Issue
Block a user