From 29d01e1c746e1558c52f704bcc42b885992391cd Mon Sep 17 00:00:00 2001 From: yangdx Date: Fri, 4 Apr 2025 22:51:07 +0800 Subject: [PATCH] Add title support for webui --- env.example | 4 +- lightrag_webui/src/api/lightrag.ts | 29 +++++++++++ lightrag_webui/src/features/SiteHeader.tsx | 34 ++++++++++--- lightrag_webui/src/stores/state.ts | 58 ++++++++++++++++++++-- 4 files changed, 113 insertions(+), 12 deletions(-) diff --git a/env.example b/env.example index 2a6fb3d7..d21bbef6 100644 --- a/env.example +++ b/env.example @@ -5,8 +5,8 @@ # PORT=9621 # WORKERS=2 # CORS_ORIGINS=http://localhost:3000,http://localhost:8080 -# WEBUI_TITLE='My Best RAG System' -# WEBUI_DESCRIPTION="My Knowledge System Based on LightRAG" +WEBUI_TITLE='Graph RAG Engine' +WEBUI_DESCRIPTION="Simple and Fast Graph Based RAG System" ### Optional SSL Configuration # SSL=true diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index 5a68851c..6892cc14 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -3,6 +3,7 @@ import { backendBaseUrl } from '@/lib/constants' import { errorMessage } from '@/lib/utils' import { useSettingsStore } from '@/stores/settings' import { navigationService } from '@/services/navigation' +import { useAuthStore } from '@/stores/state' // Types export type LightragNodeType = { @@ -46,6 +47,8 @@ export type LightragStatus = { api_version?: string auth_mode?: 'enabled' | 'disabled' pipeline_busy: boolean + webui_title?: string + webui_description?: string } export type LightragDocumentsScanProgress = { @@ -140,6 +143,8 @@ export type AuthStatusResponse = { message?: string core_version?: string api_version?: string + webui_title?: string + webui_description?: string } export type PipelineStatusResponse = { @@ -163,6 +168,8 @@ export type LoginResponse = { message?: string // Optional message core_version?: string api_version?: string + webui_title?: string + webui_description?: string } export const InvalidApiKeyError = 'Invalid API Key' @@ -419,12 +426,26 @@ export const getAuthStatus = async (): Promise => { // For unconfigured auth, ensure we have an access token if (!response.data.auth_configured) { if (response.data.access_token && typeof response.data.access_token === 'string') { + // Update custom title if available + if (response.data.webui_title || response.data.webui_description) { + useAuthStore.getState().setCustomTitle( + response.data.webui_title || null, + response.data.webui_description || null + ); + } return response.data; } else { console.warn('Auth not configured but no valid access token provided'); } } else { // For configured auth, just return the data + // Update custom title if available + if (response.data.webui_title || response.data.webui_description) { + useAuthStore.getState().setCustomTitle( + response.data.webui_title || null, + response.data.webui_description || null + ); + } return response.data; } } @@ -463,5 +484,13 @@ export const loginToServer = async (username: string, password: string): Promise } }); + // Update custom title if available + if (response.data.webui_title || response.data.webui_description) { + useAuthStore.getState().setCustomTitle( + response.data.webui_title || null, + response.data.webui_description || null + ); + } + return response.data; } diff --git a/lightrag_webui/src/features/SiteHeader.tsx b/lightrag_webui/src/features/SiteHeader.tsx index 8077d390..4881e4b6 100644 --- a/lightrag_webui/src/features/SiteHeader.tsx +++ b/lightrag_webui/src/features/SiteHeader.tsx @@ -8,6 +8,7 @@ import { cn } from '@/lib/utils' import { useTranslation } from 'react-i18next' import { navigationService } from '@/services/navigation' import { ZapIcon, GithubIcon, LogOutIcon } from 'lucide-react' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/Tooltip' interface NavigationTabProps { value: string @@ -55,7 +56,7 @@ function TabsNavigation() { export default function SiteHeader() { const { t } = useTranslation() - const { isGuestMode, coreVersion, apiVersion, username } = useAuthStore() + const { isGuestMode, coreVersion, apiVersion, username, webuiTitle, webuiDescription } = useAuthStore() const versionDisplay = (coreVersion && apiVersion) ? `${coreVersion}/${apiVersion}` @@ -67,17 +68,31 @@ export default function SiteHeader() { return (
-
+
+ {webuiTitle && ( +
+ | + + + + + {webuiTitle} + + + {webuiDescription && ( + + {webuiDescription} + + )} + + +
+ )}
@@ -91,6 +106,11 @@ export default function SiteHeader() {