fix publish record deletion
Desktop Client Build / Resolve Build Metadata (push) Successful in 26s
Frontend CI / Frontend (push) Successful in 2m47s
Backend CI / Backend (push) Failing after 10m1s
Desktop Client Build / Build Desktop Client (push) Successful in 23m3s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 29s

This commit is contained in:
2026-06-26 21:04:38 +08:00
parent 6780963c28
commit 04769dec78
12 changed files with 259 additions and 53 deletions
+1
View File
@@ -133,6 +133,7 @@ declare global {
): Promise<DesktopPublishTaskListResponse>
retryPublishTask(taskId: string): Promise<CreatePublishJobResponse>
cancelPublishTask(taskId: string): Promise<DesktopTaskInfo>
deletePublishRecord(recordId: number): Promise<{ deleted: boolean }>
openExternalUrl(url: string): Promise<null>
openSettingsWindow(): Promise<null>
getAppSettings(): Promise<DesktopAppSettings>
@@ -2,6 +2,7 @@
import {
ClockCircleOutlined,
CopyOutlined,
DeleteOutlined,
DesktopOutlined,
ExportOutlined,
ReloadOutlined,
@@ -36,6 +37,7 @@ const publishPlatformIndex: Record<string, (typeof desktopPublishMediaCatalog)[n
interface PublishTaskItem {
id: string
publishRecordId: number | null
title: string
articleId: number | null
platform: string
@@ -397,6 +399,7 @@ const consolePendingTaskId = ref<string | null>(null)
const copiedErrorTaskId = ref<string | null>(null)
const retryingTaskId = ref<string | null>(null)
const cancelingTaskId = ref<string | null>(null)
const deletingTaskId = ref<string | null>(null)
function notifySuccess(message: string) {
notification.success({
@@ -629,6 +632,30 @@ async function cancelTask(record: PublishTaskItem) {
}
}
async function deleteRecord(record: PublishTaskItem) {
if (!record.publishRecordId) {
return
}
deletingTaskId.value = record.id
try {
await window.desktopBridge.app.deletePublishRecord(record.publishRecordId)
notifySuccess('发文记录已删除')
await refreshTasks(currentPage.value)
} catch (err) {
notifyActionError(
normalizeTaskErrorMessage(unwrapClientErrorMessage(err, '删除发文记录失败')) ??
'删除发文记录失败',
)
} finally {
deletingTaskId.value = null
}
}
function canDeleteRecord(record: PublishTaskItem): boolean {
return record.publishRecordId !== null
}
async function copyTextToClipboard(text: string): Promise<void> {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text)
@@ -741,6 +768,7 @@ const publishTasks = computed<PublishTaskItem[]>(() =>
const articleId =
extractNumber(payload.article_id) ??
extractNumber(nestedContentRef?.article_id ?? nestedContentRef?.id)
const publishRecordId = extractNumber(payload.publish_record_id)
const pendingTasks =
taskPage.value?.items.filter((item) =>
isPendingStatus(normalizePublishTaskStatus(item.status)),
@@ -782,6 +810,7 @@ const publishTasks = computed<PublishTaskItem[]>(() =>
return {
id: task.id,
publishRecordId,
title: extractString(payload.title) ?? `发布任务 · ${translatePlatform(task.platform)}`,
articleId,
platform: task.platform,
@@ -1096,6 +1125,26 @@ const tableScroll = { x: 1080 } as const
<ClockCircleOutlined />
</div>
</a-tooltip>
<a-popconfirm
v-if="canDeleteRecord(record)"
title="确认删除这条发文记录?删除后后台和客户端发文管理都不再显示。"
ok-text="删除"
cancel-text="保留"
placement="topRight"
@confirm="deleteRecord(record)"
>
<a-tooltip title="删除发文记录" placement="top">
<a-button
type="text"
class="icon-action-btn icon-action-btn--danger"
:loading="deletingTaskId === record.id"
:aria-label="`删除发文记录:${record.title}`"
@click.stop
>
<template #icon><DeleteOutlined /></template>
</a-button>
</a-tooltip>
</a-popconfirm>
</div>
</template>
</template>