Add title support for webui

This commit is contained in:
yangdx
2025-04-04 22:51:07 +08:00
parent d5da79892f
commit 29d01e1c74
4 changed files with 113 additions and 12 deletions

View File

@@ -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<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 (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;
}