From 1bfc00520312da0ed24f9f9e54f4a88b32a160a7 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud <79562285+wangdan-fit2cloud@users.noreply.github.com> Date: Tue, 4 Mar 2025 15:17:44 +0800 Subject: [PATCH] perf: optimization workflow interactive --- ui/src/views/application-workflow/index.vue | 49 ++++++++++++------- ui/src/workflow/common/data.ts | 13 ++--- .../nodes/variable-assign-node/index.vue | 20 ++++---- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/ui/src/views/application-workflow/index.vue b/ui/src/views/application-workflow/index.vue index eb53cabbe..60a892a1a 100644 --- a/ui/src/views/application-workflow/index.vue +++ b/ui/src/views/application-workflow/index.vue @@ -174,20 +174,25 @@ const isSave = ref(false) const showHistory = ref(false) const disablePublic = ref(false) const currentVersion = ref({}) +const cloneWorkFlow = ref(null) function back() { - MsgConfirm(t('common.tip'), t('views.applicationWorkflow.tip.saveMessage'), { - confirmButtonText: t('views.applicationWorkflow.setting.exitSave'), - cancelButtonText: t('views.applicationWorkflow.setting.exit'), - type: 'warning', - distinguishCancelAndClose: true - }) - .then(() => { - saveApplication(true, true) - }) - .catch((action: Action) => { - action === 'cancel' && router.push({ path: `/application/${id}/WORK_FLOW/overview` }) + if (JSON.stringify(cloneWorkFlow.value) !== JSON.stringify(getGraphData())) { + MsgConfirm(t('common.tip'), t('views.applicationWorkflow.tip.saveMessage'), { + confirmButtonText: t('views.applicationWorkflow.setting.exitSave'), + cancelButtonText: t('views.applicationWorkflow.setting.exit'), + type: 'warning', + distinguishCancelAndClose: true }) + .then(() => { + saveApplication(true, true) + }) + .catch((action: Action) => { + action === 'cancel' && router.push({ path: `/application/${id}/WORK_FLOW/overview` }) + }) + } else { + router.push({ path: `/application/${id}/WORK_FLOW/overview` }) + } } function clickoutsideHistory() { if (!disablePublic.value) { @@ -357,6 +362,7 @@ function getDetail() { workflowRef.value?.clearGraphData() nextTick(() => { workflowRef.value?.render(detail.value.work_flow) + cloneWorkFlow.value = getGraphData() }) }) } @@ -366,15 +372,20 @@ function saveApplication(bool?: boolean, back?: boolean) { work_flow: getGraphData() } loading.value = back || false - application.asyncPutApplication(id, obj).then((res) => { - saveTime.value = new Date() - if (bool) { - MsgSuccess(t('common.saveSuccess')) - if (back) { - router.push({ path: `/application/${id}/WORK_FLOW/overview` }) + application + .asyncPutApplication(id, obj) + .then((res) => { + saveTime.value = new Date() + if (bool) { + MsgSuccess(t('common.saveSuccess')) + if (back) { + router.push({ path: `/application/${id}/WORK_FLOW/overview` }) + } } - } - }) + }) + .catch(() => { + loading.value = false + }) } /** diff --git a/ui/src/workflow/common/data.ts b/ui/src/workflow/common/data.ts index 3e58eaf41..6554c9b7d 100644 --- a/ui/src/workflow/common/data.ts +++ b/ui/src/workflow/common/data.ts @@ -17,17 +17,14 @@ export const startNode = { } ], globalFields: [ + { label: t('views.applicationWorkflow.nodes.startNode.currentTime'), value: 'time' }, { - value: 'time', - label: t('views.applicationWorkflow.nodes.startNode.currentTime') + label: t('views.application.applicationForm.form.historyRecord.label'), + value: 'history_context' }, { - value: 'history_context', - label: t('views.application.applicationForm.form.historyRecord.label') - }, - { - value: 'chat_id', - label: t('chat.chatId') + label: t('chat.chatId'), + value: 'chat_id' } ] }, diff --git a/ui/src/workflow/nodes/variable-assign-node/index.vue b/ui/src/workflow/nodes/variable-assign-node/index.vue index 8a336e58e..ed3f45612 100644 --- a/ui/src/workflow/nodes/variable-assign-node/index.vue +++ b/ui/src/workflow/nodes/variable-assign-node/index.vue @@ -9,6 +9,7 @@ ref="replyNodeFormRef" hide-required-asterisk > + +