From 7042c5dbb4d9d4a9a064d8afbcc5e515b6f08d95 Mon Sep 17 00:00:00 2001 From: Yourz Date: Mon, 15 Dec 2025 22:19:49 +0800 Subject: [PATCH] refactor: extract nested ternary into early return pattern --- src/components/common/TreeExplorer.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/common/TreeExplorer.vue b/src/components/common/TreeExplorer.vue index 7343f5c69..d91ab9e8c 100644 --- a/src/components/common/TreeExplorer.vue +++ b/src/components/common/TreeExplorer.vue @@ -386,11 +386,11 @@ const onNodeContentClick = async ( const menu = ref | null>(null) const menuTargetNode = ref(null) const extraMenuItems = computed(() => { - return menuTargetNode.value?.contextMenuItems - ? typeof menuTargetNode.value.contextMenuItems === 'function' - ? menuTargetNode.value.contextMenuItems(menuTargetNode.value) - : menuTargetNode.value.contextMenuItems - : [] + const contextMenuItems = menuTargetNode.value?.contextMenuItems + if (!contextMenuItems) return [] + return typeof contextMenuItems === 'function' + ? contextMenuItems(menuTargetNode.value!) + : contextMenuItems }) const renameEditingNode = ref(null) const handleNodeLabelEdit = async (