This commit is contained in:
X1627315083@163.com
2026-03-17 11:06:32 +08:00
parent 9aa9c8193c
commit 2ad392037e
5 changed files with 27 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
<template>
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
<fullscreen-dialog v-model="dialogVisible" @close="onClose" hide-destroy>
<div class="canvas-box">
<depth-canvas :config="config" @workbench="onWorkbench" @close="onClose" />
</div>

View File

@@ -146,7 +146,7 @@
const { layout } = useLayout()
const index = ref(0)
async function layoutGraph(direction) {
if (props.config.json > 0) return
if (props.config.json.length > 0) return
if (index.value > 0) return
index.value++
setTimeout(() => {
@@ -187,10 +187,14 @@
stateManager.sendToBack(id)
}
// 导出流程
const getFlowJson = () => {
if(!stateManager.isSave.value)return ''
return JSON.stringify(stateManager.nodes.value)
}
const exportFlow = () => {
// flowManager.exportFlow()
const str = JSON.stringify(stateManager.nodes.value)
const str = getFlowJson()
stateManager.isSave.value = false
emit('exportFlow', str)
// localStorage.setItem('flow_json', str)
}
@@ -259,6 +263,9 @@
nodeManager.dispose()
toolManager.dispose()
})
defineExpose({
getFlowJson
})
</script>
<style lang="less">
@import '@vue-flow/core/dist/style.css';

View File

@@ -1,6 +1,6 @@
<template>
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
<flow-canvas :config="config" @exportFlow="exportFlow" />
<fullscreen-dialog v-model="dialogVisible" @close="close" hide-destroy>
<flow-canvas ref="flowCanvasRef" :config="config" @exportFlow="exportFlow" />
</fullscreen-dialog>
</template>
@@ -12,6 +12,7 @@
const dialogVisible = ref(false)
const config = ref({}) as any
const flowCanvasRef = ref<any>()
const open = async (options) => {
let json = []
await new Promise((resolve) => {
@@ -29,7 +30,7 @@
dialogVisible.value = true
}
const exportFlow = async (str) => {
if(!config.value.imgId)return
if(!config.value.imgId || !str)return
await new Promise((resolve) => {
putSketchFlowCanvas({
id: config.value.imgId,
@@ -41,7 +42,9 @@
})
}
const close = () => {
const close = async () => {
const str = flowCanvasRef.value?.getFlowJson()
await exportFlow(str)
dialogVisible.value = false
}
defineExpose({

View File

@@ -36,6 +36,9 @@ export class StateManager {
nodeManager: any
toolManager: any
generateManager: any
// 是否有数据没保存
isSave: any
// 设置管理器
setManager(options) {
options.eventManager && (this.eventManager = options.eventManager)
@@ -54,6 +57,7 @@ export class StateManager {
this.mxHistory = ref(50)
this.historyList = ref([])
this.historyIndex = ref(0)
this.isSave = ref(false)
this.activeNodeID = ref("")
this.nodes = ref<NodesItem[]>([]);
@@ -172,6 +176,8 @@ export class StateManager {
const size = this.historyList.value.length - this.mxHistory.value
if (size > 0) this.historyList.value.splice(0, size)
this.historyIndex.value = this.historyList.value.length - 1
this.isSave.value = true
}
/** 撤回状态 */
undoState() {
@@ -205,6 +211,7 @@ export class StateManager {
}
dispose() {
this.isSave.value = false
this.historyList.value = []
this.historyIndex.value = 0
}

View File

@@ -25,7 +25,7 @@
transitionTime: { default: 300, type: Number },
hideDestroy: { default: false, type: Boolean }
})
const emit = defineEmits(['update:modelValue', 'closed'])
const emit = defineEmits(['close', 'closed'])
const show = ref(props.modelValue)
const show_ = ref(props.modelValue)
const timeout = ref(null)
@@ -47,7 +47,7 @@
}
)
const close = () => {
emit('update:modelValue', false)
emit('close', false)
}
</script>