File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -72,9 +72,11 @@ const StyledLink = styled(Link)(({ theme }) => ({
72
72
function NavLinks ( ) {
73
73
const location = useLocation ( ) ;
74
74
75
+ // 修复路由匹配逻辑,使用hash路由的pathname
75
76
const isActive = ( path : string ) => {
76
- if ( path === '/' ) return location . pathname === path ;
77
- return location . pathname . startsWith ( path ) ;
77
+ const hashPath = location . hash . replace ( '#' , '' ) ;
78
+ if ( path === '/' ) return hashPath === '/' ;
79
+ return hashPath . startsWith ( path ) ;
78
80
} ;
79
81
80
82
return (
@@ -94,7 +96,7 @@ function NavLinks() {
94
96
95
97
function MainApp ( ) {
96
98
return (
97
- < Router basename = "/ai-coding-prompt-builder/ " >
99
+ < Router basename = "/" >
98
100
< AppBar
99
101
position = "static"
100
102
color = "default"
@@ -117,8 +119,6 @@ function MainApp() {
117
119
< Route path = "/" element = { < Home /> } />
118
120
< Route path = "/prompt" element = { < PromptTemplate /> } />
119
121
< Route path = "/about" element = { < About /> } />
120
- { /* 添加404回退路由 */ }
121
- < Route path = "*" element = { < Home /> } />
122
122
</ Routes >
123
123
124
124
< footer style = { {
Original file line number Diff line number Diff line change 1
1
import { defineConfig } from 'vite'
2
2
import react from '@vitejs/plugin-react'
3
3
4
- // https://vite.dev/config/
5
4
export default defineConfig ( {
6
- base : '/ai-coding-prompt-builder/' ,
7
- plugins : [ react ( ) ] ,
8
- } )
5
+ plugins : [ react ( ) ] ,
6
+ base : '/ai-coding-prompt-builder/' , // 保持base配置不变
7
+ build : {
8
+ outDir : 'dist' ,
9
+ assetsDir : 'assets'
10
+ }
11
+ } )
You can’t perform that action at this time.
0 commit comments