fix: 修复点击立即触发运行报错的bug

This commit is contained in:
xiaojunnuo
2025-11-12 22:15:17 +08:00
parent c31bfd8b94
commit e1eef013a8
2 changed files with 19 additions and 13 deletions
@@ -20,8 +20,8 @@ defineOptions({
name: "PipelineDetail", name: "PipelineDetail",
}); });
const route = useRoute(); const route = useRoute();
const pipelineId: Ref = ref(route.query.id); const pipelineId: Ref = ref(parseInt((route.query.id as string) || "0"));
const historyId = ref(route.query.historyId as string); const historyId: Ref = ref(parseInt((route.query.historyId as string) || "0"));
const pluginStore = usePluginStore(); const pluginStore = usePluginStore();
const pipelineOptions: PipelineOptions = { const pipelineOptions: PipelineOptions = {
async getPipelineDetail({ pipelineId }) { async getPipelineDetail({ pipelineId }) {
@@ -327,11 +327,11 @@ export default defineComponent({
}, },
props: { props: {
pipelineId: { pipelineId: {
type: [Number, String], type: Number,
default: 0, default: 0,
}, },
historyId: { historyId: {
type: [Number, String], type: Number,
default: 0, default: 0,
}, },
editMode: { editMode: {
@@ -348,6 +348,7 @@ export default defineComponent({
emits: ["update:modelValue", "update:editMode"], emits: ["update:modelValue", "update:editMode"],
setup(props, ctx) { setup(props, ctx) {
const { t } = useI18n(); const { t } = useI18n();
//右侧选中的pipeline
const currentPipeline: Ref<any> = ref({}); const currentPipeline: Ref<any> = ref({});
const pipeline: Ref<any> = ref({}); const pipeline: Ref<any> = ref({});
const pipelineEntity: Ref<any> = ref({}); const pipelineEntity: Ref<any> = ref({});
@@ -399,7 +400,7 @@ export default defineComponent({
currentPipeline.value = currentHistory.value.pipeline; currentPipeline.value = currentHistory.value.pipeline;
}; };
async function loadHistoryList(reload = false) { async function loadHistoryList(reload = false, historyId: number) {
if (props.editMode) { if (props.editMode) {
return; return;
} }
@@ -416,11 +417,11 @@ export default defineComponent({
histories.value = historyList; histories.value = historyList;
if (historyList.length > 0) { if (historyList.length > 0) {
//@ts-ignore if (historyId > 0) {
if (props.historyId > 0) { //如果传递了history,优先显示历史记录作为当前
const found = historyList.find(item => { const found = histories.value.find(item => {
//字符串==int //字符串==int
return item.id == props.historyId; return item.id == historyId;
}); });
if (found) { if (found) {
await changeCurrentHistory(found); await changeCurrentHistory(found);
@@ -428,7 +429,8 @@ export default defineComponent({
} }
} }
//@ts-ignore //@ts-ignore
if (historyList[0]?.version === pipeline.value.version) { if (historyList[0]?.version === pipeline.value?.version) {
//如果当前的流水线版本与历史记录最后一条一致,则将该记录设置为current
await changeCurrentHistory(historyList[0]); await changeCurrentHistory(historyList[0]);
} }
} }
@@ -482,7 +484,7 @@ export default defineComponent({
if (editMode) { if (editMode) {
changeCurrentHistory(); changeCurrentHistory();
} else if (histories.value.length > 0) { } 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]); changeCurrentHistory(histories.value[0]);
} }
} }
@@ -508,7 +510,7 @@ export default defineComponent({
detail.pipeline detail.pipeline
); );
pipeline.value = currentPipeline.value; pipeline.value = currentPipeline.value;
await loadHistoryList(true); await loadHistoryList(true, props.historyId);
}, },
{ {
immediate: true, immediate: true,
@@ -740,7 +742,11 @@ export default defineComponent({
//@ts-ignore //@ts-ignore
await changeCurrentHistory(null); await changeCurrentHistory(null);
if (histories.value.length > 0) { 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 }); await props.options.doTrigger({ pipelineId: pipeline.value.id, stepId: stepId });