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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,14 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lightrag</title>
<script type="module" crossorigin src="./assets/index-CJz72b6Q.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-CH-3l4_Z.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

View File

@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.png" />
<link rel="icon" type="image/svg+xml" href="logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lightrag</title>
</head>

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'

View File

@@ -26,5 +26,5 @@
"@/*": ["./src/*"]
}
},
"include": ["src", "vite.config.ts"]
"include": ["src", "vite.config.ts", "src/vite-env.d.ts"]
}

View File

@@ -1,6 +1,6 @@
import { defineConfig } from 'vite'
import path from 'path'
import { webuiPrefix } from '@/lib/constants'
import react from '@vitejs/plugin-react-swc'
import tailwindcss from '@tailwindcss/vite'
@@ -12,7 +12,8 @@ export default defineConfig({
'@': path.resolve(__dirname, './src')
}
},
base: './',
// base: import.meta.env.VITE_BASE_URL || '/webui/',
base: webuiPrefix,
build: {
outDir: path.resolve(__dirname, '../lightrag/api/webui'),
emptyOutDir: true