From a30eff90a6accdbc085598155f9ba1fa1cc17207 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Mon, 29 May 2023 19:51:08 +0300 Subject: [PATCH] add history buttons and navigator --- app.vue | 63 ++++++++++++++++----------- composables/history-switcher.ts | 75 +++++++++++++++++++++++++++++++++ package-lock.json | 6 +++ package.json | 1 + 4 files changed, 120 insertions(+), 25 deletions(-) create mode 100644 composables/history-switcher.ts diff --git a/app.vue b/app.vue index 1819aea..07b0d47 100644 --- a/app.vue +++ b/app.vue @@ -17,7 +17,8 @@ let files = ref([]); let filesList = ref([]); let selectedItem = useSelectedItem(); let filesGridList = ref([]) -let selectedList = ref([]) +let selectedList = ref([]); +let history = new HistorySwitcher(selectedItem); watchEffect(async () => { if (files.value?.[0]) { @@ -47,7 +48,7 @@ watchEffect(async () => { }) function onDrop(e: any) { - if(!e.dataTransfer.files.length) return; + if (!e.dataTransfer.files.length) return; files.value = e.dataTransfer.files; selectedItem.value = '/'; } @@ -102,11 +103,6 @@ watchEffect(() => { } }) -watchEffect(() => { - console.log(selectedList.value) -}) - - let dragContainer = document.querySelector(".select-area"); function onSelectStart(e: any) { @@ -131,6 +127,16 @@ function onSelectEnd(e: any) { }); } +// step up from current path +function stepUp(path: string) { + let pathArray = path.split("/"); + if(path.endsWith("/")) { + pathArray.pop(); + } + pathArray.pop(); + return (pathArray.join("/") || "")+ "/"; +} +