40d9a6cc63
Introduce 仿写创作: new list and create views, backend imitation service and prompt templates, worker task routing for imitation jobs, and one-click rewrite triggers from question citation sources. Surface source article URL/title on article list/detail, and restrict failed articles to delete-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
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") {
|
|
return {
|
|
showPublish: false,
|
|
showEdit: true,
|
|
showPreview: false,
|
|
showCopy: false,
|
|
showDelete: true,
|
|
};
|
|
}
|
|
|
|
if (generateStatus === "failed") {
|
|
return {
|
|
showPublish: false,
|
|
showEdit: false,
|
|
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();
|
|
}
|