Refactor navigation and authentication flow
- Move navigation setup to AppRouter - Prevent protected route logic to handle login 401
This commit is contained in:
@@ -5,11 +5,9 @@ import MessageAlert from '@/components/MessageAlert'
|
||||
import ApiKeyAlert from '@/components/ApiKeyAlert'
|
||||
import StatusIndicator from '@/components/graph/StatusIndicator'
|
||||
import { healthCheckInterval } from '@/lib/constants'
|
||||
import { useBackendState, useAuthStore } from '@/stores/state'
|
||||
import { useBackendState } from '@/stores/state'
|
||||
import { useSettingsStore } from '@/stores/settings'
|
||||
import { useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { navigationService } from '@/services/navigation'
|
||||
import SiteHeader from '@/features/SiteHeader'
|
||||
import { InvalidApiKeyError, RequireApiKeError } from '@/api/lightrag'
|
||||
|
||||
@@ -21,22 +19,13 @@ import ApiSite from '@/features/ApiSite'
|
||||
import { Tabs, TabsContent } from '@/components/ui/Tabs'
|
||||
|
||||
function App() {
|
||||
const navigate = useNavigate();
|
||||
const message = useBackendState.use.message()
|
||||
|
||||
// Initialize navigation service
|
||||
useEffect(() => {
|
||||
navigationService.setNavigate(navigate);
|
||||
}, [navigate]);
|
||||
const enableHealthCheck = useSettingsStore.use.enableHealthCheck()
|
||||
const currentTab = useSettingsStore.use.currentTab()
|
||||
const [apiKeyInvalid, setApiKeyInvalid] = useState(false)
|
||||
|
||||
// Health check
|
||||
useEffect(() => {
|
||||
const { isAuthenticated } = useAuthStore.getState();
|
||||
if (!enableHealthCheck || !isAuthenticated) return
|
||||
|
||||
// Check immediately
|
||||
useBackendState.getState().check()
|
||||
|
||||
|
Reference in New Issue
Block a user