refactor rect selection to make it work in shares
This commit is contained in:
@@ -7,6 +7,7 @@ definePageMeta({
|
||||
layout: 'share',
|
||||
});
|
||||
|
||||
const selectionRect = useSelectionRect();
|
||||
const warrenStore = useWarrenStore();
|
||||
const route = useRoute();
|
||||
|
||||
@@ -96,12 +97,13 @@ async function loadFiles() {
|
||||
}
|
||||
|
||||
async function onEntryClicked(entry: DirectoryEntry, event: MouseEvent) {
|
||||
event.stopPropagation();
|
||||
|
||||
if (warrenStore.current == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.ctrlKey) {
|
||||
warrenStore.toggleSelection(entry);
|
||||
if (warrenStore.handleSelectionClick(entry, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -171,7 +173,7 @@ function onEntryDownload(entry: DirectoryEntry) {
|
||||
);
|
||||
} else {
|
||||
downloadName = 'download.zip';
|
||||
const paths = Array.from(warrenStore.selection).map((entry) =>
|
||||
const paths = Array.from(warrenStore.selection.values()).map((entry) =>
|
||||
joinPaths(warrenStore.current!.path, entry.name)
|
||||
);
|
||||
|
||||
@@ -182,12 +184,22 @@ function onEntryDownload(entry: DirectoryEntry) {
|
||||
|
||||
downloadFile(downloadName, downloadApiUrl);
|
||||
}
|
||||
|
||||
function onParentClick() {
|
||||
if (selectionRect.dirty) {
|
||||
selectionRect.dirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
warrenStore.clearSelection();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="share != null"
|
||||
class="flex h-full w-full items-center justify-center px-2"
|
||||
@click="onParentClick"
|
||||
>
|
||||
<div
|
||||
:class="[
|
||||
|
||||
Reference in New Issue
Block a user