Skip to content

Commit 2d34b33

Browse files
frant1cfrant1c
authored andcommitted
fix: change router
1 parent f6bb239 commit 2d34b33

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"homepage": "https://frant1cc.github.io/RandomInterview",
77
"scripts": {
88
"dev": "vite",
9-
"build": "tsc -b && vite build",
9+
"build": "tsc && vite build",
1010
"preview": "vite preview",
11-
"predeploy": "npm run build && cp public/.nojekyll dist/.nojekyll",
11+
"predeploy": "npm run build",
1212
"deploy": "gh-pages -d dist"
1313
},
1414
"dependencies": {

src/App.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import {
55
NavigationMenuList,
66
NavigationMenuTrigger
77
} from "@/components/ui/navigation-menu"
8-
import { HashRouter as Router, Routes, Route, Link, Navigate } from "react-router"
8+
import { HashRouter as Routes, Route, Link, Navigate } from "react-router"
99
import Home from "./pages/home"
1010
import Start from "./pages/start"
1111

1212
function App() {
1313
return (
14-
<Router>
14+
<>
15+
{" "}
1516
<div className="flex h-16 w-full items-center bg-green-400 px-5">
1617
<NavigationMenu>
1718
<NavigationMenuList className="flex items-center gap-2.5">
@@ -57,7 +58,7 @@ function App() {
5758
element={<Start />}
5859
/>
5960
</Routes>
60-
</Router>
61+
</>
6162
)
6263
}
6364

src/main.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { StrictMode } from "react"
22
import { createRoot } from "react-dom/client"
3+
import { HashRouter } from "react-router"
34
import App from "./App.tsx"
45
import "./tailwind.css"
56

67
createRoot(document.getElementById("root")!).render(
78
<StrictMode>
8-
<App />
9+
<HashRouter>
10+
<App />
11+
</HashRouter>
912
</StrictMode>
1013
)

vite.config.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1+
// vite.config.ts
12
import { defineConfig } from "vite"
23
import react from "@vitejs/plugin-react"
3-
import tailwindcss from "@tailwindcss/vite"
4-
import path from "path"
54

65
export default defineConfig({
7-
plugins: [react(), tailwindcss()],
8-
base:
9-
process.env.NODE_ENV === "production"
10-
? "/RandomInterview/" // 生产环境:GitHub Pages
11-
: "/", // 开发环境:本地
12-
resolve: {
13-
alias: {
14-
"@": path.resolve(__dirname, "src")
15-
}
16-
},
6+
plugins: [react()],
7+
base: "/RandomInterview/", // 确保与你的仓库名完全一致
178
build: {
189
outDir: "dist",
19-
chunkSizeWarningLimit: 1000
10+
emptyOutDir: true
2011
}
2112
})

0 commit comments

Comments
 (0)