feat: 增加通知 outbox 重发入口
This commit is contained in:
@@ -424,6 +424,14 @@ export const devopsApi = {
|
|||||||
return Array.isArray(data) ? data.map(sanitizeNotificationOutboxMessage) : []
|
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[]> {
|
async getAgentCards(): Promise<AgentCard[]> {
|
||||||
return agentCards
|
return agentCards
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -135,6 +135,16 @@ export const usePlatformStore = defineStore('platform', () => {
|
|||||||
return notificationOutbox.value
|
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) {
|
function upsertRun(run: ReleaseRun) {
|
||||||
runs.value = [run, ...runs.value.filter((item) => item.id !== run.id)]
|
runs.value = [run, ...runs.value.filter((item) => item.id !== run.id)]
|
||||||
}
|
}
|
||||||
@@ -163,5 +173,6 @@ export const usePlatformStore = defineStore('platform', () => {
|
|||||||
loadProjectRefs,
|
loadProjectRefs,
|
||||||
loadAuditLogs,
|
loadAuditLogs,
|
||||||
loadNotificationOutbox,
|
loadNotificationOutbox,
|
||||||
|
retryNotificationOutboxMessage,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const session = useSessionStore()
|
|||||||
const agentConfigLoading = ref(false)
|
const agentConfigLoading = ref(false)
|
||||||
const agentConfigTesting = ref(false)
|
const agentConfigTesting = ref(false)
|
||||||
const agentConfig = ref<AgentConfigSummary | null>(null)
|
const agentConfig = ref<AgentConfigSummary | null>(null)
|
||||||
|
const retryingOutboxIds = ref<Set<string>>(new Set())
|
||||||
const agentConfigForm = reactive({
|
const agentConfigForm = reactive({
|
||||||
key: '',
|
key: '',
|
||||||
baseURL: '',
|
baseURL: '',
|
||||||
@@ -135,6 +136,26 @@ function outboxStatusType(
|
|||||||
return outboxStatusMeta[status]?.type ?? 'info'
|
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[] {
|
function variableGroups(item: IntegrationConfigItem): VariableGroup[] {
|
||||||
return [
|
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) {
|
function applyAgentConfig(config: AgentConfigSummary) {
|
||||||
agentConfig.value = config
|
agentConfig.value = config
|
||||||
agentConfigForm.baseURL = config.baseURL
|
agentConfigForm.baseURL = config.baseURL
|
||||||
@@ -469,6 +504,21 @@ function applyAgentConfig(config: AgentConfigSummary) {
|
|||||||
<AuditJsonCell :value="outboxPayload(row)" />
|
<AuditJsonCell :value="outboxPayload(row)" />
|
||||||
</template>
|
</template>
|
||||||
</ElTableColumn>
|
</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>
|
</ElTable>
|
||||||
<ElEmpty
|
<ElEmpty
|
||||||
v-if="platform.notificationOutbox.length === 0"
|
v-if="platform.notificationOutbox.length === 0"
|
||||||
@@ -707,6 +757,11 @@ function applyAgentConfig(config: AgentConfigSummary) {
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table-empty {
|
||||||
|
color: #9aa4b2;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 1080px) {
|
@media (max-width: 1080px) {
|
||||||
.variable-grid {
|
.variable-grid {
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
|||||||
Reference in New Issue
Block a user