11<script setup lang="ts">
2- import { nextTick , onBeforeUnmount , onMounted , provide , ref , useTemplateRef } from ' vue'
2+ import { nextTick , onBeforeUnmount , onMounted , provide , ref , useTemplateRef , watch } from ' vue'
33import { useRoute } from ' vue-router'
44import type LogicFlow from ' @logicflow/core'
55import type { Action } from ' element-plus'
66import { cloneDeep } from ' lodash'
77import ApplicationApi from ' @/api/admin/workspace/application/application.ts'
8- import WorkflowVersionApi from ' @/api/admin/workspace/application/workflow-version'
98import ModelApi from ' @/api/admin/workspace/model/model'
109import type { ApplicationDetail , ApplicationStoreTemplate , DefaultModelSettingPayload , WorkflowVersion } from ' @/api/types'
1110import { MsgConfirm , MsgError , MsgSuccess } from ' @/utils/message'
@@ -14,7 +13,7 @@ import { defaultApplicationNodes } from '@/workflow-canvas/config/node-mapping'
1413import { WorkflowMode } from ' @/workflow-canvas/types'
1514import ButtonDefaultModelSetting from ' ../components/default-model-setting/ButtonDefaultModelSetting.vue'
1615import WorkflowViewLayout from ' ../components/WorkflowViewLayout.vue'
17- import ButtonPublishHistory from ' ../components/publish-history /ButtonPublishHistory.vue'
16+ import ButtonPublishHistory from ' ./ButtonPublishHistory.vue'
1817import TemplateStoreDialog from ' @/views/application/template-store/TemplateStoreDialog.vue'
1918import DebugPanel from ' ./debug/DebugPanel.vue'
2019import { getResourceScope } from ' @/utils/resource-context.ts'
@@ -151,26 +150,22 @@ function handlePreviewVersion(version: WorkflowVersion) {
151150 nextTick (() => workflowRef .value ?.fitView ())
152151}
153152
154- function handleCloseHistory() {
153+ // 所有退出入口统一通过显隐状态清理预览;恢复版本时提前清空草稿快照。
154+ watch (historyVisible , (visible ) => {
155+ if (visible ) return
155156 if (workflowBeforePreview ) workflowRef .value ?.render (cloneDeep (workflowBeforePreview ))
156157 workflowBeforePreview = undefined
157158 previewVersion .value = undefined
158- historyVisible .value = false
159- }
159+ })
160160
161161function handleRestoreVersion(version = previewVersion .value ) {
162162 if (! version || loading .value || saving .value || publishing .value ) return
163163 workflowRef .value ?.render (cloneDeep (version .work_flow ))
164164 workflowBeforePreview = undefined
165- previewVersion .value = undefined
166165 historyVisible .value = false
167166 nextTick (() => workflowRef .value ?.fitView ())
168167}
169168
170- function handleUpdateVersion(version : WorkflowVersion ) {
171- if (previewVersion .value ?.id === version .id ) previewVersion .value = version
172- }
173-
174169/* 模板中心 */
175170const templateStoreDialogRef = useTemplateRef <InstanceType <typeof TemplateStoreDialog >>(' templateStoreDialogRef' )
176171
@@ -219,26 +214,25 @@ function handleSaveDefaultModelSetting(settings: DefaultModelSettingPayload) {
219214/* 发布工作流 */
220215function handlePublish() {
221216 workflowRef .value ?.validate ().then (() => {
222- // publishing.value = true
223- // return saveApplication(undefined, false)
224- // .then(() => ApplicationApi.putApplicationPublish(applicationId))
225- // .then((application) => {
226- // applicationDetail.value = application
227- // saveTime.value = application.update_time || saveTime.value
228- // MsgSuccess('发布成功')
229- // })
230- // .finally(() => {
231- // publishing.value = false
232- // })
217+ publishing .value = true
218+ return saveApplication (undefined , false )
219+ .then (() => ApplicationApi .putApplicationPublish (applicationId ))
220+ .then ((application ) => {
221+ applicationDetail .value = application
222+ saveTime .value = application .update_time || saveTime .value
223+ MsgSuccess (' 发布成功' )
224+ })
225+ .finally (() => {
226+ publishing .value = false
227+ })
233228 })
234229}
235230
236231/* 退出工作流 */
237232function handleBack() {
238233 if (loading .value || saving .value || confirmingExit .value ) return
239234 if (historyVisible .value ) {
240- handleCloseHistory ()
241- return
235+ historyVisible .value = false
242236 }
243237 if (! hasUnsavedChanges ()) {
244238 goBack (applicationId )
@@ -301,7 +295,7 @@ onBeforeUnmount(() => stopAutoSave())
301295 :title =" applicationDetail ?.name "
302296 :save-time =" saveTime "
303297 :history-visible =" historyVisible "
304- :can-restore-version =" !! previewVersion && ! loading && ! saving && ! publishing "
298+ :can-restore-version =" !! previewVersion "
305299 @back =" handleBack "
306300 @restore-version =" handleRestoreVersion ()"
307301 >
@@ -355,15 +349,11 @@ onBeforeUnmount(() => stopAutoSave())
355349 <!-- 发布历史 -->
356350 <ButtonPublishHistory
357351 v-model :visible =" historyVisible "
358- :resource-id =" applicationId "
359- :api =" WorkflowVersionApi "
352+ :application-id =" applicationId "
360353 :selected-id =" previewVersion ?.id "
361- :disabled =" loading || saving || publishing "
362354 @open =" closeDebug "
363355 @preview =" handlePreviewVersion "
364356 @restore =" handleRestoreVersion "
365- @update =" handleUpdateVersion "
366- @close =" handleCloseHistory "
367357 />
368358 <!-- 自动保存 -->
369359 <MkDropdownItem @click .stop >
0 commit comments