Skip to content

Commit 18b4f56

Browse files
committed
refactor candidatefromnodetarget
1 parent 9de27ad commit 18b4f56

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,27 @@ export function useSlotLinkInteraction({
142142
if (!firstLink) return null
143143
const connectingTo = adapter.linkConnector.state.connectingTo
144144

145-
if (connectingTo === 'input') {
146-
const res = node.findInputByType(firstLink.fromSlot.type)
147-
const index = res?.index
148-
if (index == null) return null
149-
const key = getSlotKey(String(nodeId), index, true)
150-
const layout = layoutStore.getSlotLayout(key)
151-
if (!layout) return null
152-
const compatible = adapter.isInputValidDrop(nodeId, index)
153-
if (!compatible) return null
154-
return { layout, compatible: true }
155-
} else if (connectingTo === 'output') {
156-
const res = node.findOutputByType(firstLink.fromSlot.type)
157-
const index = res?.index
158-
if (index == null) return null
159-
const key = getSlotKey(String(nodeId), index, false)
160-
const layout = layoutStore.getSlotLayout(key)
161-
if (!layout) return null
162-
const compatible = adapter.isOutputValidDrop(nodeId, index)
163-
if (!compatible) return null
164-
return { layout, compatible: true }
165-
}
145+
if (connectingTo !== 'input' && connectingTo !== 'output') return null
146+
147+
const isInput = connectingTo === 'input'
148+
const slotType = firstLink.fromSlot.type
149+
150+
const res = isInput
151+
? node.findInputByType(slotType)
152+
: node.findOutputByType(slotType)
153+
154+
const index = res?.index
155+
if (index == null) return null
156+
157+
const key = getSlotKey(String(nodeId), index, isInput)
158+
const layout = layoutStore.getSlotLayout(key)
159+
if (!layout) return null
160+
161+
const compatible = isInput
162+
? adapter.isInputValidDrop(nodeId, index)
163+
: adapter.isOutputValidDrop(nodeId, index)
164+
165+
return compatible ? { layout, compatible: true } : null
166166

167167
return null
168168
}

0 commit comments

Comments
 (0)