mirror of
https://github.com/xlmnxp/extractify.zip.git
synced 2024-11-24 01:24:35 +03:00
improve the performance and increase 3 dots column a little
This commit is contained in:
parent
e644375b75
commit
93a42b6458
4
app.vue
4
app.vue
@ -124,11 +124,11 @@ function stepUp(path: string) {
|
|||||||
<v-btn title="Parent Folder" aria-label="Parent Folder" icon="mdi-arrow-up" :disabled="selectedItem == '/'"
|
<v-btn title="Parent Folder" aria-label="Parent Folder" icon="mdi-arrow-up" :disabled="selectedItem == '/'"
|
||||||
@click="selectedItem = stepUp(selectedItem);"></v-btn>
|
@click="selectedItem = stepUp(selectedItem);"></v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="11" lg="9" md="11">
|
<v-col cols="10" lg="8" md="10">
|
||||||
<v-text-field :disabled="!files.length" hide-details title="Location" single-line placeholder="location"
|
<v-text-field :disabled="!files.length" hide-details title="Location" single-line placeholder="location"
|
||||||
v-model="selectedItem"></v-text-field>
|
v-model="selectedItem"></v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="1">
|
<v-col cols="2">
|
||||||
<v-menu>
|
<v-menu>
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn :disabled="!files.length" title="Menu" aria-label="Menu" icon="mdi-dots-vertical"
|
<v-btn :disabled="!files.length" title="Menu" aria-label="Menu" icon="mdi-dots-vertical"
|
||||||
|
@ -59,29 +59,44 @@ export class FilesManager {
|
|||||||
|
|
||||||
// sort unorganized files by depth
|
// sort unorganized files by depth
|
||||||
unorganizedFiles = unorganizedFiles.sort((a, b) => {
|
unorganizedFiles = unorganizedFiles.sort((a, b) => {
|
||||||
if (a.path.split("/").length > b.path.split("/").length) return -1;
|
const aPathArray = a.path.split("/");
|
||||||
if (a.path.split("/").length < b.path.split("/").length) return 1;
|
const bPathArray = b.path.split("/");
|
||||||
|
if (aPathArray.length > bPathArray.length) return -1;
|
||||||
|
if (aPathArray.length < bPathArray.length) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
// sort files and folder inside each folder
|
// sort files and folder inside each folder
|
||||||
|
const pathArrays: any = {};
|
||||||
for (let file of unorganizedFiles) {
|
for (let file of unorganizedFiles) {
|
||||||
// get parent folder file
|
// get parent folder file
|
||||||
let parentFolderFile = unorganizedFiles.find(_file => _file.path == file.path.substring(0, file.path.lastIndexOf("/")));
|
const parentPath = file.path.substring(0, file.path.lastIndexOf("/"));
|
||||||
|
const parentFolderFile = pathArrays[parentPath] || unorganizedFiles.find(_file => _file.path === parentPath);
|
||||||
if (!parentFolderFile) continue;
|
if (!parentFolderFile) continue;
|
||||||
|
|
||||||
// add file to parent folder content
|
// add file to parent folder content
|
||||||
parentFolderFile.content!.push(file);
|
if (!parentFolderFile.content) parentFolderFile.content = [];
|
||||||
|
parentFolderFile.content.push(file);
|
||||||
|
|
||||||
|
// cache split path array to avoid calling split() multiple times
|
||||||
|
const pathArray = pathArrays[file.path] || file.path.split("/");
|
||||||
|
pathArrays[file.path] = pathArray;
|
||||||
|
|
||||||
|
parentFolderFile.content = parentFolderFile.content.sort((a:any, b:any) => {
|
||||||
|
// sort by folder and from a to z
|
||||||
|
if (a.isFolder && !b.isFolder) return -1;
|
||||||
|
if (!a.isFolder && b.isFolder) return 1;
|
||||||
|
if (a.name < b.name) return -1;
|
||||||
|
if (a.name > b.name) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove folders from root
|
// remove folders from root
|
||||||
console.log(unorganizedFiles);
|
const files = unorganizedFiles.filter(file => (file.path.match(/\//g) || []).length == 1);
|
||||||
let files = unorganizedFiles.filter(file => file.path.split("/").length <= 2);
|
console.log({files});
|
||||||
console.log(files);
|
|
||||||
|
|
||||||
this.filesList.value = files;
|
this.filesList.value = files;
|
||||||
|
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user