Skip to content

Commit c960123

Browse files
committed
perf: 优化应用编排历史版本
1 parent f9611c2 commit c960123

File tree

4 files changed

+43
-38
lines changed

4 files changed

+43
-38
lines changed

ui/src/components/dynamics-form/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const install = (app: App) => {
1616
const commentName: string = key
1717
.substring(key.lastIndexOf('/') + 1, key.length)
1818
.replace('.vue', '')
19-
app.component(commentName, components[key].default)
19+
if (key !== '/src/components/dynamics-form/constructor/index.vue') {
20+
app.component(commentName, components[key].default)
21+
}
2022
})
2123
app.component('DynamicsForm', DynamicsForm)
2224
}

ui/src/views/application-workflow/index.vue

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@
134134
</div>
135135
</template>
136136
<script setup lang="ts">
137-
import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
137+
import { ref, onMounted, onBeforeUnmount, computed, nextTick } from 'vue'
138138
import { useRouter, useRoute } from 'vue-router'
139139
import Workflow from '@/workflow/index.vue'
140140
import DropdownMenu from '@/views/application-workflow/component/DropdownMenu.vue'
141141
import PublishHistory from '@/views/application-workflow/component/PublishHistory.vue'
142142
import applicationApi from '@/api/application'
143143
import { isAppIcon } from '@/utils/application'
144-
import { MsgSuccess, MsgConfirm, MsgError } from '@/utils/message'
144+
import { MsgSuccess, MsgError } from '@/utils/message'
145145
import { datetimeFormat } from '@/utils/time'
146146
import useStore from '@/stores'
147147
import { WorkFlowInstance } from '@/workflow/common/validate'
@@ -182,34 +182,31 @@ function clickoutsideHistory() {
182182
183183
function refreshVersion(item?: any) {
184184
if (item) {
185-
getHistortyDetail(item.id)
185+
renderGraphData(item)
186186
}
187187
if (hasPermission(`APPLICATION:MANAGE:${id}`, 'AND') && isSave.value) {
188188
initInterval()
189189
}
190190
showHistory.value = false
191191
disablePublic.value = false
192192
}
193+
193194
function checkVersion(item: any) {
194195
disablePublic.value = true
195-
getHistortyDetail(item.id)
196196
currentVersion.value = item
197+
renderGraphData(item)
197198
closeInterval()
198199
}
199200
200-
function getHistortyDetail(versionId: string) {
201-
applicationApi.getWorkFlowVersionDetail(id, versionId, loading).then((res: any) => {
202-
res.data?.work_flow['nodes'].map((v: any) => {
203-
v['properties']['noRender'] = true
204-
})
205-
detail.value.work_flow = res.data.work_flow
206-
detail.value.stt_model_id = res.data.stt_model
207-
detail.value.tts_model_id = res.data.tts_model
208-
detail.value.tts_type = res.data.tts_type
209-
saveTime.value = res.data?.update_time
210-
setTimeout(() => {
211-
workflowRef.value?.renderGraphData()
212-
}, 200)
201+
function renderGraphData(item: any) {
202+
item.work_flow['nodes'].map((v: any) => {
203+
v['properties']['noRender'] = true
204+
})
205+
detail.value.work_flow = item.work_flow
206+
saveTime.value = item?.update_time
207+
workflowRef.value?.clearGraphData()
208+
nextTick(() => {
209+
workflowRef.value?.render(item.work_flow)
213210
})
214211
}
215212
@@ -259,7 +256,6 @@ function publicHandle() {
259256
return
260257
}
261258
applicationApi.putPublishApplication(id as String, obj, loading).then(() => {
262-
getDetail()
263259
MsgSuccess('发布成功')
264260
})
265261
})
@@ -317,7 +313,7 @@ function getGraphData() {
317313
}
318314
319315
function getDetail() {
320-
application.asyncGetApplicationDetail(id, loading).then((res: any) => {
316+
application.asyncGetApplicationDetail(id).then((res: any) => {
321317
res.data?.work_flow['nodes'].map((v: any) => {
322318
v['properties']['noRender'] = true
323319
})
@@ -326,9 +322,10 @@ function getDetail() {
326322
detail.value.tts_model_id = res.data.tts_model
327323
detail.value.tts_type = res.data.tts_type
328324
saveTime.value = res.data?.update_time
329-
setTimeout(() => {
330-
workflowRef.value?.renderGraphData()
331-
}, 200)
325+
workflowRef.value?.clearGraphData()
326+
nextTick(() => {
327+
workflowRef.value?.renderGraphData(detail.value.work_flow)
328+
})
332329
})
333330
}
334331

ui/src/workflow/common/app-node.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,20 @@ class AppNodeModel extends HtmlResize.model {
193193
get_width() {
194194
return this.properties?.width || 340
195195
}
196-
196+
197197
setAttributes() {
198198
this.width = this.get_width()
199-
const isLoop=(node_id:string,target_node_id:string)=>{
200-
const up_node_list=this.graphModel.getNodeIncomingNode(node_id)
199+
const isLoop = (node_id: string, target_node_id: string) => {
200+
const up_node_list = this.graphModel.getNodeIncomingNode(node_id)
201201
for (const index in up_node_list) {
202-
const item=up_node_list[index]
203-
if(item.id===target_node_id){
204-
return true
205-
}else{
206-
const result= isLoop(item.id,target_node_id)
207-
if(result){
202+
const item = up_node_list[index]
203+
if (item.id === target_node_id) {
208204
return true
209-
}
205+
} else {
206+
const result = isLoop(item.id, target_node_id)
207+
if (result) {
208+
return true
209+
}
210210
}
211211
}
212212
return false
@@ -220,7 +220,7 @@ class AppNodeModel extends HtmlResize.model {
220220
this.sourceRules.push({
221221
message: '不可循环连线',
222222
validate: (sourceNode: any, targetNode: any, sourceAnchor: any, targetAnchor: any) => {
223-
return !isLoop(sourceNode.id,targetNode.id)
223+
return !isLoop(sourceNode.id, targetNode.id)
224224
}
225225
})
226226

ui/src/workflow/index.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ const lf = ref()
5151
onMounted(() => {
5252
renderGraphData()
5353
})
54-
55-
const renderGraphData = () => {
54+
const render = (data: any) => {
55+
lf.value.render(data)
56+
}
57+
const renderGraphData = (data?: any) => {
58+
if (data) {
59+
graphData.value = data
60+
}
5661
const container: any = document.querySelector('#container')
5762
if (container) {
5863
lf.value = new LogicFlow({
@@ -133,7 +138,7 @@ const addNode = (shapeItem: ShapeItem) => {
133138
}
134139
135140
const clearGraphData = () => {
136-
return lf.value.graphModel.clearData()
141+
return lf.value.clearData()
137142
}
138143
139144
defineExpose({
@@ -142,7 +147,8 @@ defineExpose({
142147
getGraphData,
143148
addNode,
144149
clearGraphData,
145-
renderGraphData
150+
renderGraphData,
151+
render
146152
})
147153
</script>
148154
<style lang="scss">

0 commit comments

Comments
 (0)