This commit is contained in:
X1627315083@163.com
2026-03-13 15:06:33 +08:00
parent 85accaead5
commit 1333a885d1
3 changed files with 40 additions and 29 deletions

View File

@@ -78,8 +78,6 @@
import card from './components/nodes/cards/index.vue'
import text from './components/nodes/text.vue'
// 接口
import { getSketchFlowCanvas, putSketchFlowCanvas } from '@/api/flow-canvas'
const components = {
[NODE_COMPONENT.RESULT_IMAGE]: resultImage,
[NODE_COMPONENT.CARD]: card,
@@ -100,6 +98,7 @@
default: () => ({})
}
})
const emit = defineEmits(['exportFlow'])
const vueFlow = ref<any>()
const nodeTypes = ref([NODE_TYPE.INPUT, NODE_TYPE.SECONDARY, NODE_TYPE.OUTPUT, NODE_TYPE.ALONE])
@@ -146,6 +145,7 @@
const { layout } = useLayout()
const index = ref(0)
async function layoutGraph(direction) {
if(props.config.json > 0)return
if (index.value > 0) return
index.value++
setTimeout(() => {
@@ -190,15 +190,7 @@
// flowManager.exportFlow()
const str = JSON.stringify(stateManager.nodes.value)
const json = JSON.parse(str)
putSketchFlowCanvas({
id: props.config.imgId,
canvasData: str
}).then((res) => {
if (res) {
console.log(res)
}
})
emit('exportFlow', str)
// localStorage.setItem('flow_json', str)
}
// 导入流程
@@ -229,19 +221,9 @@
onMounted(async () => {
// window['vueFlow'] = vueFlow
// window['nodes'] = nodes
let json = []
await new Promise((resolve) => {
getSketchFlowCanvas({ id: props.config.imgId }).then((res:any) => {
if (res) {
json = JSON.parse(res)
}
resolve(true)
}).catch(() => {
resolve(true)
})
})
if(json.length > 0){
importFlow(json)
if(props.config.json.length > 0){
importFlow(props.config.json)
}else{
const timestamp = Date.now()
nodeManager.createResultNode({

View File

@@ -1,6 +1,6 @@
<template>
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
<flow-canvas :config="config" />
<flow-canvas :config="config" @exportFlow="exportFlow" />
</fullscreen-dialog>
</template>
@@ -8,18 +8,46 @@
import FullscreenDialog from '../components/fullscreen-dialog.vue'
import flowCanvas from './flow-canvas.vue'
import { ref } from 'vue'
import { getSketchFlowCanvas, putSketchFlowCanvas } from '@/api/flow-canvas'
const dialogVisible = ref(false)
const config = ref({})
const open = (options) => {
dialogVisible.value = true
const config = ref({}) as any
const open = async (options) => {
let json = []
await new Promise((resolve) => {
getSketchFlowCanvas({ id: options.imgId }).then((res:any) => {
if (res) {
json = JSON.parse(res)
}
resolve(true)
}).catch(() => {
resolve(true)
})
})
config.value = options || {}
config.value.json = json
dialogVisible.value = true
}
const exportFlow = async (str) => {
if(!config.value.imgId)return
await new Promise((resolve) => {
putSketchFlowCanvas({
id: config.value.imgId,
canvasData: str }).then(() => {
resolve(true)
}).catch(() => {
resolve(true)
})
})
}
const close = () => {
dialogVisible.value = false
}
defineExpose({
open,
close
close,
exportFlow
})
</script>
<style lang="less" scoped>

View File

@@ -83,6 +83,7 @@ export class NodeManager {
...(options?.data || {}),
},
}
console.log(11)
return this.createNode(options_)
}
/** 创建卡片选择节点 */