mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-13 23:14:11 +00:00
refac
This commit is contained in:
parent
199490eadb
commit
e112a5252f
1 changed files with 0 additions and 81 deletions
|
|
@ -1,9 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { onMount, tick, getContext } from 'svelte';
|
||||
import { openDB, deleteDB } from 'idb';
|
||||
import fileSaver from 'file-saver';
|
||||
const { saveAs } = fileSaver;
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
|
|
@ -54,8 +51,6 @@
|
|||
const i18n = getContext('i18n');
|
||||
|
||||
let loaded = false;
|
||||
let DB = null;
|
||||
let localDBChats = [];
|
||||
|
||||
let version;
|
||||
let handledSettingsUrl = '';
|
||||
|
|
@ -69,26 +64,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
const checkLocalDBChats = async () => {
|
||||
try {
|
||||
// Check if IndexedDB exists
|
||||
DB = await openDB('Chats', 1);
|
||||
|
||||
if (!DB) {
|
||||
return;
|
||||
}
|
||||
|
||||
const chats = await DB.getAllFromIndex('chats', 'timestamp');
|
||||
localDBChats = chats.map((item, idx) => chats[chats.length - 1 - idx]);
|
||||
|
||||
if (localDBChats.length === 0) {
|
||||
await deleteDB('Chats');
|
||||
}
|
||||
} catch (error) {
|
||||
// IndexedDB Not Found
|
||||
}
|
||||
};
|
||||
|
||||
const setUserSettings = async (cb?: () => Promise<void>) => {
|
||||
const userSettings = await getUserSettings(localStorage.token);
|
||||
|
||||
|
|
@ -247,7 +222,6 @@
|
|||
clearChatInputStorage();
|
||||
try {
|
||||
await Promise.all([
|
||||
checkLocalDBChats(),
|
||||
setBanners().catch((e) => console.error('Failed to load banners:', e)),
|
||||
setTools().catch((e) => console.error('Failed to load tools:', e)),
|
||||
setUserSettings(async () => {
|
||||
|
|
@ -471,61 +445,6 @@
|
|||
{#if !['user', 'admin'].includes($user?.role)}
|
||||
<AccountPending />
|
||||
{:else}
|
||||
{#if localDBChats.length > 0}
|
||||
<div class="fixed w-full h-full flex z-50">
|
||||
<div
|
||||
class="absolute w-full h-full backdrop-blur-md bg-white/20 dark:bg-gray-900/50 flex justify-center"
|
||||
>
|
||||
<div class="m-auto pb-44 flex flex-col justify-center">
|
||||
<div class="max-w-md">
|
||||
<div class="text-center dark:text-white text-2xl font-normal z-50">
|
||||
{$i18n.t('Important Update')}<br />
|
||||
{$i18n.t('Action Required for Chat Log Storage')}
|
||||
</div>
|
||||
|
||||
<div class=" mt-4 text-center text-sm dark:text-gray-200 w-full">
|
||||
{$i18n.t(
|
||||
"Saving chat logs directly to your browser's storage is no longer supported. Please take a moment to download and delete your chat logs by clicking the button below. Don't worry, you can easily re-import your chat logs to the backend through"
|
||||
)}
|
||||
<span class="font-normal dark:text-white"
|
||||
>{$i18n.t('Settings')} > {$i18n.t('Chats')} > {$i18n.t('Import Chats')}</span
|
||||
>. {$i18n.t(
|
||||
'This ensures that your valuable conversations are securely saved to your backend database. Thank you!'
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div class=" mt-6 mx-auto relative group w-fit">
|
||||
<button
|
||||
class="relative z-20 flex px-5 py-2 rounded-full bg-white border border-gray-100 dark:border-none hover:bg-gray-100 transition font-normal text-sm"
|
||||
on:click={async () => {
|
||||
let blob = new Blob([JSON.stringify(localDBChats)], {
|
||||
type: 'application/json'
|
||||
});
|
||||
saveAs(blob, `chat-export-${Date.now()}.json`);
|
||||
|
||||
const tx = DB.transaction('chats', 'readwrite');
|
||||
await Promise.all([tx.store.clear(), tx.done]);
|
||||
await deleteDB('Chats');
|
||||
|
||||
localDBChats = [];
|
||||
}}
|
||||
>
|
||||
{$i18n.t('Download & Delete')}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="text-xs text-center w-full mt-2 text-gray-400 underline"
|
||||
on:click={async () => {
|
||||
localDBChats = [];
|
||||
}}>{$i18n.t('Close')}</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<Sidebar />
|
||||
|
||||
{#if loaded}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue