mirror of
https://github.com/open-webui/open-webui
synced 2024-11-25 21:38:43 +00:00
refac: dropzone
This commit is contained in:
parent
d4388a53f4
commit
a47ebd468e
@ -236,8 +236,14 @@
|
|||||||
dragged = false;
|
dragged = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let dropzoneElement;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await tools.set(await getTools(localStorage.token));
|
console.log('hi');
|
||||||
|
|
||||||
|
if (!$tools) {
|
||||||
|
await tools.set(await getTools(localStorage.token));
|
||||||
|
}
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
@ -248,24 +254,29 @@
|
|||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
window.addEventListener('keydown', handleKeyDown);
|
||||||
|
|
||||||
const dropZone = document.getElementById('chat-container');
|
if (dropzoneElement) {
|
||||||
|
dropzoneElement?.addEventListener('dragover', onDragOver);
|
||||||
dropZone?.addEventListener('dragover', onDragOver);
|
dropzoneElement?.addEventListener('drop', onDrop);
|
||||||
dropZone?.addEventListener('drop', onDrop);
|
dropzoneElement?.addEventListener('dragleave', onDragLeave);
|
||||||
dropZone?.addEventListener('dragleave', onDragLeave);
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
console.log('destroy');
|
||||||
window.removeEventListener('keydown', handleKeyDown);
|
window.removeEventListener('keydown', handleKeyDown);
|
||||||
|
|
||||||
const dropZone = document.getElementById('chat-container');
|
if (dropzoneElement) {
|
||||||
|
dropzoneElement?.removeEventListener('dragover', onDragOver);
|
||||||
dropZone?.removeEventListener('dragover', onDragOver);
|
dropzoneElement?.removeEventListener('drop', onDrop);
|
||||||
dropZone?.removeEventListener('drop', onDrop);
|
dropzoneElement?.removeEventListener('dragleave', onDragLeave);
|
||||||
dropZone?.removeEventListener('dragleave', onDragLeave);
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="absolute top-0 bottom-0 left-0 right-0 w-full h-full touch-none pointer-events-none"
|
||||||
|
bind:this={dropzoneElement}
|
||||||
|
></div>
|
||||||
<FilesOverlay show={dragged} />
|
<FilesOverlay show={dragged} />
|
||||||
|
|
||||||
{#if loaded}
|
{#if loaded}
|
||||||
|
Loading…
Reference in New Issue
Block a user