Merge pull request #1269 from danielaskdd/main
Fix webui title display problem
This commit is contained in:
@@ -436,6 +436,8 @@ def create_app(args):
|
|||||||
"auth_mode": "enabled",
|
"auth_mode": "enabled",
|
||||||
"core_version": core_version,
|
"core_version": core_version,
|
||||||
"api_version": __api_version__,
|
"api_version": __api_version__,
|
||||||
|
"webui_title": webui_title,
|
||||||
|
"webui_description": webui_description,
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.get("/health", dependencies=[Depends(combined_auth)])
|
@app.get("/health", dependencies=[Depends(combined_auth)])
|
||||||
|
File diff suppressed because one or more lines are too long
2
lightrag/api/webui/index.html
generated
2
lightrag/api/webui/index.html
generated
@@ -8,7 +8,7 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="logo.png" />
|
<link rel="icon" type="image/svg+xml" href="logo.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Lightrag</title>
|
<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">
|
<link rel="stylesheet" crossorigin href="/webui/assets/index-f0HMqdqP.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@@ -63,14 +63,16 @@ function App() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const status = await getAuthStatus();
|
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;
|
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(
|
useAuthStore.getState().login(
|
||||||
token,
|
token,
|
||||||
isGuestMode,
|
isGuestMode,
|
||||||
status.core_version,
|
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
|
// Set flag to indicate version info has been checked
|
||||||
|
@@ -3,7 +3,6 @@ import { backendBaseUrl } from '@/lib/constants'
|
|||||||
import { errorMessage } from '@/lib/utils'
|
import { errorMessage } from '@/lib/utils'
|
||||||
import { useSettingsStore } from '@/stores/settings'
|
import { useSettingsStore } from '@/stores/settings'
|
||||||
import { navigationService } from '@/services/navigation'
|
import { navigationService } from '@/services/navigation'
|
||||||
import { useAuthStore } from '@/stores/state'
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
export type LightragNodeType = {
|
export type LightragNodeType = {
|
||||||
@@ -426,26 +425,12 @@ export const getAuthStatus = async (): Promise<AuthStatusResponse> => {
|
|||||||
// For unconfigured auth, ensure we have an access token
|
// For unconfigured auth, ensure we have an access token
|
||||||
if (!response.data.auth_configured) {
|
if (!response.data.auth_configured) {
|
||||||
if (response.data.access_token && typeof response.data.access_token === 'string') {
|
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;
|
return response.data;
|
||||||
} else {
|
} else {
|
||||||
console.warn('Auth not configured but no valid access token provided');
|
console.warn('Auth not configured but no valid access token provided');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// For configured auth, just return the data
|
// 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;
|
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;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ const LoginPage = () => {
|
|||||||
|
|
||||||
if (!status.auth_configured && status.access_token) {
|
if (!status.auth_configured && status.access_token) {
|
||||||
// If auth is not configured, use the guest token and redirect
|
// 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) {
|
if (status.message) {
|
||||||
toast.info(status.message)
|
toast.info(status.message)
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ const LoginPage = () => {
|
|||||||
|
|
||||||
// Check authentication mode
|
// Check authentication mode
|
||||||
const isGuestMode = response.auth_mode === 'disabled'
|
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
|
// Set session flag for version check
|
||||||
if (response.core_version || response.api_version) {
|
if (response.core_version || response.api_version) {
|
||||||
|
@@ -171,11 +171,17 @@ export const useAuthStore = create<AuthState>(set => {
|
|||||||
if (apiVersion) {
|
if (apiVersion) {
|
||||||
localStorage.setItem('LIGHTRAG-API-VERSION', apiVersion);
|
localStorage.setItem('LIGHTRAG-API-VERSION', apiVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (webuiTitle) {
|
if (webuiTitle) {
|
||||||
localStorage.setItem('LIGHTRAG-WEBUI-TITLE', webuiTitle);
|
localStorage.setItem('LIGHTRAG-WEBUI-TITLE', webuiTitle);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('LIGHTRAG-WEBUI-TITLE');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (webuiDescription) {
|
if (webuiDescription) {
|
||||||
localStorage.setItem('LIGHTRAG-WEBUI-DESCRIPTION', webuiDescription);
|
localStorage.setItem('LIGHTRAG-WEBUI-DESCRIPTION', webuiDescription);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('LIGHTRAG-WEBUI-DESCRIPTION');
|
||||||
}
|
}
|
||||||
|
|
||||||
const username = getUsernameFromToken(token);
|
const username = getUsernameFromToken(token);
|
||||||
|
Reference in New Issue
Block a user