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 }) => ({
7272function NavLinks ( ) {
7373 const location = useLocation ( ) ;
7474
75+ // 修复路由匹配逻辑,使用hash路由的pathname
7576 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 ) ;
7880 } ;
7981
8082 return (
@@ -94,7 +96,7 @@ function NavLinks() {
9496
9597function MainApp ( ) {
9698 return (
97- < Router basename = "/ai-coding-prompt-builder/ " >
99+ < Router basename = "/" >
98100 < AppBar
99101 position = "static"
100102 color = "default"
@@ -117,8 +119,6 @@ function MainApp() {
117119 < Route path = "/" element = { < Home /> } />
118120 < Route path = "/prompt" element = { < PromptTemplate /> } />
119121 < Route path = "/about" element = { < About /> } />
120- { /* 添加404回退路由 */ }
121- < Route path = "*" element = { < Home /> } />
122122 </ Routes >
123123
124124 < footer style = { {
Original file line number Diff line number Diff line change 11import { defineConfig } from 'vite'
22import react from '@vitejs/plugin-react'
33
4- // https://vite.dev/config/
54export 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