Implemented version display in SiteHeader of webui
- Updated API version to 1.2.0 - Stored versions in localStorage
This commit is contained in:
@@ -19,7 +19,9 @@ interface BackendState {
|
||||
interface AuthState {
|
||||
isAuthenticated: boolean;
|
||||
isGuestMode: boolean; // Add guest mode flag
|
||||
login: (token: string, isGuest?: boolean) => void;
|
||||
coreVersion: string | null;
|
||||
apiVersion: string | null;
|
||||
login: (token: string, isGuest?: boolean, coreVersion?: string | null, apiVersion?: string | null) => void;
|
||||
logout: () => void;
|
||||
}
|
||||
|
||||
@@ -84,15 +86,22 @@ const isGuestToken = (token: string): boolean => {
|
||||
};
|
||||
|
||||
// Initialize auth state from localStorage
|
||||
const initAuthState = (): { isAuthenticated: boolean; isGuestMode: boolean } => {
|
||||
const initAuthState = (): { isAuthenticated: boolean; isGuestMode: boolean; coreVersion: string | null; apiVersion: string | null } => {
|
||||
const token = localStorage.getItem('LIGHTRAG-API-TOKEN');
|
||||
if (!token) {
|
||||
return { isAuthenticated: false, isGuestMode: false };
|
||||
return {
|
||||
isAuthenticated: false,
|
||||
isGuestMode: false,
|
||||
coreVersion: null,
|
||||
apiVersion: null
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
isAuthenticated: true,
|
||||
isGuestMode: isGuestToken(token)
|
||||
isGuestMode: isGuestToken(token),
|
||||
coreVersion: localStorage.getItem('LIGHTRAG-CORE-VERSION'),
|
||||
apiVersion: localStorage.getItem('LIGHTRAG-API-VERSION')
|
||||
};
|
||||
};
|
||||
|
||||
@@ -103,20 +112,36 @@ export const useAuthStore = create<AuthState>(set => {
|
||||
return {
|
||||
isAuthenticated: initialState.isAuthenticated,
|
||||
isGuestMode: initialState.isGuestMode,
|
||||
coreVersion: initialState.coreVersion,
|
||||
apiVersion: initialState.apiVersion,
|
||||
|
||||
login: (token, isGuest = false) => {
|
||||
login: (token, isGuest = false, coreVersion = null, apiVersion = null) => {
|
||||
localStorage.setItem('LIGHTRAG-API-TOKEN', token);
|
||||
|
||||
// 存储版本信息到 localStorage
|
||||
if (coreVersion) {
|
||||
localStorage.setItem('LIGHTRAG-CORE-VERSION', coreVersion);
|
||||
}
|
||||
if (apiVersion) {
|
||||
localStorage.setItem('LIGHTRAG-API-VERSION', apiVersion);
|
||||
}
|
||||
|
||||
set({
|
||||
isAuthenticated: true,
|
||||
isGuestMode: isGuest
|
||||
isGuestMode: isGuest,
|
||||
coreVersion,
|
||||
apiVersion
|
||||
});
|
||||
},
|
||||
|
||||
logout: () => {
|
||||
localStorage.removeItem('LIGHTRAG-API-TOKEN');
|
||||
|
||||
set({
|
||||
isAuthenticated: false,
|
||||
isGuestMode: false
|
||||
isGuestMode: false,
|
||||
coreVersion: null,
|
||||
apiVersion: null
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user