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();
|
||||
}
|
||||
@@ -25,6 +25,18 @@ const platformCatalog: Record<string, Omit<PublishPlatformOption, "accountLabel"
|
||||
dongchedi: { id: "dongchedi", name: "懂车帝", shortName: "懂", accent: "#fadb14" },
|
||||
};
|
||||
|
||||
export function getPublishPlatformMeta(platformId: string): Omit<PublishPlatformOption, "accountLabel" | "bound"> {
|
||||
const normalized = normalizePublishPlatformId(platformId);
|
||||
const fallbackShortName = normalized.slice(0, 1).toUpperCase() || "?";
|
||||
|
||||
return platformCatalog[normalized] ?? {
|
||||
id: normalized,
|
||||
name: normalized || "--",
|
||||
shortName: fallbackShortName,
|
||||
accent: "#667085",
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizePublishPlatformId(platformId?: string | null): string {
|
||||
return String(platformId ?? "").trim();
|
||||
}
|
||||
@@ -73,8 +85,7 @@ export function parseTargetPlatforms(value?: string | null): string[] {
|
||||
}
|
||||
|
||||
export function getPublishPlatformLabel(platformId: string): string {
|
||||
const normalized = normalizePublishPlatformId(platformId);
|
||||
return platformCatalog[normalized]?.name ?? normalized;
|
||||
return getPublishPlatformMeta(platformId).name;
|
||||
}
|
||||
|
||||
export function formatPublishPlatformSummary(value?: string | null): string {
|
||||
|
||||
Reference in New Issue
Block a user