mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
c03ca7270e
commit
b53ddfbd19
6 changed files with 71 additions and 36 deletions
|
|
@ -1363,6 +1363,7 @@
|
||||||
<div class=" flex justify-between mt-0.5 mb-2.5 mx-0.5 max-w-full" dir="ltr">
|
<div class=" flex justify-between mt-0.5 mb-2.5 mx-0.5 max-w-full" dir="ltr">
|
||||||
<div class="ml-1 self-end flex items-center flex-1 max-w-[80%]">
|
<div class="ml-1 self-end flex items-center flex-1 max-w-[80%]">
|
||||||
<InputMenu
|
<InputMenu
|
||||||
|
bind:files
|
||||||
selectedModels={atSelectedModel ? [atSelectedModel.id] : selectedModels}
|
selectedModels={atSelectedModel ? [atSelectedModel.id] : selectedModels}
|
||||||
{fileUploadCapableModels}
|
{fileUploadCapableModels}
|
||||||
{screenCaptureHandler}
|
{screenCaptureHandler}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
export let selectedToolIds: string[] = [];
|
export let files = [];
|
||||||
|
|
||||||
export let selectedModels: string[] = [];
|
export let selectedModels: string[] = [];
|
||||||
export let fileUploadCapableModels: string[] = [];
|
export let fileUploadCapableModels: string[] = [];
|
||||||
|
|
@ -54,13 +54,28 @@
|
||||||
return /android|iphone|ipad|ipod|windows phone/i.test(userAgent);
|
return /android|iphone|ipad|ipod|windows phone/i.test(userAgent);
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleFileChange(event) {
|
const handleFileChange = (event) => {
|
||||||
const inputFiles = Array.from(event.target?.files);
|
const inputFiles = Array.from(event.target?.files);
|
||||||
if (inputFiles && inputFiles.length > 0) {
|
if (inputFiles && inputFiles.length > 0) {
|
||||||
console.log(inputFiles);
|
console.log(inputFiles);
|
||||||
inputFilesHandler(inputFiles);
|
inputFilesHandler(inputFiles);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSelect = (item) => {
|
||||||
|
if (files.find((f) => f.id === item.id)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
files = [
|
||||||
|
...files,
|
||||||
|
{
|
||||||
|
...item,
|
||||||
|
status: 'processed'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
show = false;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Hidden file input used to open the camera on mobile -->
|
<!-- Hidden file input used to open the camera on mobile -->
|
||||||
|
|
@ -422,7 +437,7 @@
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<Knowledge knowledge={$knowledge ?? []} />
|
<Knowledge knowledge={$knowledge ?? []} {onSelect} />
|
||||||
</div>
|
</div>
|
||||||
{:else if tab === 'notes'}
|
{:else if tab === 'notes'}
|
||||||
<div in:fly={{ x: 20, duration: 150 }}>
|
<div in:fly={{ x: 20, duration: 150 }}>
|
||||||
|
|
@ -441,7 +456,7 @@
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<Notes />
|
<Notes {onSelect} />
|
||||||
</div>
|
</div>
|
||||||
{:else if tab === 'chats'}
|
{:else if tab === 'chats'}
|
||||||
<div in:fly={{ x: 20, duration: 150 }}>
|
<div in:fly={{ x: 20, duration: 150 }}>
|
||||||
|
|
@ -460,7 +475,7 @@
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<Chats />
|
<Chats {onSelect} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||||
import Loader from '$lib/components/common/Loader.svelte';
|
import Loader from '$lib/components/common/Loader.svelte';
|
||||||
|
import { chatId } from '$lib/stores';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
|
@ -70,6 +71,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-col gap-0.5">
|
<div class="flex flex-col gap-0.5">
|
||||||
{#each items as item, idx}
|
{#each items as item, idx}
|
||||||
|
{#if item?.id !== $chatId}
|
||||||
<button
|
<button
|
||||||
class=" px-2.5 py-1 rounded-xl w-full text-left flex justify-between items-center text-sm {idx ===
|
class=" px-2.5 py-1 rounded-xl w-full text-left flex justify-between items-center text-sm {idx ===
|
||||||
selectedIdx
|
selectedIdx
|
||||||
|
|
@ -97,6 +99,7 @@
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
{#if !allItemsLoaded}
|
{#if !allItemsLoaded}
|
||||||
|
|
|
||||||
|
|
@ -668,7 +668,7 @@
|
||||||
name={file.name}
|
name={file.name}
|
||||||
type={file.type}
|
type={file.type}
|
||||||
size={file?.size}
|
size={file?.size}
|
||||||
colorClassName="bg-white dark:bg-gray-850 "
|
small={true}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@
|
||||||
name={file.name}
|
name={file.name}
|
||||||
type={file.type}
|
type={file.type}
|
||||||
size={file?.size}
|
size={file?.size}
|
||||||
colorClassName="bg-white dark:bg-gray-850 "
|
small={true}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
import DocumentPage from '../icons/DocumentPage.svelte';
|
import DocumentPage from '../icons/DocumentPage.svelte';
|
||||||
import Database from '../icons/Database.svelte';
|
import Database from '../icons/Database.svelte';
|
||||||
|
import PageEdit from '../icons/PageEdit.svelte';
|
||||||
|
import ChatBubble from '../icons/ChatBubble.svelte';
|
||||||
let showModal = false;
|
let showModal = false;
|
||||||
|
|
||||||
const decodeString = (str: string) => {
|
const decodeString = (str: string) => {
|
||||||
|
|
@ -96,11 +98,23 @@
|
||||||
<div class="pl-1">
|
<div class="pl-1">
|
||||||
{#if !loading}
|
{#if !loading}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={type === 'collection' ? $i18n.t('Collection') : $i18n.t('Document')}
|
content={type === 'collection'
|
||||||
|
? $i18n.t('Collection')
|
||||||
|
: type === 'note'
|
||||||
|
? $i18n.t('Note')
|
||||||
|
: type === 'chat'
|
||||||
|
? $i18n.t('Chat')
|
||||||
|
: type === 'file'
|
||||||
|
? $i18n.t('File')
|
||||||
|
: $i18n.t('Document')}
|
||||||
placement="top"
|
placement="top"
|
||||||
>
|
>
|
||||||
{#if type === 'collection'}
|
{#if type === 'collection'}
|
||||||
<Database />
|
<Database />
|
||||||
|
{:else if type === 'note'}
|
||||||
|
<PageEdit />
|
||||||
|
{:else if type === 'chat'}
|
||||||
|
<ChatBubble />
|
||||||
{:else}
|
{:else}
|
||||||
<DocumentPage />
|
<DocumentPage />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -124,6 +138,8 @@
|
||||||
>
|
>
|
||||||
{#if type === 'file'}
|
{#if type === 'file'}
|
||||||
{$i18n.t('File')}
|
{$i18n.t('File')}
|
||||||
|
{:else if type === 'note'}
|
||||||
|
{$i18n.t('Note')}
|
||||||
{:else if type === 'doc'}
|
{:else if type === 'doc'}
|
||||||
{$i18n.t('Document')}
|
{$i18n.t('Document')}
|
||||||
{:else if type === 'collection'}
|
{:else if type === 'collection'}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue