feat: 增加通知 outbox 重发入口
This commit is contained in:
@@ -424,6 +424,14 @@ export const devopsApi = {
|
||||
return Array.isArray(data) ? data.map(sanitizeNotificationOutboxMessage) : []
|
||||
},
|
||||
|
||||
async retryNotificationOutboxMessage(id: string): Promise<NotificationOutboxMessage> {
|
||||
const { data } = await http.post<NotificationOutboxMessage>(
|
||||
`/notification-outbox/${id}/retry`,
|
||||
)
|
||||
lastDataSource = 'backend'
|
||||
return sanitizeNotificationOutboxMessage(data)
|
||||
},
|
||||
|
||||
async getAgentCards(): Promise<AgentCard[]> {
|
||||
return agentCards
|
||||
},
|
||||
|
||||
@@ -135,6 +135,16 @@ export const usePlatformStore = defineStore('platform', () => {
|
||||
return notificationOutbox.value
|
||||
}
|
||||
|
||||
async function retryNotificationOutboxMessage(id: string) {
|
||||
const message = await devopsApi.retryNotificationOutboxMessage(id)
|
||||
notificationOutbox.value = [
|
||||
message,
|
||||
...notificationOutbox.value.filter((item) => item.id !== message.id),
|
||||
]
|
||||
dataSource.value = devopsApi.getLastDataSource()
|
||||
return message
|
||||
}
|
||||
|
||||
function upsertRun(run: ReleaseRun) {
|
||||
runs.value = [run, ...runs.value.filter((item) => item.id !== run.id)]
|
||||
}
|
||||
@@ -163,5 +173,6 @@ export const usePlatformStore = defineStore('platform', () => {
|
||||
loadProjectRefs,
|
||||
loadAuditLogs,
|
||||
loadNotificationOutbox,
|
||||
retryNotificationOutboxMessage,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -23,6 +23,7 @@ const session = useSessionStore()
|
||||
const agentConfigLoading = ref(false)
|
||||
const agentConfigTesting = ref(false)
|
||||
const agentConfig = ref<AgentConfigSummary | null>(null)
|
||||
const retryingOutboxIds = ref<Set<string>>(new Set())
|
||||
const agentConfigForm = reactive({
|
||||
key: '',
|
||||
baseURL: '',
|
||||
@@ -135,6 +136,26 @@ function outboxStatusType(
|
||||
return outboxStatusMeta[status]?.type ?? 'info'
|
||||
}
|
||||
|
||||
function canRetryOutbox(record: NotificationOutboxMessage): boolean {
|
||||
return record.status === 'failed' || record.status === 'dead'
|
||||
}
|
||||
|
||||
function isRetryingOutbox(id: string): boolean {
|
||||
return retryingOutboxIds.value.has(id)
|
||||
}
|
||||
|
||||
function setRetryingOutbox(id: string, loading: boolean) {
|
||||
const nextIds = new Set(retryingOutboxIds.value)
|
||||
|
||||
if (loading) {
|
||||
nextIds.add(id)
|
||||
} else {
|
||||
nextIds.delete(id)
|
||||
}
|
||||
|
||||
retryingOutboxIds.value = nextIds
|
||||
}
|
||||
|
||||
function variableGroups(item: IntegrationConfigItem): VariableGroup[] {
|
||||
return [
|
||||
{
|
||||
@@ -246,6 +267,20 @@ async function refreshNotificationOutbox() {
|
||||
}
|
||||
}
|
||||
|
||||
async function retryNotificationOutbox(record: NotificationOutboxMessage) {
|
||||
setRetryingOutbox(record.id, true)
|
||||
|
||||
try {
|
||||
await platform.retryNotificationOutboxMessage(record.id)
|
||||
await platform.loadAuditLogs()
|
||||
ElMessage.success('通知 outbox 已提交重发')
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '通知 outbox 重发失败')
|
||||
} finally {
|
||||
setRetryingOutbox(record.id, false)
|
||||
}
|
||||
}
|
||||
|
||||
function applyAgentConfig(config: AgentConfigSummary) {
|
||||
agentConfig.value = config
|
||||
agentConfigForm.baseURL = config.baseURL
|
||||
@@ -469,6 +504,21 @@ function applyAgentConfig(config: AgentConfigSummary) {
|
||||
<AuditJsonCell :value="outboxPayload(row)" />
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作" min-width="100" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
v-if="canRetryOutbox(row)"
|
||||
:icon="Refresh"
|
||||
link
|
||||
type="primary"
|
||||
:loading="isRetryingOutbox(row.id)"
|
||||
@click="retryNotificationOutbox(row)"
|
||||
>
|
||||
重发
|
||||
</ElButton>
|
||||
<span v-else class="table-empty">-</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<ElEmpty
|
||||
v-if="platform.notificationOutbox.length === 0"
|
||||
@@ -707,6 +757,11 @@ function applyAgentConfig(config: AgentConfigSummary) {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.table-empty {
|
||||
color: #9aa4b2;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) {
|
||||
.variable-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
|
||||
Reference in New Issue
Block a user