diff --git a/frontend/src/components/right-context-menu/index.vue b/frontend/src/components/right-context-menu/index.vue new file mode 100644 index 000000000000..38d651bb2963 --- /dev/null +++ b/frontend/src/components/right-context-menu/index.vue @@ -0,0 +1,105 @@ + + + + diff --git a/frontend/src/views/host/file-management/index.vue b/frontend/src/views/host/file-management/index.vue index 761a81577e1b..0df40876e629 100644 --- a/frontend/src/views/host/file-management/index.vue +++ b/frontend/src/views/host/file-management/index.vue @@ -1,5 +1,11 @@ @@ -865,6 +880,7 @@ const top = () => { }; const jump = async (url: string) => { + hideRightMenu(); history.splice(pointer + 1); history.push(url); pointer = history.length - 1; @@ -1308,7 +1324,8 @@ const buttons = [ openDownload(row); }, disabled: (row: File.File) => { - return row.isDir; + debugger; + return row?.isDir; }, }, { @@ -1366,8 +1383,8 @@ const buttons = [ { label: i18n.global.t('file.addFavorite'), click: (row: File.File) => { - if (row.favoriteID > 0) { - remove(row.favoriteID); + if (row?.favoriteID > 0) { + remove(row?.favoriteID); } else { addToFavorite(row); } @@ -1424,6 +1441,36 @@ const handleDragleave = (event: { preventDefault: () => void }) => { event.preventDefault(); }; +const menuVisible = ref(false); +const noMenuVisible = ref(false); +const menuPosition = reactive({ x: 0, y: 0 }); +const currentRow = ref({} as File.File); + +function openRight(row: File.File, _column: any, event: MouseEvent) { + noMenuVisible.value = true; + if (row.name === currentRow.value?.name && menuVisible.value) { + menuVisible.value = false; + } else { + event.preventDefault(); + currentRow.value = row; + menuPosition.x = event.clientX; + menuPosition.y = event.clientY; + menuVisible.value = true; + } +} + +function hideRightMenu() { + menuVisible.value = false; +} + +function onRightClick() { + if (noMenuVisible.value) { + noMenuVisible.value = false; + } else { + menuVisible.value = false; + } +} + onMounted(() => { if (localStorage.getItem('show-hidden') === null) { localStorage.setItem('show-hidden', 'true');