diff --git a/src/App.vue b/src/App.vue index 45602ec..d2dc268 100644 --- a/src/App.vue +++ b/src/App.vue @@ -104,6 +104,15 @@ function changeRootPath(newRootPath) { localStorage.setItem('rootPathOfFolderTree', newRootPath) rootPathOfFolderTree.value = newRootPath } +// 返回的文件树数据,增加自定义数据,便于传给 进行渲染 +function appendDataForNode(nodeData) { + if (!nodeData.directory) { + // 给文件节点,增加 suffix 字段,用于表示文件后缀,便于 过滤文件 + let splitResult = nodeData.name.split('.'); + let fileSuffix = splitResult.length > 1 ? splitResult.pop() : ''; + nodeData.suffix = fileSuffix; + } +} // 选择目录后赋值给 folderTreeData,然后再传递给 const folderTreeData = ref(null) @@ -158,7 +167,8 @@ onUnmounted(() => {