mirror of
https://github.com/samanhappy/mcphub.git
synced 2025-12-24 02:39:19 -05:00
feat: add VITE_BASE_PATH environment variable and update routing in App component (#130)
This commit is contained in:
@@ -18,6 +18,9 @@ RUN npm install -g pnpm
|
||||
ARG REQUEST_TIMEOUT=60000
|
||||
ENV REQUEST_TIMEOUT=$REQUEST_TIMEOUT
|
||||
|
||||
ARG VITE_BASE_PATH=""
|
||||
ENV VITE_BASE_PATH=$VITE_BASE_PATH
|
||||
|
||||
ENV PNPM_HOME=/usr/local/share/pnpm
|
||||
ENV PATH=$PNPM_HOME:$PATH
|
||||
RUN mkdir -p $PNPM_HOME && \
|
||||
|
||||
@@ -13,12 +13,20 @@ import SettingsPage from './pages/SettingsPage';
|
||||
import MarketPage from './pages/MarketPage';
|
||||
import LogsPage from './pages/LogsPage';
|
||||
|
||||
// Get base path from environment variable or default to empty string
|
||||
const getBasePath = (): string => {
|
||||
const basePath = import.meta.env.VITE_BASE_PATH || '';
|
||||
return basePath.startsWith('/') ? basePath : '';
|
||||
};
|
||||
|
||||
function App() {
|
||||
const basename = getBasePath();
|
||||
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<AuthProvider>
|
||||
<ToastProvider>
|
||||
<Router>
|
||||
<Router basename={basename}>
|
||||
<Routes>
|
||||
{/* 公共路由 */}
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
|
||||
1
frontend/src/vite-env.d.ts
vendored
1
frontend/src/vite-env.d.ts
vendored
@@ -3,6 +3,7 @@
|
||||
interface ImportMeta {
|
||||
readonly env: {
|
||||
readonly PACKAGE_VERSION: string;
|
||||
readonly VITE_BASE_PATH?: string; // Add base path environment variable
|
||||
// Add other custom env variables here if needed
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user