Fix webtitle display problem
This commit is contained in:
@@ -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)])
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user