diff --git a/packages/client/components/AssetListItem.vue b/packages/client/components/AssetListItem.vue index 3ee7805c..1de198fa 100644 --- a/packages/client/components/AssetListItem.vue +++ b/packages/client/components/AssetListItem.vue @@ -1,9 +1,22 @@ diff --git a/packages/client/pages/assets.vue b/packages/client/pages/assets.vue index e8f760fe..afbb9d43 100644 --- a/packages/client/pages/assets.vue +++ b/packages/client/pages/assets.vue @@ -37,6 +37,27 @@ const byFolders = computed(() => { return Object.entries(result).sort(([a], [b]) => a.localeCompare(b)) }) +const byTree = computed(() => { + const root = { path: 'public', children: [] } + const addToTree = (node: any, pathParts: any, file: AssetInfo) => { + const [currentPart, ...remainingParts] = pathParts + let child = node.children.find((child: any) => child.path === currentPart) + if (!child) { + child = { ...file, path: currentPart, children: [] } + node.children.push(child) + } + if (remainingParts.length > 1) + addToTree(child, remainingParts, file) + else if (remainingParts.length === 1) + child.children.push({ ...file, path: remainingParts[0] }) + } + filtered.value.forEach((file) => { + const pathParts = file.path.split('/').filter(part => part !== '') + addToTree(root, pathParts, file) + }) + return root.children +}) + const selected = ref() const view = ref<'list' | 'grid'>('grid') @@ -92,7 +113,11 @@ const navbar = ref()
- +