|
45 | 45 | class="file-path-tree" |
46 | 46 | > |
47 | 47 | <template #prepend="{ item, isOpen }"> |
48 | | - <v-icon v-if="item.children.length > 0" size="small"> |
| 48 | + <v-icon v-if="item.children?.length > 0" size="small"> |
49 | 49 | {{ isOpen ? 'mdi-folder-open' : 'mdi-folder' }} |
50 | 50 | </v-icon> |
51 | 51 | <v-icon v-else size="small"> |
@@ -173,13 +173,13 @@ const treeItems = computed(() => { |
173 | 173 | } else { |
174 | 174 | currentLevel.push({ |
175 | 175 | name: fileName, fullPath: filePath, |
176 | | - children: [], findings: numCount |
| 176 | + findings: numCount |
177 | 177 | }); |
178 | 178 | } |
179 | 179 | } |
180 | 180 | }); |
181 | 181 | function aggregate(node) { |
182 | | - if (node.children.length === 0) return node.findings; |
| 182 | + if (!node.children?.length) return node.findings; |
183 | 183 | node.findings = node.children.reduce( |
184 | 184 | (sum, child) => sum + aggregate(child), 0 |
185 | 185 | ); |
@@ -275,8 +275,8 @@ function applyTreeSelection(onApplyFinished) { |
275 | 275 | function isDirectory(fullPath) { |
276 | 276 | const find = nodes => { |
277 | 277 | for (const n of nodes) { |
278 | | - if (n.fullPath === fullPath) return n.children.length > 0; |
279 | | - if (n.children.length) { |
| 278 | + if (n.fullPath === fullPath) return (n.children?.length ?? 0) > 0; |
| 279 | + if (n.children?.length) { |
280 | 280 | const r = find(n.children); |
281 | 281 | if (r !== null) return r; |
282 | 282 | } |
|
0 commit comments