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
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:
@@ -2,6 +2,7 @@
|
||||
import {
|
||||
ClockCircleOutlined,
|
||||
CopyOutlined,
|
||||
DeleteOutlined,
|
||||
DesktopOutlined,
|
||||
ExportOutlined,
|
||||
ReloadOutlined,
|
||||
@@ -193,6 +194,7 @@ const appliedTitle = ref('')
|
||||
const copiedErrorTaskId = ref<string | null>(null)
|
||||
const retryingTaskId = ref<string | null>(null)
|
||||
const cancelingTaskId = ref<string | null>(null)
|
||||
const deletingRecordId = ref<string | null>(null)
|
||||
const manualRefreshing = ref(false)
|
||||
|
||||
const recordsQuery = useQuery({
|
||||
@@ -370,6 +372,19 @@ async function cancelTask(record: PublishRecordItem): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteRecord(record: PublishRecordItem): Promise<void> {
|
||||
deletingRecordId.value = record.id
|
||||
try {
|
||||
await publishRecordsApi.remove(record.recordId)
|
||||
message.success('发文记录已删除')
|
||||
await recordsQuery.refetch()
|
||||
} catch (error) {
|
||||
message.error(formatError(error))
|
||||
} finally {
|
||||
deletingRecordId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function copyErrorMessage(record: PublishRecordItem): Promise<void> {
|
||||
if (!record.errorMessage) {
|
||||
return
|
||||
@@ -622,6 +637,25 @@ async function copyErrorMessage(record: PublishRecordItem): Promise<void> {
|
||||
<ClockCircleOutlined />
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<a-popconfirm
|
||||
title="确认删除这条发文记录?删除后后台和客户端发文管理都不再显示。"
|
||||
ok-text="删除"
|
||||
cancel-text="保留"
|
||||
placement="topRight"
|
||||
@confirm="deleteRecord(record)"
|
||||
>
|
||||
<a-tooltip title="删除发文记录" placement="top">
|
||||
<a-button
|
||||
type="text"
|
||||
class="publish-action-btn publish-action-btn--danger"
|
||||
:loading="deletingRecordId === record.id"
|
||||
:aria-label="`删除发文记录:${record.title}`"
|
||||
@click.stop
|
||||
>
|
||||
<template #icon><DeleteOutlined /></template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</a-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -78,6 +78,7 @@ import {
|
||||
import {
|
||||
cancelDesktopTask,
|
||||
checkDesktopClientRelease,
|
||||
deleteDesktopPublishRecord,
|
||||
initTransport,
|
||||
listDesktopPublishTasks,
|
||||
resolveDesktopClientReleaseDownloadURL,
|
||||
@@ -1246,6 +1247,9 @@ function registerBridgeHandlers(): void {
|
||||
safeHandle('desktop:cancel-publish-task', async (_event, taskId: string) => {
|
||||
return cancelDesktopTask(taskId, { reason: 'user_cancelled_publish' })
|
||||
})
|
||||
safeHandle('desktop:delete-publish-record', async (_event, recordId: number) => {
|
||||
return deleteDesktopPublishRecord(recordId)
|
||||
})
|
||||
safeHandle('desktop:open-external-url', async (_event, url: string) => {
|
||||
if (!isSafeExternalUrl(url)) {
|
||||
throw new Error('unsupported_external_url')
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
CancelDesktopTaskRequest,
|
||||
CompleteDesktopTaskRequest,
|
||||
CreatePublishJobResponse,
|
||||
DeletePublishRecordResponse,
|
||||
DesktopAccountInfo,
|
||||
DesktopArticleContent,
|
||||
DesktopClientHeartbeatRequest,
|
||||
@@ -678,6 +679,14 @@ export async function retryDesktopPublishTask(taskId: string): Promise<CreatePub
|
||||
)
|
||||
}
|
||||
|
||||
export async function deleteDesktopPublishRecord(
|
||||
recordId: number,
|
||||
): Promise<DeletePublishRecordResponse> {
|
||||
return desktopDelete<DeletePublishRecordResponse>(
|
||||
`/api/desktop/publish-records/${encodeURIComponent(String(recordId))}`,
|
||||
)
|
||||
}
|
||||
|
||||
export async function upsertDesktopAccount(
|
||||
payload: UpsertDesktopAccountRequest,
|
||||
): Promise<DesktopAccountInfo> {
|
||||
|
||||
@@ -226,6 +226,10 @@ const desktopBridge = {
|
||||
ipcRenderer.invoke('desktop:retry-publish-task', taskId) as Promise<CreatePublishJobResponse>,
|
||||
cancelPublishTask: (taskId: string) =>
|
||||
ipcRenderer.invoke('desktop:cancel-publish-task', taskId) as Promise<DesktopTaskInfo>,
|
||||
deletePublishRecord: (recordId: number) =>
|
||||
ipcRenderer.invoke('desktop:delete-publish-record', recordId) as Promise<{
|
||||
deleted: boolean
|
||||
}>,
|
||||
openExternalUrl: (url: string) =>
|
||||
ipcRenderer.invoke('desktop:open-external-url', url) as Promise<null>,
|
||||
openSettingsWindow: () => ipcRenderer.invoke('desktop:open-settings-window') as Promise<null>,
|
||||
|
||||
+1
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user