mirror of
https://github.com/open-webui/open-webui
synced 2025-04-06 05:35:55 +00:00
refac
This commit is contained in:
parent
a3f2b7045c
commit
3516eea189
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { onMount, tick, getContext, createEventDispatcher } from 'svelte';
|
import { onMount, tick, getContext, createEventDispatcher, onDestroy } from 'svelte';
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -175,10 +175,6 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
window.setTimeout(() => chatTextAreaElement?.focus(), 0);
|
|
||||||
|
|
||||||
const dropZone = document.getElementById('chat-container');
|
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
if (event.key === 'Escape') {
|
if (event.key === 'Escape') {
|
||||||
console.log('Escape');
|
console.log('Escape');
|
||||||
@ -212,19 +208,26 @@
|
|||||||
dragged = false;
|
dragged = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
window.setTimeout(() => chatTextAreaElement?.focus(), 0);
|
||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
window.addEventListener('keydown', handleKeyDown);
|
||||||
|
|
||||||
|
const dropZone = document.getElementById('chat-container');
|
||||||
|
|
||||||
dropZone?.addEventListener('dragover', onDragOver);
|
dropZone?.addEventListener('dragover', onDragOver);
|
||||||
dropZone?.addEventListener('drop', onDrop);
|
dropZone?.addEventListener('drop', onDrop);
|
||||||
dropZone?.addEventListener('dragleave', onDragLeave);
|
dropZone?.addEventListener('dragleave', onDragLeave);
|
||||||
|
});
|
||||||
|
|
||||||
return () => {
|
onDestroy(() => {
|
||||||
window.removeEventListener('keydown', handleKeyDown);
|
window.removeEventListener('keydown', handleKeyDown);
|
||||||
|
|
||||||
|
const dropZone = document.getElementById('chat-container');
|
||||||
|
|
||||||
dropZone?.removeEventListener('dragover', onDragOver);
|
dropZone?.removeEventListener('dragover', onDragOver);
|
||||||
dropZone?.removeEventListener('drop', onDrop);
|
dropZone?.removeEventListener('drop', onDrop);
|
||||||
dropZone?.removeEventListener('dragleave', onDragLeave);
|
dropZone?.removeEventListener('dragleave', onDragLeave);
|
||||||
};
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user