yangdx
commited on
Commit
·
08aa15f
1
Parent(s):
9b50052
Fix webtitle display problem
Browse files
lightrag/api/lightrag_server.py
CHANGED
@@ -436,6 +436,8 @@ def create_app(args):
|
|
436 |
"auth_mode": "enabled",
|
437 |
"core_version": core_version,
|
438 |
"api_version": __api_version__,
|
|
|
|
|
439 |
}
|
440 |
|
441 |
@app.get("/health", dependencies=[Depends(combined_auth)])
|
|
|
436 |
"auth_mode": "enabled",
|
437 |
"core_version": core_version,
|
438 |
"api_version": __api_version__,
|
439 |
+
"webui_title": webui_title,
|
440 |
+
"webui_description": webui_description,
|
441 |
}
|
442 |
|
443 |
@app.get("/health", dependencies=[Depends(combined_auth)])
|
lightrag_webui/src/App.tsx
CHANGED
@@ -63,14 +63,16 @@ function App() {
|
|
63 |
|
64 |
try {
|
65 |
const status = await getAuthStatus();
|
66 |
-
if (status.core_version || status.api_version) {
|
67 |
const isGuestMode = status.auth_mode === 'disabled' || useAuthStore.getState().isGuestMode;
|
68 |
-
// Update version info while maintaining login state
|
69 |
useAuthStore.getState().login(
|
70 |
token,
|
71 |
isGuestMode,
|
72 |
status.core_version,
|
73 |
-
status.api_version
|
|
|
|
|
74 |
);
|
75 |
|
76 |
// Set flag to indicate version info has been checked
|
|
|
63 |
|
64 |
try {
|
65 |
const status = await getAuthStatus();
|
66 |
+
if (status.core_version || status.api_version || status.webui_title || status.webui_description) {
|
67 |
const isGuestMode = status.auth_mode === 'disabled' || useAuthStore.getState().isGuestMode;
|
68 |
+
// Update version info and webui title while maintaining login state
|
69 |
useAuthStore.getState().login(
|
70 |
token,
|
71 |
isGuestMode,
|
72 |
status.core_version,
|
73 |
+
status.api_version,
|
74 |
+
status.webui_title || null,
|
75 |
+
status.webui_description || null
|
76 |
);
|
77 |
|
78 |
// Set flag to indicate version info has been checked
|
lightrag_webui/src/api/lightrag.ts
CHANGED
@@ -3,7 +3,6 @@ import { backendBaseUrl } from '@/lib/constants'
|
|
3 |
import { errorMessage } from '@/lib/utils'
|
4 |
import { useSettingsStore } from '@/stores/settings'
|
5 |
import { navigationService } from '@/services/navigation'
|
6 |
-
import { useAuthStore } from '@/stores/state'
|
7 |
|
8 |
// Types
|
9 |
export type LightragNodeType = {
|
@@ -426,26 +425,12 @@ export const getAuthStatus = async (): Promise<AuthStatusResponse> => {
|
|
426 |
// For unconfigured auth, ensure we have an access token
|
427 |
if (!response.data.auth_configured) {
|
428 |
if (response.data.access_token && typeof response.data.access_token === 'string') {
|
429 |
-
// Update custom title if available
|
430 |
-
if ('webui_title' in response.data || 'webui_description' in response.data) {
|
431 |
-
useAuthStore.getState().setCustomTitle(
|
432 |
-
'webui_title' in response.data ? (response.data.webui_title ?? null) : null,
|
433 |
-
'webui_description' in response.data ? (response.data.webui_description ?? null) : null
|
434 |
-
);
|
435 |
-
}
|
436 |
return response.data;
|
437 |
} else {
|
438 |
console.warn('Auth not configured but no valid access token provided');
|
439 |
}
|
440 |
} else {
|
441 |
// For configured auth, just return the data
|
442 |
-
// Update custom title if available
|
443 |
-
if ('webui_title' in response.data || 'webui_description' in response.data) {
|
444 |
-
useAuthStore.getState().setCustomTitle(
|
445 |
-
'webui_title' in response.data ? (response.data.webui_title ?? null) : null,
|
446 |
-
'webui_description' in response.data ? (response.data.webui_description ?? null) : null
|
447 |
-
);
|
448 |
-
}
|
449 |
return response.data;
|
450 |
}
|
451 |
}
|
@@ -484,13 +469,5 @@ export const loginToServer = async (username: string, password: string): Promise
|
|
484 |
}
|
485 |
});
|
486 |
|
487 |
-
// Update custom title if available
|
488 |
-
if ('webui_title' in response.data || 'webui_description' in response.data) {
|
489 |
-
useAuthStore.getState().setCustomTitle(
|
490 |
-
'webui_title' in response.data ? (response.data.webui_title ?? null) : null,
|
491 |
-
'webui_description' in response.data ? (response.data.webui_description ?? null) : null
|
492 |
-
);
|
493 |
-
}
|
494 |
-
|
495 |
return response.data;
|
496 |
}
|
|
|
3 |
import { errorMessage } from '@/lib/utils'
|
4 |
import { useSettingsStore } from '@/stores/settings'
|
5 |
import { navigationService } from '@/services/navigation'
|
|
|
6 |
|
7 |
// Types
|
8 |
export type LightragNodeType = {
|
|
|
425 |
// For unconfigured auth, ensure we have an access token
|
426 |
if (!response.data.auth_configured) {
|
427 |
if (response.data.access_token && typeof response.data.access_token === 'string') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
return response.data;
|
429 |
} else {
|
430 |
console.warn('Auth not configured but no valid access token provided');
|
431 |
}
|
432 |
} else {
|
433 |
// For configured auth, just return the data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
return response.data;
|
435 |
}
|
436 |
}
|
|
|
469 |
}
|
470 |
});
|
471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
return response.data;
|
473 |
}
|
lightrag_webui/src/features/LoginPage.tsx
CHANGED
@@ -51,7 +51,7 @@ const LoginPage = () => {
|
|
51 |
|
52 |
if (!status.auth_configured && status.access_token) {
|
53 |
// If auth is not configured, use the guest token and redirect
|
54 |
-
login(status.access_token, true, status.core_version, status.api_version)
|
55 |
if (status.message) {
|
56 |
toast.info(status.message)
|
57 |
}
|
@@ -96,7 +96,7 @@ const LoginPage = () => {
|
|
96 |
|
97 |
// Check authentication mode
|
98 |
const isGuestMode = response.auth_mode === 'disabled'
|
99 |
-
login(response.access_token, isGuestMode, response.core_version, response.api_version)
|
100 |
|
101 |
// Set session flag for version check
|
102 |
if (response.core_version || response.api_version) {
|
|
|
51 |
|
52 |
if (!status.auth_configured && status.access_token) {
|
53 |
// If auth is not configured, use the guest token and redirect
|
54 |
+
login(status.access_token, true, status.core_version, status.api_version, status.webui_title || null, status.webui_description || null)
|
55 |
if (status.message) {
|
56 |
toast.info(status.message)
|
57 |
}
|
|
|
96 |
|
97 |
// Check authentication mode
|
98 |
const isGuestMode = response.auth_mode === 'disabled'
|
99 |
+
login(response.access_token, isGuestMode, response.core_version, response.api_version, response.webui_title || null, response.webui_description || null)
|
100 |
|
101 |
// Set session flag for version check
|
102 |
if (response.core_version || response.api_version) {
|
lightrag_webui/src/stores/state.ts
CHANGED
@@ -171,11 +171,17 @@ export const useAuthStore = create<AuthState>(set => {
|
|
171 |
if (apiVersion) {
|
172 |
localStorage.setItem('LIGHTRAG-API-VERSION', apiVersion);
|
173 |
}
|
|
|
174 |
if (webuiTitle) {
|
175 |
localStorage.setItem('LIGHTRAG-WEBUI-TITLE', webuiTitle);
|
|
|
|
|
176 |
}
|
|
|
177 |
if (webuiDescription) {
|
178 |
localStorage.setItem('LIGHTRAG-WEBUI-DESCRIPTION', webuiDescription);
|
|
|
|
|
179 |
}
|
180 |
|
181 |
const username = getUsernameFromToken(token);
|
|
|
171 |
if (apiVersion) {
|
172 |
localStorage.setItem('LIGHTRAG-API-VERSION', apiVersion);
|
173 |
}
|
174 |
+
|
175 |
if (webuiTitle) {
|
176 |
localStorage.setItem('LIGHTRAG-WEBUI-TITLE', webuiTitle);
|
177 |
+
} else {
|
178 |
+
localStorage.removeItem('LIGHTRAG-WEBUI-TITLE');
|
179 |
}
|
180 |
+
|
181 |
if (webuiDescription) {
|
182 |
localStorage.setItem('LIGHTRAG-WEBUI-DESCRIPTION', webuiDescription);
|
183 |
+
} else {
|
184 |
+
localStorage.removeItem('LIGHTRAG-WEBUI-DESCRIPTION');
|
185 |
}
|
186 |
|
187 |
const username = getUsernameFromToken(token);
|