forked from open-webui/open-webui
		
	chore: layout refac
This commit is contained in:
		
							parent
							
								
									753327522a
								
							
						
					
					
						commit
						0996f3c216
					
				
					 7 changed files with 101 additions and 73 deletions
				
			
		|  | @ -22,7 +22,7 @@ | |||
| 	import toast from 'svelte-french-toast'; | ||||
| 	import { OLLAMA_API_BASE_URL, WEBUI_API_BASE_URL } from '$lib/constants'; | ||||
| 	import { getOllamaModels, getOllamaVersion } from '$lib/apis/ollama'; | ||||
| 	import { getOpenAIModels } from '$lib/apis'; | ||||
| 	import { getOpenAIModels } from '$lib/apis/openai'; | ||||
| 	import { | ||||
| 		createNewChat, | ||||
| 		deleteChatById, | ||||
|  |  | |||
|  | @ -2,54 +2,32 @@ | |||
| 	import { onMount, tick } from 'svelte'; | ||||
| 	import { config, user } from '$lib/stores'; | ||||
| 	import { goto } from '$app/navigation'; | ||||
| 	import { WEBUI_API_BASE_URL } from '$lib/constants'; | ||||
| 	import toast, { Toaster } from 'svelte-french-toast'; | ||||
| 
 | ||||
| 	import { getBackendConfig } from '$lib/apis'; | ||||
| 	import { getSessionUser } from '$lib/apis/auths'; | ||||
| 
 | ||||
| 	import '../app.css'; | ||||
| 	import '../tailwind.css'; | ||||
| 	import 'tippy.js/dist/tippy.css'; | ||||
| 
 | ||||
| 	let loaded = false; | ||||
| 
 | ||||
| 	onMount(async () => { | ||||
| 		// Check Backend Status | ||||
| 		const res = await fetch(`${WEBUI_API_BASE_URL}/`, { | ||||
| 			method: 'GET', | ||||
| 			headers: { | ||||
| 				'Content-Type': 'application/json' | ||||
| 			} | ||||
| 		}) | ||||
| 			.then(async (res) => { | ||||
| 				if (!res.ok) throw await res.json(); | ||||
| 				return res.json(); | ||||
| 			}) | ||||
| 			.catch((error) => { | ||||
| 				console.log(error); | ||||
| 				return null; | ||||
| 			}); | ||||
| 		const backendConfig = await getBackendConfig(); | ||||
| 
 | ||||
| 		if (res) { | ||||
| 			await config.set(res); | ||||
| 			console.log(res); | ||||
| 		if (backendConfig) { | ||||
| 			await config.set(backendConfig); | ||||
| 			console.log(backendConfig); | ||||
| 
 | ||||
| 			if ($config) { | ||||
| 				if (localStorage.token) { | ||||
| 					// Get Session User Info | ||||
| 					const sessionUser = await fetch(`${WEBUI_API_BASE_URL}/auths`, { | ||||
| 						method: 'GET', | ||||
| 						headers: { | ||||
| 							'Content-Type': 'application/json', | ||||
| 							Authorization: `Bearer ${localStorage.token}` | ||||
| 						} | ||||
| 					}) | ||||
| 						.then(async (res) => { | ||||
| 							if (!res.ok) throw await res.json(); | ||||
| 							return res.json(); | ||||
| 						}) | ||||
| 						.catch((error) => { | ||||
| 							console.log(error); | ||||
| 							toast.error(error.detail); | ||||
| 							return null; | ||||
| 						}); | ||||
| 					const sessionUser = await getSessionUser(localStorage.token).catch((error) => { | ||||
| 						toast.error(error); | ||||
| 						return null; | ||||
| 					}); | ||||
| 
 | ||||
| 					if (sessionUser) { | ||||
| 						await user.set(sessionUser); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek