mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 13:25:20 +00:00
modified: src/lib/components/layout/ImportChatsModal.svelte
This commit is contained in:
parent
2812f935e7
commit
241e955d12
1 changed files with 14 additions and 8 deletions
|
|
@ -46,7 +46,7 @@
|
||||||
fileName = file.name;
|
fileName = file.name;
|
||||||
try {
|
try {
|
||||||
const ext = file.name.split('.').pop()?.toLowerCase();
|
const ext = file.name.split('.').pop()?.toLowerCase();
|
||||||
let chats = null;
|
let chats: any = null;
|
||||||
|
|
||||||
if (ext === 'txt') {
|
if (ext === 'txt') {
|
||||||
chats = await parseTxtAsJson(file);
|
chats = await parseTxtAsJson(file);
|
||||||
|
|
@ -55,11 +55,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getImportOrigin(chats) === 'openai') {
|
if (getImportOrigin(chats) === 'openai') {
|
||||||
try {
|
|
||||||
chats = convertOpenAIChats(chats);
|
chats = convertOpenAIChats(chats);
|
||||||
} catch (error) {
|
|
||||||
throw new Error('Failed to convert OpenAI chats');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(chats)) {
|
if (!Array.isArray(chats)) {
|
||||||
|
|
@ -141,6 +137,16 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
let fileInputEl: HTMLInputElement;
|
let fileInputEl: HTMLInputElement;
|
||||||
|
|
||||||
|
const handleFileInputChange = (event: Event) => {
|
||||||
|
const input = event.currentTarget as HTMLInputElement;
|
||||||
|
handleFiles(input.files ?? []);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectAllChange = (event: Event) => {
|
||||||
|
const input = event.currentTarget as HTMLInputElement;
|
||||||
|
toggleSelectAll(input.checked);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:show size="xl" className="bg-white/95 dark:bg-gray-900/95 rounded-4xl p-1">
|
<Modal bind:show size="xl" className="bg-white/95 dark:bg-gray-900/95 rounded-4xl p-1">
|
||||||
|
|
@ -231,7 +237,7 @@
|
||||||
type="file"
|
type="file"
|
||||||
accept=".json,.zip,.txt,application/json"
|
accept=".json,.zip,.txt,application/json"
|
||||||
hidden
|
hidden
|
||||||
on:change={(e) => handleFiles((e.currentTarget as HTMLInputElement).files)}
|
on:change={handleFileInputChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -248,7 +254,7 @@
|
||||||
class="accent-blue-600"
|
class="accent-blue-600"
|
||||||
checked={rawChats.length > 0 && selectedIndices.size === rawChats.length}
|
checked={rawChats.length > 0 && selectedIndices.size === rawChats.length}
|
||||||
indeterminate={selectedIndices.size > 0 && selectedIndices.size < rawChats.length}
|
indeterminate={selectedIndices.size > 0 && selectedIndices.size < rawChats.length}
|
||||||
on:change={(e) => toggleSelectAll((e.currentTarget as HTMLInputElement).checked)}
|
on:change={handleSelectAllChange}
|
||||||
/>
|
/>
|
||||||
<span>全选 / 取消全选</span>
|
<span>全选 / 取消全选</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue