mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
refac
This commit is contained in:
parent
20f35d157b
commit
21366fa1b1
2 changed files with 26 additions and 22 deletions
|
|
@ -1560,7 +1560,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onOpen={(fileId) => openFileHandler(fileId)}
|
|
||||||
onDelete={(fileId) => {
|
onDelete={(fileId) => {
|
||||||
selectedFileId = null;
|
selectedFileId = null;
|
||||||
selectedFile = null;
|
selectedFile = null;
|
||||||
|
|
@ -1624,8 +1623,18 @@
|
||||||
<ChevronLeft strokeWidth="2.5" />
|
<ChevronLeft strokeWidth="2.5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class=" flex-1 text-sm line-clamp-1">
|
<div class="flex-1 text-sm line-clamp-1">
|
||||||
{selectedFile?.meta?.name}
|
<a
|
||||||
|
href="#"
|
||||||
|
class="hover:underline line-clamp-1"
|
||||||
|
on:click|preventDefault={() => {
|
||||||
|
if (selectedFile?.id) {
|
||||||
|
openFileHandler(selectedFile.id);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{selectedFile?.meta?.name}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if knowledge?.write_access}
|
{#if knowledge?.write_access}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
import { capitalizeFirstLetter, formatFileSize } from '$lib/utils';
|
import { capitalizeFirstLetter, formatFileSize } from '$lib/utils';
|
||||||
|
import { WEBUI_BASE_URL } from '$lib/constants';
|
||||||
|
|
||||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||||
|
|
@ -45,7 +46,6 @@
|
||||||
export let directories = [];
|
export let directories = [];
|
||||||
|
|
||||||
export let onClick: (fileId: string | undefined) => void = () => {};
|
export let onClick: (fileId: string | undefined) => void = () => {};
|
||||||
export let onOpen: (fileId: string) => void = () => {};
|
|
||||||
export let onDelete: (fileId: string | undefined) => void = () => {};
|
export let onDelete: (fileId: string | undefined) => void = () => {};
|
||||||
export let onRename: (fileId: string, name: string) => void = () => {};
|
export let onRename: (fileId: string, name: string) => void = () => {};
|
||||||
export let onNavigateDirectory: (directoryId: string) => void = () => {};
|
export let onNavigateDirectory: (directoryId: string) => void = () => {};
|
||||||
|
|
@ -77,13 +77,6 @@
|
||||||
const cancelRename = () => {
|
const cancelRename = () => {
|
||||||
editingFileId = null;
|
editingFileId = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const openFile = (file: KnowledgeFile) => {
|
|
||||||
const fileId = file?.id ?? file?.tempId;
|
|
||||||
if (!fileId) return;
|
|
||||||
|
|
||||||
onOpen(fileId);
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class=" max-h-full flex flex-col w-full gap-[0.03125rem]" role="list">
|
<div class=" max-h-full flex flex-col w-full gap-[0.03125rem]" role="list">
|
||||||
|
|
@ -117,16 +110,15 @@
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
{#if file?.status !== 'uploading'}
|
{#if file?.status !== 'uploading'}
|
||||||
<Tooltip content={$i18n.t('Open file')}>
|
<button
|
||||||
<button
|
class="p-1 rounded-full transition"
|
||||||
class="p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-850 transition"
|
type="button"
|
||||||
type="button"
|
on:click={() => {
|
||||||
aria-label={$i18n.t('Open file')}
|
onClick(file?.id ?? file?.tempId);
|
||||||
on:click={() => openFile(file)}
|
}}
|
||||||
>
|
>
|
||||||
<DocumentPage className="size-3.5" />
|
<DocumentPage className="size-3.5" />
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
|
||||||
{:else}
|
{:else}
|
||||||
<Spinner className="size-3.5" />
|
<Spinner className="size-3.5" />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -228,7 +220,10 @@
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-xs transition hover:text-gray-900 dark:hover:text-gray-100"
|
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-xs transition hover:text-gray-900 dark:hover:text-gray-100"
|
||||||
on:click={() => openFile(file)}
|
on:click={() => {
|
||||||
|
let fileId = file?.id ?? file?.tempId;
|
||||||
|
window.open(`${WEBUI_BASE_URL}/api/v1/files/${fileId}/content`, '_blank');
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Download className="size-3.5" />
|
<Download className="size-3.5" />
|
||||||
{$i18n.t('Download')}
|
{$i18n.t('Download')}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue