feat(admin-web/articles): show partial-success publish status from records
ArticlePublishStatus now derives partial_success when both succeeded and failed records are present, fetches publish_records eagerly with a 30s stale window so the popover lights up without a click, and ArticleDetail Drawer reuses the component instead of its own tag. Relabel partial_ success copy to 部分发布 / Partially Published to match the new bucket. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import type { ArticleVersion, PublishRecord } from "@geo/shared-types";
|
|||||||
import { computed, ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
|
import ArticlePublishStatus from "@/components/ArticlePublishStatus.vue";
|
||||||
import MarkdownPreview from "@/components/MarkdownPreview.vue";
|
import MarkdownPreview from "@/components/MarkdownPreview.vue";
|
||||||
import {
|
import {
|
||||||
articlesApi,
|
articlesApi,
|
||||||
@@ -121,7 +122,6 @@ const displayMarkdown = computed(() => streamMarkdown.value || detail.value?.mar
|
|||||||
const generateMeta = computed(() =>
|
const generateMeta = computed(() =>
|
||||||
getGenerateStatusMeta(streamStatus.value || detail.value?.generate_status),
|
getGenerateStatusMeta(streamStatus.value || detail.value?.generate_status),
|
||||||
);
|
);
|
||||||
const publishMeta = computed(() => getPublishStatusMeta(detail.value?.publish_status));
|
|
||||||
const sourceArticleTitle = computed(() => detail.value?.source_title?.trim() || "");
|
const sourceArticleTitle = computed(() => detail.value?.source_title?.trim() || "");
|
||||||
const sourceArticleURL = computed(() => detail.value?.source_url?.trim() || "");
|
const sourceArticleURL = computed(() => detail.value?.source_url?.trim() || "");
|
||||||
|
|
||||||
@@ -274,7 +274,11 @@ async function copyPublishLink(record: PublishRecord): Promise<void> {
|
|||||||
|
|
||||||
<div class="article-drawer__tags">
|
<div class="article-drawer__tags">
|
||||||
<a-tag :color="generateMeta.color">{{ generateMeta.label }}</a-tag>
|
<a-tag :color="generateMeta.color">{{ generateMeta.label }}</a-tag>
|
||||||
<a-tag :color="publishMeta.color">{{ publishMeta.label }}</a-tag>
|
<ArticlePublishStatus
|
||||||
|
:status="detail.publish_status"
|
||||||
|
:article-id="detail.id"
|
||||||
|
:show-platforms="false"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ const props = withDefaults(defineProps<{
|
|||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const popoverOpen = ref(false);
|
const popoverOpen = ref(false);
|
||||||
const shouldLoadPlatforms = computed(() => props.showPlatforms && Boolean(props.articleId) && props.status !== "unpublished");
|
const shouldLoadRecords = computed(() => Boolean(props.articleId) && props.status !== "unpublished");
|
||||||
|
const shouldLoadPlatforms = computed(() => props.showPlatforms && shouldLoadRecords.value);
|
||||||
|
|
||||||
const platformsQuery = useQuery({
|
const platformsQuery = useQuery({
|
||||||
queryKey: ["media", "platforms", "publish-status"],
|
queryKey: ["media", "platforms", "publish-status"],
|
||||||
@@ -50,12 +51,13 @@ const platformsQuery = useQuery({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const publishRecordsQuery = useQuery({
|
const publishRecordsQuery = useQuery({
|
||||||
queryKey: computed(() => ["articles", "publish-records", props.articleId, "publish-status"]),
|
queryKey: computed(() => ["articles", "publish-records", props.articleId]),
|
||||||
enabled: computed(() => popoverOpen.value && shouldLoadPlatforms.value),
|
enabled: shouldLoadRecords,
|
||||||
queryFn: () => articlesApi.publishRecords(props.articleId as number),
|
queryFn: () => articlesApi.publishRecords(props.articleId as number),
|
||||||
|
staleTime: 30 * 1000,
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasPopover = computed(() => shouldLoadPlatforms.value);
|
const hasPopover = computed(() => props.showPlatforms && shouldLoadRecords.value);
|
||||||
|
|
||||||
const platformMap = computed(() => {
|
const platformMap = computed(() => {
|
||||||
return new Map(
|
return new Map(
|
||||||
@@ -108,6 +110,10 @@ const pendingEntries = computed(() =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
const displayStatus = computed(() => {
|
const displayStatus = computed(() => {
|
||||||
|
if (successEntries.value.length > 0 && failedEntries.value.length > 0) {
|
||||||
|
return "partial_success";
|
||||||
|
}
|
||||||
|
|
||||||
if (failedEntries.value.length > 0) {
|
if (failedEntries.value.length > 0) {
|
||||||
return "failed";
|
return "failed";
|
||||||
}
|
}
|
||||||
@@ -121,7 +127,7 @@ const displayStatus = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (props.status === "partial_success") {
|
if (props.status === "partial_success") {
|
||||||
return "failed";
|
return "partial_success";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.status === "publish_success" || props.status === "published") {
|
if (props.status === "publish_success" || props.status === "published") {
|
||||||
@@ -149,6 +155,8 @@ const statusTone = computed(() => {
|
|||||||
return "failed";
|
return "failed";
|
||||||
case "publishing":
|
case "publishing":
|
||||||
return "processing";
|
return "processing";
|
||||||
|
case "partial_success":
|
||||||
|
return "warning";
|
||||||
default:
|
default:
|
||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ const enUS = {
|
|||||||
publishing: "Publishing",
|
publishing: "Publishing",
|
||||||
success: "Published",
|
success: "Published",
|
||||||
failed: "Failed",
|
failed: "Failed",
|
||||||
partial_success: "Partial Success",
|
partial_success: "Partially Published",
|
||||||
published: "Published",
|
published: "Published",
|
||||||
publish_success: "Published",
|
publish_success: "Published",
|
||||||
publish_failed: "Failed",
|
publish_failed: "Failed",
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ const zhCN = {
|
|||||||
publishing: "发布中",
|
publishing: "发布中",
|
||||||
success: "发布成功",
|
success: "发布成功",
|
||||||
failed: "发布失败",
|
failed: "发布失败",
|
||||||
partial_success: "部分成功",
|
partial_success: "部分发布",
|
||||||
published: "发布成功",
|
published: "发布成功",
|
||||||
publish_success: "发布成功",
|
publish_success: "发布成功",
|
||||||
publish_failed: "发布失败",
|
publish_failed: "发布失败",
|
||||||
|
|||||||
Reference in New Issue
Block a user