fix
This commit is contained in:
@@ -78,8 +78,6 @@
|
|||||||
import card from './components/nodes/cards/index.vue'
|
import card from './components/nodes/cards/index.vue'
|
||||||
import text from './components/nodes/text.vue'
|
import text from './components/nodes/text.vue'
|
||||||
|
|
||||||
// 接口
|
|
||||||
import { getSketchFlowCanvas, putSketchFlowCanvas } from '@/api/flow-canvas'
|
|
||||||
const components = {
|
const components = {
|
||||||
[NODE_COMPONENT.RESULT_IMAGE]: resultImage,
|
[NODE_COMPONENT.RESULT_IMAGE]: resultImage,
|
||||||
[NODE_COMPONENT.CARD]: card,
|
[NODE_COMPONENT.CARD]: card,
|
||||||
@@ -100,6 +98,7 @@
|
|||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const emit = defineEmits(['exportFlow'])
|
||||||
|
|
||||||
const vueFlow = ref<any>()
|
const vueFlow = ref<any>()
|
||||||
const nodeTypes = ref([NODE_TYPE.INPUT, NODE_TYPE.SECONDARY, NODE_TYPE.OUTPUT, NODE_TYPE.ALONE])
|
const nodeTypes = ref([NODE_TYPE.INPUT, NODE_TYPE.SECONDARY, NODE_TYPE.OUTPUT, NODE_TYPE.ALONE])
|
||||||
@@ -146,6 +145,7 @@
|
|||||||
const { layout } = useLayout()
|
const { layout } = useLayout()
|
||||||
const index = ref(0)
|
const index = ref(0)
|
||||||
async function layoutGraph(direction) {
|
async function layoutGraph(direction) {
|
||||||
|
if(props.config.json > 0)return
|
||||||
if (index.value > 0) return
|
if (index.value > 0) return
|
||||||
index.value++
|
index.value++
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -190,15 +190,7 @@
|
|||||||
// flowManager.exportFlow()
|
// flowManager.exportFlow()
|
||||||
|
|
||||||
const str = JSON.stringify(stateManager.nodes.value)
|
const str = JSON.stringify(stateManager.nodes.value)
|
||||||
const json = JSON.parse(str)
|
emit('exportFlow', str)
|
||||||
putSketchFlowCanvas({
|
|
||||||
id: props.config.imgId,
|
|
||||||
canvasData: str
|
|
||||||
}).then((res) => {
|
|
||||||
if (res) {
|
|
||||||
console.log(res)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// localStorage.setItem('flow_json', str)
|
// localStorage.setItem('flow_json', str)
|
||||||
}
|
}
|
||||||
// 导入流程
|
// 导入流程
|
||||||
@@ -229,19 +221,9 @@
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// window['vueFlow'] = vueFlow
|
// window['vueFlow'] = vueFlow
|
||||||
// window['nodes'] = nodes
|
// window['nodes'] = nodes
|
||||||
let json = []
|
|
||||||
await new Promise((resolve) => {
|
if(props.config.json.length > 0){
|
||||||
getSketchFlowCanvas({ id: props.config.imgId }).then((res:any) => {
|
importFlow(props.config.json)
|
||||||
if (res) {
|
|
||||||
json = JSON.parse(res)
|
|
||||||
}
|
|
||||||
resolve(true)
|
|
||||||
}).catch(() => {
|
|
||||||
resolve(true)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
if(json.length > 0){
|
|
||||||
importFlow(json)
|
|
||||||
}else{
|
}else{
|
||||||
const timestamp = Date.now()
|
const timestamp = Date.now()
|
||||||
nodeManager.createResultNode({
|
nodeManager.createResultNode({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
|
<fullscreen-dialog v-model="dialogVisible" hide-destroy>
|
||||||
<flow-canvas :config="config" />
|
<flow-canvas :config="config" @exportFlow="exportFlow" />
|
||||||
</fullscreen-dialog>
|
</fullscreen-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -8,18 +8,46 @@
|
|||||||
import FullscreenDialog from '../components/fullscreen-dialog.vue'
|
import FullscreenDialog from '../components/fullscreen-dialog.vue'
|
||||||
import flowCanvas from './flow-canvas.vue'
|
import flowCanvas from './flow-canvas.vue'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { getSketchFlowCanvas, putSketchFlowCanvas } from '@/api/flow-canvas'
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const config = ref({})
|
const config = ref({}) as any
|
||||||
const open = (options) => {
|
const open = async (options) => {
|
||||||
dialogVisible.value = true
|
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 = 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 = () => {
|
const close = () => {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
close
|
close,
|
||||||
|
exportFlow
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ export class NodeManager {
|
|||||||
...(options?.data || {}),
|
...(options?.data || {}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
console.log(11)
|
||||||
return this.createNode(options_)
|
return this.createNode(options_)
|
||||||
}
|
}
|
||||||
/** 创建卡片选择节点 */
|
/** 创建卡片选择节点 */
|
||||||
|
|||||||
Reference in New Issue
Block a user