From e3769c1073e3dffdd28228eadc044a7cf7e733b6 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 4 Mar 2025 01:16:08 -0800 Subject: [PATCH] refac --- backend/open_webui/main.py | 4 ++-- src/lib/components/OnBoarding.svelte | 29 ++++++++++++++++++++++++++- src/routes/auth/+page.svelte | 30 ++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 22a91dce5..1ee04df0d 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -420,7 +420,7 @@ oauth_manager = OAuthManager(app) app.state.config = AppConfig() app.state.WEBUI_NAME = WEBUI_NAME -app.state.LICENSE_DATA = None +app.state.LICENSE_METADATA = None ######################################## # @@ -1218,7 +1218,7 @@ async def get_app_config(request: Request): { "record_count": user_count, "active_entries": app.state.USER_COUNT, - "license_data": app.state.LICENSE_DATA, + "license_metadata": app.state.LICENSE_METADATA, } if user.role == "admin" else {} diff --git a/src/lib/components/OnBoarding.svelte b/src/lib/components/OnBoarding.svelte index e68a7f2c1..1976e5c6e 100644 --- a/src/lib/components/OnBoarding.svelte +++ b/src/lib/components/OnBoarding.svelte @@ -1,5 +1,5 @@ {#if show} @@ -18,6 +44,7 @@
import { toast } from 'svelte-sonner'; - import { onMount, getContext } from 'svelte'; + import { onMount, getContext, tick } from 'svelte'; import { goto } from '$app/navigation'; import { page } from '$app/stores'; @@ -115,6 +115,29 @@ let onboarding = false; + async function setLogoImage() { + await tick(); + const logo = document.getElementById('logo'); + + if (logo) { + const isDarkMode = document.documentElement.classList.contains('dark'); + + if (isDarkMode) { + const darkImage = new Image(); + darkImage.src = '/static/favicon-dark.png'; + + darkImage.onload = () => { + logo.src = '/static/favicon-dark.png'; + logo.style.filter = ''; // Ensure no inversion is applied if favicon-dark.png exists + }; + + darkImage.onerror = () => { + logo.style.filter = 'invert(1)'; // Invert image if favicon-dark.png is missing + }; + } + } + } + onMount(async () => { if ($user !== undefined) { await goto('/'); @@ -122,6 +145,8 @@ await checkOauthCallback(); loaded = true; + setLogoImage(); + if (($config?.features.auth_trusted_header ?? false) || $config?.features.auth === false) { await signInHandler(); } else { @@ -154,9 +179,10 @@