123
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
}
|
||||
]
|
||||
const nodeManager = inject('nodeManager') as any
|
||||
const stateManager = inject('stateManager') as any
|
||||
const props = defineProps({
|
||||
type: {
|
||||
type: String as () =>
|
||||
@@ -107,16 +108,22 @@
|
||||
const componentRef = ref(null)
|
||||
const onGenerateClick = () => {
|
||||
const data = { ...componentRef.value.data }
|
||||
const subordNode = stateManager.getSubordNodeByID(attrs.node.id)
|
||||
if (attrs.node.data) attrs.node.data.data = data
|
||||
nodeManager.createResultNode({
|
||||
data: {
|
||||
superiorID: attrs.node.id,
|
||||
tier: currentComponent.value.tier,
|
||||
if (!subordNode) {
|
||||
nodeManager.createResultNode({
|
||||
data: {
|
||||
url: 'https://s3-alpha-sig.figma.com/img/ea2f/590e/9638f62a2fc91e31f33db0022db1642c?Expires=1773014400&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=M0B8oJJOk~dGG0aZAqOIocAp7T0LFdJ9FYmCrEZVTCRzYxM6SJRNtYMTX-rTO3Z~s14QINh~o-S41XiZnBv-0zcKjuWot~VVaNHfd0~1LesfNe2KwvCinT~72btFut1pheLnKE-wWCX5ewtonxU77bnw386YPMTqv7DBZzksf2udsJA7NmOYD6~TUG3Q2dWSt~zPH~lkaidscPqpCnCbqzljCEi4RiHY4U3A45l5XypcX2umqn1UaYUFCTqV9471J4qdB6Dg2pcKocdp-7-3s1De6Q~2SmBOrSgDQ~KEADCB2lhKfhxgWmy0lwMvhTd4l90ygVZDWZRABgjHNrGUvg__'
|
||||
superiorID: attrs.node.id,
|
||||
tier: currentComponent.value.tier,
|
||||
data: {
|
||||
url: 'https://s3-alpha-sig.figma.com/img/ea2f/590e/9638f62a2fc91e31f33db0022db1642c?Expires=1773014400&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=M0B8oJJOk~dGG0aZAqOIocAp7T0LFdJ9FYmCrEZVTCRzYxM6SJRNtYMTX-rTO3Z~s14QINh~o-S41XiZnBv-0zcKjuWot~VVaNHfd0~1LesfNe2KwvCinT~72btFut1pheLnKE-wWCX5ewtonxU77bnw386YPMTqv7DBZzksf2udsJA7NmOYD6~TUG3Q2dWSt~zPH~lkaidscPqpCnCbqzljCEi4RiHY4U3A45l5XypcX2umqn1UaYUFCTqV9471J4qdB6Dg2pcKocdp-7-3s1De6Q~2SmBOrSgDQ~KEADCB2lhKfhxgWmy0lwMvhTd4l90ygVZDWZRABgjHNrGUvg__'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
subordNode.data.data.url =
|
||||
'https://s3-alpha-sig.figma.com/img/ea2f/590e/9638f62a2fc91e31f33db0022db1642c?Expires=1773014400&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=M0B8oJJOk~dGG0aZAqOIocAp7T0LFdJ9FYmCrEZVTCRzYxM6SJRNtYMTX-rTO3Z~s14QINh~o-S41XiZnBv-0zcKjuWot~VVaNHfd0~1LesfNe2KwvCinT~72btFut1pheLnKE-wWCX5ewtonxU77bnw386YPMTqv7DBZzksf2udsJA7NmOYD6~TUG3Q2dWSt~zPH~lkaidscPqpCnCbqzljCEi4RiHY4U3A45l5XypcX2umqn1UaYUFCTqV9471J4qdB6Dg2pcKocdp-7-3s1De6Q~2SmBOrSgDQ~KEADCB2lhKfhxgWmy0lwMvhTd4l90ygVZDWZRABgjHNrGUvg__'
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
for (const key in props.data) {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onBeforeUnmount, useAttrs, inject } from 'vue'
|
||||
import { reactive, ref, onBeforeUnmount, useAttrs, inject, watch } from 'vue'
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
@@ -49,9 +49,14 @@
|
||||
const showHeader = ref(!!attrs.node?.data?.isHeader)
|
||||
const showMenu = ref(false)
|
||||
const data = reactive({
|
||||
tier: props.data?.tier || 0,
|
||||
url: props.data?.url || ''
|
||||
})
|
||||
watch(
|
||||
() => props.data.url,
|
||||
(newVal) => {
|
||||
data.url = newVal
|
||||
}
|
||||
)
|
||||
const menus = ref([
|
||||
{ label: 'Copy', tip: 'Ctrl+C', on: () => {} },
|
||||
{ label: 'Paste', tip: 'Ctrl+V', on: () => {} },
|
||||
|
||||
@@ -19,5 +19,8 @@ export class FlowManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
getSubordNodeByID(id: string) {
|
||||
return this.vueFlow.value.getNodes?.find((v) => v.data.superiorID === id)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,6 +94,14 @@ export class StateManager {
|
||||
deleteNode(id: string) {
|
||||
this.nodes.value = this.nodes.value.filter((node: NodesItem) => node.id !== id)
|
||||
}
|
||||
/** 获取节点 */
|
||||
getNodeById(id: string) {
|
||||
return this.nodes.value.find((node: NodesItem) => node.id === id)
|
||||
}
|
||||
/** 获取下级节点 */
|
||||
getSubordNodeByID(id: string) {
|
||||
return this.nodes.value.find((node: NodesItem) => node.data.superiorID === id)
|
||||
}
|
||||
getLastNode() {
|
||||
return this.nodes.value[this.nodes.value.length - 1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user