feat: 完善发布运维前端体验
This commit is contained in:
@@ -7,7 +7,6 @@ import type { JenkinsBuildLog, PipelineStep, ReleaseRun, StepStatus } from '../t
|
||||
import StatusPill from './StatusPill.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
xml: string
|
||||
steps: PipelineStep[]
|
||||
run?: ReleaseRun
|
||||
}>()
|
||||
@@ -22,7 +21,7 @@ type StatusMeta = {
|
||||
type OutputMode = 'step' | 'jenkins'
|
||||
const maxRenderedLogLines = 520
|
||||
|
||||
const selectedNodeId = ref('')
|
||||
const selectedStepNodeId = ref('')
|
||||
const terminalOutputEl = ref<HTMLElement>()
|
||||
const outputMode = ref<OutputMode>('step')
|
||||
const logLoading = ref(false)
|
||||
@@ -104,11 +103,11 @@ const currentStep = computed(() => {
|
||||
})
|
||||
|
||||
const selectedStep = computed(() => {
|
||||
if (!selectedNodeId.value) {
|
||||
if (!selectedStepNodeId.value) {
|
||||
return currentStep.value
|
||||
}
|
||||
|
||||
return findStep(selectedNodeId.value) ?? currentStep.value
|
||||
return findStep(selectedStepNodeId.value) ?? currentStep.value
|
||||
})
|
||||
|
||||
const stepStats = computed(() => {
|
||||
@@ -140,8 +139,6 @@ const isActiveRun = computed(
|
||||
() => props.run?.status === 'queued' || props.run?.status === 'running',
|
||||
)
|
||||
|
||||
const processSourceText = computed(() => (props.xml ? 'BPMN XML 已加载' : '等待 BPMN XML'))
|
||||
|
||||
const terminalTitle = computed(() => {
|
||||
if (outputMode.value === 'jenkins') {
|
||||
return hasJenkinsBuildNumber.value
|
||||
@@ -160,14 +157,14 @@ const terminalSubtitle = computed(() => {
|
||||
|
||||
const buildText = hasJenkinsBuildNumber.value ? `Build #${props.run?.jenkinsBuildNumber}` : ''
|
||||
const queueText = props.run?.jenkinsQueueId ? `Queue ${props.run.jenkinsQueueId}` : ''
|
||||
return [buildText, queueText, processSourceText.value].filter(Boolean).join(' · ')
|
||||
return [buildText, queueText].filter(Boolean).join(' · ') || '等待 Jenkins 日志来源'
|
||||
}
|
||||
|
||||
if (!selectedStep.value) {
|
||||
return processSourceText.value
|
||||
return '等待后端步骤'
|
||||
}
|
||||
|
||||
return `${selectedStep.value.owner} · ${selectedStep.value.bpmnNodeId}`
|
||||
return `${selectedStep.value.owner} · 节点 ${selectedStep.value.nodeId}`
|
||||
})
|
||||
|
||||
const logRefreshStateText = computed(() => {
|
||||
@@ -193,7 +190,7 @@ const stepOutputText = computed(() => {
|
||||
`# ${step.name}`,
|
||||
`owner=${step.owner}`,
|
||||
`status=${statusMeta[step.status].label}`,
|
||||
`bpmnNodeId=${step.bpmnNodeId}`,
|
||||
`nodeId=${step.nodeId}`,
|
||||
`duration=${step.duration}`,
|
||||
step.startedAt ? `startedAt=${step.startedAt}` : '',
|
||||
step.finishedAt ? `finishedAt=${step.finishedAt}` : '',
|
||||
@@ -238,7 +235,7 @@ const terminalEmptyHint = computed(() => {
|
||||
})
|
||||
|
||||
function findStep(nodeId: string) {
|
||||
return props.steps.find((step) => step.bpmnNodeId === nodeId)
|
||||
return props.steps.find((step) => step.nodeId === nodeId)
|
||||
}
|
||||
|
||||
function statusClass(status: StepStatus): string {
|
||||
@@ -246,11 +243,11 @@ function statusClass(status: StepStatus): string {
|
||||
}
|
||||
|
||||
function isSelectedStep(step: PipelineStep): boolean {
|
||||
return selectedStep.value?.bpmnNodeId === step.bpmnNodeId
|
||||
return selectedStep.value?.nodeId === step.nodeId
|
||||
}
|
||||
|
||||
function selectStep(step: PipelineStep) {
|
||||
selectedNodeId.value = step.bpmnNodeId
|
||||
selectedStepNodeId.value = step.nodeId
|
||||
|
||||
if (step.owner === 'Jenkins') {
|
||||
outputMode.value = 'jenkins'
|
||||
@@ -401,7 +398,7 @@ watch(
|
||||
watch(
|
||||
() => `${props.run?.id ?? 'none'}:${currentStep.value?.id ?? 'none'}:${currentStep.value?.status ?? 'none'}`,
|
||||
() => {
|
||||
if (selectedNodeId.value || currentStep.value?.owner !== 'Jenkins') {
|
||||
if (selectedStepNodeId.value || currentStep.value?.owner !== 'Jenkins') {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -430,7 +427,7 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="bpmn-viewer">
|
||||
<div class="pipeline-viewer">
|
||||
<section class="execution-output">
|
||||
<div class="execution-toolbar">
|
||||
<div>
|
||||
@@ -484,7 +481,7 @@ onBeforeUnmount(() => {
|
||||
<div v-if="logError && outputMode === 'jenkins'" class="log-error">{{ logError }}</div>
|
||||
</section>
|
||||
|
||||
<aside class="bpmn-side">
|
||||
<aside class="pipeline-side">
|
||||
<div class="flow-stats">
|
||||
<div>
|
||||
<small>流程进度</small>
|
||||
@@ -535,7 +532,7 @@ onBeforeUnmount(() => {
|
||||
<div class="node-detail-head">
|
||||
<span>
|
||||
<strong>{{ selectedStep.name }}</strong>
|
||||
<small>{{ selectedStep.owner }} · {{ selectedStep.bpmnNodeId }}</small>
|
||||
<small>{{ selectedStep.owner }} · 节点 {{ selectedStep.nodeId }}</small>
|
||||
</span>
|
||||
<StatusPill :state="selectedStep.status" />
|
||||
</div>
|
||||
@@ -563,7 +560,7 @@ onBeforeUnmount(() => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.bpmn-viewer {
|
||||
.pipeline-viewer {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 330px;
|
||||
gap: 16px;
|
||||
@@ -712,7 +709,7 @@ onBeforeUnmount(() => {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.bpmn-side {
|
||||
.pipeline-side {
|
||||
position: sticky;
|
||||
top: 86px;
|
||||
display: flex;
|
||||
@@ -972,7 +969,7 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.bpmn-viewer {
|
||||
.pipeline-viewer {
|
||||
grid-template-columns: 1fr;
|
||||
height: auto;
|
||||
}
|
||||
@@ -989,7 +986,7 @@ onBeforeUnmount(() => {
|
||||
height: min(520px, 70vh);
|
||||
}
|
||||
|
||||
.bpmn-side {
|
||||
.pipeline-side {
|
||||
position: static;
|
||||
height: auto;
|
||||
max-height: none;
|
||||
+73
-2
@@ -1,8 +1,79 @@
|
||||
import { createApp } from 'vue'
|
||||
import './style.css'
|
||||
import App from './App.vue'
|
||||
import ElementPlus from 'element-plus'
|
||||
import {
|
||||
ElAlert,
|
||||
ElAside,
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElContainer,
|
||||
ElDialog,
|
||||
ElDrawer,
|
||||
ElDropdown,
|
||||
ElDropdownItem,
|
||||
ElDropdownMenu,
|
||||
ElEmpty,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElHeader,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElLink,
|
||||
ElLoading,
|
||||
ElMain,
|
||||
ElMenu,
|
||||
ElMenuItem,
|
||||
ElOption,
|
||||
ElRadio,
|
||||
ElRadioButton,
|
||||
ElRadioGroup,
|
||||
ElSegmented,
|
||||
ElSelect,
|
||||
ElSwitch,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElTooltip,
|
||||
} from 'element-plus'
|
||||
import { createPinia } from 'pinia'
|
||||
import router from './router'
|
||||
|
||||
createApp(App).use(createPinia()).use(router).use(ElementPlus).mount('#app')
|
||||
const app = createApp(App)
|
||||
|
||||
for (const component of [
|
||||
ElAlert,
|
||||
ElAside,
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElContainer,
|
||||
ElDialog,
|
||||
ElDrawer,
|
||||
ElDropdown,
|
||||
ElDropdownItem,
|
||||
ElDropdownMenu,
|
||||
ElEmpty,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElHeader,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElLink,
|
||||
ElMain,
|
||||
ElMenu,
|
||||
ElMenuItem,
|
||||
ElOption,
|
||||
ElRadio,
|
||||
ElRadioButton,
|
||||
ElRadioGroup,
|
||||
ElSegmented,
|
||||
ElSelect,
|
||||
ElSwitch,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElTooltip,
|
||||
]) {
|
||||
app.use(component)
|
||||
}
|
||||
|
||||
app.use(ElLoading).use(createPinia()).use(router).mount('#app')
|
||||
|
||||
+12
-8
@@ -1,13 +1,14 @@
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||||
import { useSessionStore } from '../stores/session'
|
||||
import MainLayout from '../layouts/MainLayout.vue'
|
||||
import LoginView from '../views/LoginView.vue'
|
||||
import OverviewView from '../views/OverviewView.vue'
|
||||
import ProjectsView from '../views/ProjectsView.vue'
|
||||
import MembersView from '../views/MembersView.vue'
|
||||
import ReleaseCenterView from '../views/ReleaseCenterView.vue'
|
||||
import RunsView from '../views/RunsView.vue'
|
||||
import SettingsView from '../views/SettingsView.vue'
|
||||
|
||||
const MainLayout = () => import('../layouts/MainLayout.vue')
|
||||
const LoginView = () => import('../views/LoginView.vue')
|
||||
const OverviewView = () => import('../views/OverviewView.vue')
|
||||
const ProjectsView = () => import('../views/ProjectsView.vue')
|
||||
const MembersView = () => import('../views/MembersView.vue')
|
||||
const ReleaseCenterView = () => import('../views/ReleaseCenterView.vue')
|
||||
const RunsView = () => import('../views/RunsView.vue')
|
||||
const SettingsView = () => import('../views/SettingsView.vue')
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
@@ -59,6 +60,9 @@ const routes: RouteRecordRaw[] = [
|
||||
path: 'settings',
|
||||
name: 'settings',
|
||||
component: SettingsView,
|
||||
meta: {
|
||||
superAdminOnly: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
+12
-26
@@ -91,6 +91,7 @@ interface BackendProject {
|
||||
|
||||
interface BackendDeployRunStep {
|
||||
id?: string
|
||||
nodeId?: string
|
||||
bpmnNodeId?: string
|
||||
name?: string
|
||||
status?: BackendRunStatus
|
||||
@@ -151,13 +152,6 @@ interface BackendJenkinsImportSummary {
|
||||
}>
|
||||
}
|
||||
|
||||
interface BackendProcessDefinition {
|
||||
key: 'release'
|
||||
version: string
|
||||
xml: string
|
||||
nodeIds: string[]
|
||||
}
|
||||
|
||||
interface BackendIntegrationConfigItem {
|
||||
key: IntegrationConfigKey
|
||||
name: string
|
||||
@@ -231,7 +225,7 @@ const agentCards: AgentCard[] = [
|
||||
mode: 'incidentReview',
|
||||
title: '事故复盘草稿',
|
||||
description: '基于失败 run、流程耗时、Jenkins 摘要和 Runbook 生成复盘草稿。',
|
||||
inputScope: ['失败 run', 'BPMN 节点', '脱敏日志片段', 'Runbook'],
|
||||
inputScope: ['失败 run', '失败节点', '脱敏日志片段', 'Runbook'],
|
||||
outputPreview: ['时间线', '根因假设', '修复和预防项'],
|
||||
},
|
||||
]
|
||||
@@ -246,12 +240,12 @@ const settings: SystemSetting[] = [
|
||||
boundary: '前端不写死真实 token,不直接访问 Jenkins/Gitea/LLM。',
|
||||
},
|
||||
{
|
||||
key: 'bpmn',
|
||||
name: 'BPMN 流程定义',
|
||||
key: 'pipeline',
|
||||
name: '发布步骤流转',
|
||||
status: 'healthy',
|
||||
owner: '平台流程配置',
|
||||
contract: 'step.bpmnNodeId 必须和 BPMN XML 节点 id 一致。',
|
||||
boundary: '前端只展示流程和状态,不推进状态机。',
|
||||
owner: '后端发布状态机',
|
||||
contract: 'run.steps 由后端返回,前端只按节点顺序展示状态、耗时和日志摘要。',
|
||||
boundary: '前端只展示步骤和日志,不推进状态机。',
|
||||
},
|
||||
{
|
||||
key: 'agent',
|
||||
@@ -539,14 +533,6 @@ export const devopsApi = {
|
||||
return data
|
||||
},
|
||||
|
||||
async getReleaseProcessXml(): Promise<string> {
|
||||
const { data } = await http.get<BackendProcessDefinition>(
|
||||
'/process-definitions/release',
|
||||
)
|
||||
lastDataSource = 'backend'
|
||||
return data.xml
|
||||
},
|
||||
|
||||
async createAgentInvocation(
|
||||
payload: CreateAgentInvocationPayload,
|
||||
): Promise<AgentInvocation> {
|
||||
@@ -1153,14 +1139,14 @@ function sanitizeNotificationOutboxMessage(
|
||||
}
|
||||
|
||||
function toPipelineStep(step: BackendDeployRunStep): PipelineStep {
|
||||
const bpmnNodeId = step.bpmnNodeId || step.id || 'unknown-step'
|
||||
const name = step.name || bpmnNodeId
|
||||
const nodeId = step.nodeId || step.bpmnNodeId || step.id || 'unknown-step'
|
||||
const name = step.name || nodeId
|
||||
|
||||
return {
|
||||
id: step.id || bpmnNodeId,
|
||||
bpmnNodeId,
|
||||
id: step.id || nodeId,
|
||||
nodeId,
|
||||
name,
|
||||
owner: stepOwner(bpmnNodeId),
|
||||
owner: stepOwner(nodeId),
|
||||
status: toStepStatus(step.status),
|
||||
duration: formatDuration(step.startedAt, step.finishedAt, step.status),
|
||||
summary: step.errorSummary || step.message || name,
|
||||
|
||||
@@ -46,7 +46,6 @@ export const usePlatformStore = defineStore('platform', () => {
|
||||
checkedAt: '',
|
||||
integrations: [],
|
||||
})
|
||||
const releaseProcessXml = ref('')
|
||||
const projectRefs = ref<Record<string, ProjectRefs>>({})
|
||||
|
||||
const failedRuns = computed(() => runs.value.filter((run) => run.status === 'failed'))
|
||||
@@ -83,19 +82,16 @@ export const usePlatformStore = defineStore('platform', () => {
|
||||
agentCards.value = summary.agentCards
|
||||
settings.value = summary.settings
|
||||
integrationConfig.value = summary.integrationConfig
|
||||
const processXmlPromise = devopsApi.getReleaseProcessXml()
|
||||
const auditLogsPromise = includeAdminData
|
||||
? devopsApi.getAuditLogs()
|
||||
: Promise.resolve<AuditLogEntry[]>([])
|
||||
const notificationOutboxPromise = includeAdminData
|
||||
? devopsApi.getNotificationOutbox()
|
||||
: Promise.resolve<NotificationOutboxMessage[]>([])
|
||||
const [processXml, recentAuditLogs, recentNotificationOutbox] = await Promise.all([
|
||||
processXmlPromise,
|
||||
const [recentAuditLogs, recentNotificationOutbox] = await Promise.all([
|
||||
auditLogsPromise,
|
||||
notificationOutboxPromise,
|
||||
])
|
||||
releaseProcessXml.value = processXml
|
||||
auditLogs.value = recentAuditLogs
|
||||
notificationOutbox.value = recentNotificationOutbox
|
||||
applyProjectGiteaDiagnostics()
|
||||
@@ -358,7 +354,6 @@ export const usePlatformStore = defineStore('platform', () => {
|
||||
projectJenkinsDiagnostics,
|
||||
projectGiteaDiagnostics,
|
||||
integrationConfig,
|
||||
releaseProcessXml,
|
||||
projectRefs,
|
||||
failedRuns,
|
||||
runningRuns,
|
||||
|
||||
+1
-1
@@ -353,7 +353,7 @@ export interface ProjectRefItem {
|
||||
|
||||
export interface PipelineStep {
|
||||
id: string
|
||||
bpmnNodeId: string
|
||||
nodeId: string
|
||||
name: string
|
||||
owner: 'Gitea' | 'Jenkins' | 'HealthCheck' | 'Notification' | 'Platform'
|
||||
status: StepStatus
|
||||
|
||||
@@ -273,6 +273,16 @@ async function updatePermissions() {
|
||||
return
|
||||
}
|
||||
|
||||
const buildCount = Object.values(editPermissions).filter((level) => level === 'build').length
|
||||
const confirmed = await confirmMemberAction(
|
||||
'确认保存项目权限',
|
||||
`将保存 ${member.displayName} 的项目权限,其中 ${buildCount} 个项目具备构建权限。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
const updated = await devopsApi.updateMemberPermissions(member.id, {
|
||||
permissions: toPermissionPayload(editPermissions),
|
||||
})
|
||||
@@ -313,6 +323,16 @@ async function showTemporaryPassword(
|
||||
|
||||
async function toggleStatus(member: MemberSummary) {
|
||||
const nextStatus = member.status === 'active' ? 'disabled' : 'active'
|
||||
const actionText = nextStatus === 'active' ? '启用' : '禁用'
|
||||
const confirmed = await confirmMemberAction(
|
||||
`${actionText}成员`,
|
||||
`确认${actionText}成员 ${member.displayName}?${nextStatus === 'disabled' ? '禁用后该成员不能继续登录平台。' : ''}`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
const updated = await devopsApi.updateMemberStatus(member.id, {
|
||||
status: nextStatus,
|
||||
})
|
||||
@@ -336,12 +356,35 @@ async function deleteMember(member: MemberSummary) {
|
||||
}
|
||||
|
||||
async function markMessageHandled(message: PlatformMessageSummary) {
|
||||
const confirmed = await confirmMemberAction(
|
||||
'确认处理消息',
|
||||
`将密码重置消息“${message.title}”标记为已处理。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
await devopsApi.markMessageHandled(message.id)
|
||||
await loadMessages()
|
||||
await loadMembers()
|
||||
ElMessage.success('消息已处理')
|
||||
}
|
||||
|
||||
async function confirmMemberAction(title: string, message: string): Promise<boolean> {
|
||||
try {
|
||||
await ElMessageBox.confirm(message, title, {
|
||||
confirmButtonText: '确认执行',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
autofocus: false,
|
||||
})
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMembers() {
|
||||
members.value = await devopsApi.getMembers()
|
||||
}
|
||||
|
||||
+106
-26
@@ -3,10 +3,10 @@
|
||||
* 发布中心负责创建发布单、展示真实 Gitea ref 摘要并同步 Jenkins 状态。
|
||||
*/
|
||||
import { CircleClose, Promotion, RefreshRight, VideoPause } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import BpmnStatusViewer from '../components/BpmnStatusViewer.vue'
|
||||
import PipelineStatusViewer from '../components/PipelineStatusViewer.vue'
|
||||
import RunExecutionDetails from '../components/RunExecutionDetails.vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { isDevopsApiError } from '../services/http'
|
||||
@@ -333,8 +333,16 @@ const preflightSummary = computed(() => {
|
||||
return '关键检查均已通过'
|
||||
})
|
||||
|
||||
const contextRuns = computed(() => {
|
||||
return platform.runs.filter((run) => matchesReleaseContext(run))
|
||||
})
|
||||
|
||||
const shownRun = computed(() => {
|
||||
return activeRun.value || platform.runs[0]
|
||||
if (activeRun.value && matchesReleaseContext(activeRun.value)) {
|
||||
return activeRun.value
|
||||
}
|
||||
|
||||
return contextRuns.value[0]
|
||||
})
|
||||
|
||||
const canSyncJenkins = computed(() => {
|
||||
@@ -357,6 +365,20 @@ const canRetryShownRun = computed(
|
||||
)
|
||||
|
||||
async function triggerRelease() {
|
||||
if (!canTrigger.value) {
|
||||
ElMessage.warning(triggerDisabledReason.value || '发布参数不完整')
|
||||
return
|
||||
}
|
||||
|
||||
const confirmed = await confirmReleaseAction(
|
||||
form.environment === 'production' ? '确认触发生产发布' : '确认触发发布',
|
||||
`即将发布 ${selectedProject.value?.name || form.projectKey} / ${form.environment} / ${form.ref}。提交后会创建后端发布单并进入 Jenkins 执行链路。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const run = await platform.createDeployRun({
|
||||
@@ -444,12 +466,22 @@ async function cancelRelease() {
|
||||
return
|
||||
}
|
||||
|
||||
const run = shownRun.value
|
||||
const confirmed = await confirmReleaseAction(
|
||||
'确认取消发布单',
|
||||
`将取消 ${run.projectName} / ${run.environment} 的发布单 ${run.id}。该操作会写入审计日志。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
const runId = shownRun.value.id
|
||||
const runId = run.id
|
||||
try {
|
||||
const run = await platform.cancelDeployRun(shownRun.value)
|
||||
activeRun.value = run
|
||||
localStatus.value = run.status
|
||||
const canceled = await platform.cancelDeployRun(run)
|
||||
activeRun.value = canceled
|
||||
localStatus.value = canceled.status
|
||||
ElMessage.success('发布单已取消')
|
||||
} catch (error) {
|
||||
await handleReleaseActionError(error, '发布单取消失败', runId)
|
||||
@@ -463,12 +495,22 @@ async function retryRelease() {
|
||||
return
|
||||
}
|
||||
|
||||
const run = shownRun.value
|
||||
const confirmed = await confirmReleaseAction(
|
||||
'确认重试发布单',
|
||||
`将基于 ${run.projectName} / ${run.environment} 的发布单 ${run.id} 发起重试。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
const runId = shownRun.value.id
|
||||
const runId = run.id
|
||||
try {
|
||||
const run = await platform.retryDeployRun(shownRun.value)
|
||||
activeRun.value = run
|
||||
localStatus.value = run.status
|
||||
const retried = await platform.retryDeployRun(run)
|
||||
activeRun.value = retried
|
||||
localStatus.value = retried.status
|
||||
ElMessage.success('已提交重试发布单')
|
||||
} catch (error) {
|
||||
await handleReleaseActionError(error, '发布单重试失败', runId)
|
||||
@@ -482,12 +524,22 @@ async function syncJenkinsRun() {
|
||||
return
|
||||
}
|
||||
|
||||
const run = shownRun.value
|
||||
const confirmed = await confirmReleaseAction(
|
||||
'确认同步 Jenkins 状态',
|
||||
`将从后端同步发布单 ${run.id} 的 Jenkins queue/build 状态。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
const runId = shownRun.value.id
|
||||
const runId = run.id
|
||||
try {
|
||||
const run = await platform.syncJenkinsRun(shownRun.value)
|
||||
activeRun.value = run
|
||||
localStatus.value = run.status
|
||||
const synced = await platform.syncJenkinsRun(run)
|
||||
activeRun.value = synced
|
||||
localStatus.value = synced.status
|
||||
ElMessage.success('已同步 Jenkins 状态')
|
||||
} catch (error) {
|
||||
await handleReleaseActionError(error, 'Jenkins 状态同步失败', runId)
|
||||
@@ -527,6 +579,24 @@ function queryProjectKey(): string {
|
||||
return typeof route.query.projectKey === 'string' ? route.query.projectKey : ''
|
||||
}
|
||||
|
||||
function matchesReleaseContext(run: ReleaseRun): boolean {
|
||||
return run.projectKey === form.projectKey && run.environment === form.environment
|
||||
}
|
||||
|
||||
async function confirmReleaseAction(title: string, message: string): Promise<boolean> {
|
||||
try {
|
||||
await ElMessageBox.confirm(message, title, {
|
||||
confirmButtonText: '确认执行',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
autofocus: false,
|
||||
})
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReleaseActionError(
|
||||
error: unknown,
|
||||
fallbackMessage: string,
|
||||
@@ -536,7 +606,7 @@ async function handleReleaseActionError(
|
||||
const refreshedRuns = await platform.refreshRuns()
|
||||
const refreshedRun = runId
|
||||
? refreshedRuns.find((run) => run.id === runId)
|
||||
: refreshedRuns[0]
|
||||
: refreshedRuns.find((run) => matchesReleaseContext(run))
|
||||
|
||||
if (refreshedRun) {
|
||||
activeRun.value = refreshedRun
|
||||
@@ -805,20 +875,23 @@ watch(
|
||||
<div class="panel-body" v-if="shownRun">
|
||||
<RunExecutionDetails :run="shownRun" />
|
||||
</div>
|
||||
<div v-else class="panel-body release-empty-state">
|
||||
<ElEmpty description="当前项目和环境暂无发布单" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel bpmn-status-panel">
|
||||
<section class="panel pipeline-status-panel">
|
||||
<div class="panel-header">
|
||||
<h2>BPMN 流程状态</h2>
|
||||
<span>step.bpmnNodeId 与 BPMN XML 节点 id 对齐后高亮</span>
|
||||
<h2>发布步骤轨迹</h2>
|
||||
<span>以后端 run steps 为准展示节点状态、输出和 Jenkins 日志</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<BpmnStatusViewer
|
||||
v-if="platform.releaseProcessXml && shownRun"
|
||||
:xml="platform.releaseProcessXml"
|
||||
<PipelineStatusViewer
|
||||
v-if="shownRun"
|
||||
:run="shownRun"
|
||||
:steps="shownRun.steps"
|
||||
/>
|
||||
<ElEmpty v-else description="暂无可查看的发布步骤" />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -835,11 +908,11 @@ watch(
|
||||
|
||||
.release-params-panel,
|
||||
.current-run-panel,
|
||||
.bpmn-status-panel {
|
||||
.pipeline-status-panel {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.bpmn-status-panel {
|
||||
.pipeline-status-panel {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
@@ -858,10 +931,17 @@ watch(
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.bpmn-status-panel .panel-body {
|
||||
.pipeline-status-panel .panel-body {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.release-empty-state {
|
||||
display: flex;
|
||||
min-height: 180px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.current-run-panel :deep(.run-execution-details) {
|
||||
gap: 12px;
|
||||
}
|
||||
@@ -1152,7 +1232,7 @@ watch(
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.bpmn-status-panel {
|
||||
.pipeline-status-panel {
|
||||
grid-column: auto;
|
||||
}
|
||||
|
||||
|
||||
+76
-16
@@ -1,12 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 运行记录页展示历史发布单、Jenkins 同步入口和后端步骤流转图。
|
||||
* 运行记录页展示历史发布单、Jenkins 同步入口和后端步骤轨迹。
|
||||
*/
|
||||
import { CircleClose, Download, RefreshRight, Search } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import BpmnStatusViewer from '../components/BpmnStatusViewer.vue'
|
||||
import PipelineStatusViewer from '../components/PipelineStatusViewer.vue'
|
||||
import RunExecutionDetails from '../components/RunExecutionDetails.vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { isDevopsApiError } from '../services/http'
|
||||
@@ -24,6 +24,7 @@ const session = useSessionStore()
|
||||
const route = useRoute()
|
||||
const selectedRunId = ref(platform.runs[0]?.id || '')
|
||||
const syncingAll = ref(false)
|
||||
const selectedActionSubmitting = ref(false)
|
||||
const importingJenkins = ref(false)
|
||||
const lastJenkinsImportSummary = ref<JenkinsImportSummary | null>(null)
|
||||
const filterProjectKey = ref(queryProjectKey())
|
||||
@@ -213,12 +214,25 @@ async function syncSelectedRun() {
|
||||
return
|
||||
}
|
||||
|
||||
const run = selectedRun.value
|
||||
const confirmed = await confirmRunAction(
|
||||
'确认同步 Jenkins 状态',
|
||||
`将同步发布单 ${run.id} 的 Jenkins queue/build 状态。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
selectedActionSubmitting.value = true
|
||||
try {
|
||||
const run = await platform.syncJenkinsRun(selectedRun.value)
|
||||
selectedRunId.value = run.id
|
||||
const synced = await platform.syncJenkinsRun(run)
|
||||
selectedRunId.value = synced.id
|
||||
ElMessage.success('已同步 Jenkins 状态')
|
||||
} catch (error) {
|
||||
await handleRunActionError(error, 'Jenkins 状态同步失败')
|
||||
} finally {
|
||||
selectedActionSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,16 +241,38 @@ async function retrySelectedRun() {
|
||||
return
|
||||
}
|
||||
|
||||
const run = selectedRun.value
|
||||
const confirmed = await confirmRunAction(
|
||||
'确认重试发布单',
|
||||
`将基于 ${run.projectName} / ${run.environment} 的发布单 ${run.id} 发起重试。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
selectedActionSubmitting.value = true
|
||||
try {
|
||||
const run = await platform.retryDeployRun(selectedRun.value)
|
||||
selectedRunId.value = run.id
|
||||
const retried = await platform.retryDeployRun(run)
|
||||
selectedRunId.value = retried.id
|
||||
ElMessage.success('已提交重试发布单')
|
||||
} catch (error) {
|
||||
await handleRunActionError(error, '发布单重试失败')
|
||||
} finally {
|
||||
selectedActionSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function syncAllJenkinsRuns() {
|
||||
const confirmed = await confirmRunAction(
|
||||
'确认批量同步 Jenkins',
|
||||
'将同步所有当前可同步的 Jenkins run 状态。该操作可能产生多条后端请求和审计记录。',
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
syncingAll.value = true
|
||||
try {
|
||||
const result = await platform.syncJenkinsRuns()
|
||||
@@ -260,6 +296,15 @@ async function syncAllJenkinsRuns() {
|
||||
}
|
||||
|
||||
async function importJenkinsBuilds() {
|
||||
const confirmed = await confirmRunAction(
|
||||
'确认导入 Jenkins 直构',
|
||||
'将扫描已纳管 Jenkins Job 并导入平台外直接触发的构建记录。',
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
importingJenkins.value = true
|
||||
try {
|
||||
const result = await platform.importJenkinsBuilds()
|
||||
@@ -291,6 +336,20 @@ async function importJenkinsBuilds() {
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmRunAction(title: string, message: string): Promise<boolean> {
|
||||
try {
|
||||
await ElMessageBox.confirm(message, title, {
|
||||
confirmButtonText: '确认执行',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
autofocus: false,
|
||||
})
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRunActionError(error: unknown, fallbackMessage: string) {
|
||||
if (isDevopsApiError(error) && error.code === 'CONFLICT') {
|
||||
await platform.refreshRuns()
|
||||
@@ -367,13 +426,13 @@ function skippedReasonLabel(reason: string): string {
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1>运行记录</h1>
|
||||
<p>查看发布 run、Jenkins 构建链接、耗时、失败节点和流程轨迹。</p>
|
||||
<p>查看发布 run、Jenkins 构建链接、耗时、失败节点和步骤轨迹。</p>
|
||||
</div>
|
||||
<div class="page-actions">
|
||||
<ElButton
|
||||
:icon="Download"
|
||||
:loading="importingJenkins"
|
||||
:disabled="!canImportJenkinsBuilds"
|
||||
:disabled="!canImportJenkinsBuilds || syncingAll"
|
||||
@click="importJenkinsBuilds"
|
||||
>
|
||||
导入 Jenkins 直构
|
||||
@@ -381,7 +440,7 @@ function skippedReasonLabel(reason: string): string {
|
||||
<ElButton
|
||||
:icon="RefreshRight"
|
||||
:loading="syncingAll"
|
||||
:disabled="!canSyncAnyRun"
|
||||
:disabled="!canSyncAnyRun || importingJenkins"
|
||||
@click="syncAllJenkinsRuns"
|
||||
>
|
||||
同步全部 Jenkins
|
||||
@@ -531,7 +590,8 @@ function skippedReasonLabel(reason: string): string {
|
||||
<ElButton
|
||||
size="small"
|
||||
:icon="RefreshRight"
|
||||
:disabled="!canSyncSelectedRun"
|
||||
:disabled="!canSyncSelectedRun || selectedActionSubmitting"
|
||||
:loading="selectedActionSubmitting && canSyncSelectedRun"
|
||||
@click="syncSelectedRun"
|
||||
>
|
||||
同步 Jenkins
|
||||
@@ -539,7 +599,8 @@ function skippedReasonLabel(reason: string): string {
|
||||
<ElButton
|
||||
size="small"
|
||||
:icon="CircleClose"
|
||||
:disabled="!canRetrySelectedRun"
|
||||
:disabled="!canRetrySelectedRun || selectedActionSubmitting"
|
||||
:loading="selectedActionSubmitting && canRetrySelectedRun"
|
||||
@click="retrySelectedRun"
|
||||
>
|
||||
重试
|
||||
@@ -560,12 +621,11 @@ function skippedReasonLabel(reason: string): string {
|
||||
|
||||
<section class="panel" v-if="selectedRun">
|
||||
<div class="panel-header">
|
||||
<h2>{{ selectedRun.id }} 流程轨迹</h2>
|
||||
<h2>{{ selectedRun.id }} 发布步骤轨迹</h2>
|
||||
<StatusPill :state="selectedRun.status" />
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<BpmnStatusViewer
|
||||
:xml="platform.releaseProcessXml"
|
||||
<PipelineStatusViewer
|
||||
:run="selectedRun"
|
||||
:steps="selectedRun.steps"
|
||||
/>
|
||||
@@ -578,7 +638,7 @@ function skippedReasonLabel(reason: string): string {
|
||||
</div>
|
||||
<div class="panel-body run-empty-state">
|
||||
<strong>当前筛选没有可查看的 Run</strong>
|
||||
<span>调整项目、环境、状态或搜索条件后,再查看对应的执行详情与流程轨迹。</span>
|
||||
<span>调整项目、环境、状态或搜索条件后,再查看对应的执行详情与步骤轨迹。</span>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 系统配置页展示集成变量说明、配置边界和审计日志脱敏 JSON。
|
||||
*/
|
||||
import { Connection, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import AuditJsonCell from '../components/AuditJsonCell.vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
@@ -385,6 +385,15 @@ async function saveAgentConfig() {
|
||||
return
|
||||
}
|
||||
|
||||
const confirmed = await confirmSettingsAction(
|
||||
'确认保存 Agent 模型配置',
|
||||
'将把 Base URL、模型名称和可选 API Key 提交给后端保存;前端不会持久化密钥。',
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
agentConfigLoading.value = true
|
||||
|
||||
try {
|
||||
@@ -410,6 +419,15 @@ async function testAgentConfig() {
|
||||
return
|
||||
}
|
||||
|
||||
const confirmed = await confirmSettingsAction(
|
||||
'确认测试 Agent 连接',
|
||||
'后端将使用已保存的模型配置发起一次真实连通性测试。',
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
agentConfigTesting.value = true
|
||||
|
||||
try {
|
||||
@@ -432,6 +450,15 @@ async function refreshNotificationOutbox() {
|
||||
}
|
||||
|
||||
async function retryNotificationOutbox(record: NotificationOutboxMessage) {
|
||||
const confirmed = await confirmSettingsAction(
|
||||
'确认重发通知',
|
||||
`将重发通知 outbox ${record.id},渠道 ${record.channel},模板 ${record.template}。`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
setRetryingOutbox(record.id, true)
|
||||
|
||||
try {
|
||||
@@ -445,6 +472,20 @@ async function retryNotificationOutbox(record: NotificationOutboxMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmSettingsAction(title: string, message: string): Promise<boolean> {
|
||||
try {
|
||||
await ElMessageBox.confirm(message, title, {
|
||||
confirmButtonText: '确认执行',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
autofocus: false,
|
||||
})
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function applyAgentConfig(config: AgentConfigSummary) {
|
||||
agentConfig.value = config
|
||||
agentConfigForm.baseURL = config.baseURL
|
||||
@@ -607,12 +648,18 @@ function resetAuditFilters() {
|
||||
/>
|
||||
</ElFormItem>
|
||||
<div class="toolbar">
|
||||
<ElButton type="primary" :loading="agentConfigLoading" @click="saveAgentConfig">
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="agentConfigLoading"
|
||||
:disabled="agentConfigTesting"
|
||||
@click="saveAgentConfig"
|
||||
>
|
||||
保存配置
|
||||
</ElButton>
|
||||
<ElButton
|
||||
:icon="Connection"
|
||||
:loading="agentConfigTesting"
|
||||
:disabled="agentConfigLoading"
|
||||
@click="testAgentConfig"
|
||||
>
|
||||
测试连接
|
||||
|
||||
Reference in New Issue
Block a user