Merge pull request #1269 from danielaskdd/main

Fix webui title display problem
This commit is contained in:
Daniel.y
2025-04-05 02:43:47 +08:00
committed by GitHub
7 changed files with 44 additions and 57 deletions

View File

@@ -436,6 +436,8 @@ def create_app(args):
"auth_mode": "enabled",
"core_version": core_version,
"api_version": __api_version__,
"webui_title": webui_title,
"webui_description": webui_description,
}
@app.get("/health", dependencies=[Depends(combined_auth)])

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,7 @@
<link rel="icon" type="image/svg+xml" href="logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lightrag</title>
<script type="module" crossorigin src="/webui/assets/index-BaHKTcxB.js"></script>
<script type="module" crossorigin src="/webui/assets/index-D8Hd4VcS.js"></script>
<link rel="stylesheet" crossorigin href="/webui/assets/index-f0HMqdqP.css">
</head>
<body>

View File

@@ -63,14 +63,16 @@ function App() {
try {
const status = await getAuthStatus();
if (status.core_version || status.api_version) {
if (status.core_version || status.api_version || status.webui_title || status.webui_description) {
const isGuestMode = status.auth_mode === 'disabled' || useAuthStore.getState().isGuestMode;
// Update version info while maintaining login state
// Update version info and webui title while maintaining login state
useAuthStore.getState().login(
token,
isGuestMode,
status.core_version,
status.api_version
status.api_version,
status.webui_title || null,
status.webui_description || null
);
// Set flag to indicate version info has been checked

View File

@@ -3,7 +3,6 @@ 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 = {
@@ -426,26 +425,12 @@ export const getAuthStatus = async (): Promise<AuthStatusResponse> => {
// 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 ('webui_title' in response.data || 'webui_description' in response.data) {
useAuthStore.getState().setCustomTitle(
'webui_title' in response.data ? (response.data.webui_title ?? null) : null,
'webui_description' in response.data ? (response.data.webui_description ?? null) : 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 ('webui_title' in response.data || 'webui_description' in response.data) {
useAuthStore.getState().setCustomTitle(
'webui_title' in response.data ? (response.data.webui_title ?? null) : null,
'webui_description' in response.data ? (response.data.webui_description ?? null) : null
);
}
return response.data;
}
}
@@ -484,13 +469,5 @@ export const loginToServer = async (username: string, password: string): Promise
}
});
// Update custom title if available
if ('webui_title' in response.data || 'webui_description' in response.data) {
useAuthStore.getState().setCustomTitle(
'webui_title' in response.data ? (response.data.webui_title ?? null) : null,
'webui_description' in response.data ? (response.data.webui_description ?? null) : null
);
}
return response.data;
}

View File

@@ -51,7 +51,7 @@ const LoginPage = () => {
if (!status.auth_configured && status.access_token) {
// If auth is not configured, use the guest token and redirect
login(status.access_token, true, status.core_version, status.api_version)
login(status.access_token, true, status.core_version, status.api_version, status.webui_title || null, status.webui_description || null)
if (status.message) {
toast.info(status.message)
}
@@ -96,7 +96,7 @@ const LoginPage = () => {
// Check authentication mode
const isGuestMode = response.auth_mode === 'disabled'
login(response.access_token, isGuestMode, response.core_version, response.api_version)
login(response.access_token, isGuestMode, response.core_version, response.api_version, response.webui_title || null, response.webui_description || null)
// Set session flag for version check
if (response.core_version || response.api_version) {

View File

@@ -171,11 +171,17 @@ export const useAuthStore = create<AuthState>(set => {
if (apiVersion) {
localStorage.setItem('LIGHTRAG-API-VERSION', apiVersion);
}
if (webuiTitle) {
localStorage.setItem('LIGHTRAG-WEBUI-TITLE', webuiTitle);
} else {
localStorage.removeItem('LIGHTRAG-WEBUI-TITLE');
}
if (webuiDescription) {
localStorage.setItem('LIGHTRAG-WEBUI-DESCRIPTION', webuiDescription);
} else {
localStorage.removeItem('LIGHTRAG-WEBUI-DESCRIPTION');
}
const username = getUsernameFromToken(token);