From e1eef013a856d26fe80a05d9ec6e505e2e31e5f9 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 12 Nov 2025 22:15:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E8=A7=A6=E5=8F=91=E8=BF=90=E8=A1=8C=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/certd/pipeline/detail.vue | 4 +-- .../views/certd/pipeline/pipeline/index.vue | 28 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue index a27ed3ab..d713a560 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue @@ -20,8 +20,8 @@ defineOptions({ name: "PipelineDetail", }); const route = useRoute(); -const pipelineId: Ref = ref(route.query.id); -const historyId = ref(route.query.historyId as string); +const pipelineId: Ref = ref(parseInt((route.query.id as string) || "0")); +const historyId: Ref = ref(parseInt((route.query.historyId as string) || "0")); const pluginStore = usePluginStore(); const pipelineOptions: PipelineOptions = { async getPipelineDetail({ pipelineId }) { diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue index bcb6f087..43a14ea1 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue @@ -327,11 +327,11 @@ export default defineComponent({ }, props: { pipelineId: { - type: [Number, String], + type: Number, default: 0, }, historyId: { - type: [Number, String], + type: Number, default: 0, }, editMode: { @@ -348,6 +348,7 @@ export default defineComponent({ emits: ["update:modelValue", "update:editMode"], setup(props, ctx) { const { t } = useI18n(); + //右侧选中的pipeline const currentPipeline: Ref = ref({}); const pipeline: Ref = ref({}); const pipelineEntity: Ref = ref({}); @@ -399,7 +400,7 @@ export default defineComponent({ currentPipeline.value = currentHistory.value.pipeline; }; - async function loadHistoryList(reload = false) { + async function loadHistoryList(reload = false, historyId: number) { if (props.editMode) { return; } @@ -416,11 +417,11 @@ export default defineComponent({ histories.value = historyList; if (historyList.length > 0) { - //@ts-ignore - if (props.historyId > 0) { - const found = historyList.find(item => { + if (historyId > 0) { + //如果传递了history,优先显示历史记录作为当前 + const found = histories.value.find(item => { //字符串==int - return item.id == props.historyId; + return item.id == historyId; }); if (found) { await changeCurrentHistory(found); @@ -428,7 +429,8 @@ export default defineComponent({ } } //@ts-ignore - if (historyList[0]?.version === pipeline.value.version) { + if (historyList[0]?.version === pipeline.value?.version) { + //如果当前的流水线版本与历史记录最后一条一致,则将该记录设置为current await changeCurrentHistory(historyList[0]); } } @@ -482,7 +484,7 @@ export default defineComponent({ if (editMode) { changeCurrentHistory(); } else if (histories.value.length > 0) { - if (histories.value[0].pipeline.version === pipeline.value.version) { + if (histories.value[0].pipeline?.version === pipeline.value?.version) { changeCurrentHistory(histories.value[0]); } } @@ -508,7 +510,7 @@ export default defineComponent({ detail.pipeline ); pipeline.value = currentPipeline.value; - await loadHistoryList(true); + await loadHistoryList(true, props.historyId); }, { immediate: true, @@ -740,7 +742,11 @@ export default defineComponent({ //@ts-ignore await changeCurrentHistory(null); if (histories.value.length > 0) { - pipeline.value = histories.value[0].pipeline; + //看是不是最新的pipeline版本 + if (pipeline.value?.version !== histories.value[0].pipeline?.version) { + const detail: PipelineDetail = await props.options.getPipelineDetail({ pipelineId: pipeline.value.id }); + pipeline.value = detail.pipeline; + } } await props.options.doTrigger({ pipelineId: pipeline.value.id, stepId: stepId });