Change to hash routing, webuiInitialize controls project prefix

This commit is contained in:
choizhang
2025-03-14 17:00:36 +08:00
parent 7bf2d51bd0
commit 10c23aabfd
11 changed files with 14 additions and 1147 deletions

View File

@@ -1,4 +1,4 @@
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import { HashRouter as Router, Routes, Route } from 'react-router-dom'
// import { useAuthStore } from '@/stores/state'
import { Toaster } from 'sonner'
import App from './App'
@@ -22,7 +22,7 @@ const ProtectedRoute = ({ children }: ProtectedRouteProps) => {
const AppRouter = () => {
return (
<ThemeProvider>
<BrowserRouter>
<Router>
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route
@@ -35,7 +35,7 @@ const AppRouter = () => {
/>
</Routes>
<Toaster position="top-center" />
</BrowserRouter>
</Router>
</ThemeProvider>
)
}

View File

@@ -1,5 +1,5 @@
import axios, { AxiosError } from 'axios'
import { backendBaseUrl } from '@/lib/constants'
import { backendBaseUrl, webuiPrefix } from '@/lib/constants'
import { errorMessage } from '@/lib/utils'
import { useSettingsStore } from '@/stores/settings'
import { useAuthStore } from '@/stores/state'
@@ -169,8 +169,8 @@ axiosInstance.interceptors.response.use(
sessionStorage.clear();
useAuthStore.getState().logout();
if (window.location.pathname !== '/login') {
window.location.href = '/login';
if (window.location.pathname !== `${webuiPrefix}/#/login`) {
window.location.href = `${webuiPrefix}/#/login`;
}
return Promise.reject(error);

View File

@@ -51,7 +51,7 @@ const LoginPage = () => {
<CardHeader className="flex items-center justify-center space-y-2 pb-8 pt-6">
<div className="flex flex-col items-center space-y-4">
<div className="flex items-center gap-3">
<img src="/logo.png" alt="LightRAG Logo" className="h-12 w-12" />
<img src="logo.png" alt="LightRAG Logo" className="h-12 w-12" />
<ZapIcon className="size-10 text-emerald-400" aria-hidden="true" />
</div>
<div className="text-center space-y-2">

View File

@@ -1,6 +1,7 @@
import { ButtonVariantType } from '@/components/ui/Button'
export const backendBaseUrl = ''
export const backendBaseUrl = 'http://localhost:9621/'
export const webuiPrefix = '/webui'
export const controlButtonVariant: ButtonVariantType = 'ghost'