@@ -10,7 +10,9 @@ import Constants from 'expo-constants';
1010import { audioService } from './src/utils/audio' ;
1111
1212// 获取 baseUrl(用于 GitHub Pages 等子路径部署)
13- const baseUrl = Constants . expoConfig ?. web ?. baseUrl || '' ;
13+ const rawBaseUrl = Constants . expoConfig ?. web ?. baseUrl || '' ;
14+ const normalizedBaseUrl = rawBaseUrl . endsWith ( '/' ) ? rawBaseUrl . slice ( 0 , - 1 ) : rawBaseUrl ;
15+ const baseUrl = resolveBaseUrl ( ) ;
1416
1517import { StudyProvider } from './src/contexts/StudyContext' ;
1618import { ThemeProvider , useTheme } from './src/contexts/ThemeContext' ;
@@ -39,7 +41,7 @@ type RootStackParamList = {
3941
4042// Linking configuration with proper typing
4143const linking : LinkingOptions < RootStackParamList > = {
42- prefixes : [ baseUrl ] ,
44+ prefixes : baseUrl ? [ baseUrl ] : [ ] ,
4345 config : {
4446 screens : {
4547 Main : {
@@ -56,12 +58,26 @@ const linking: LinkingOptions<RootStackParamList> = {
5658 } ,
5759} ;
5860
59- // Tab 图标配置
61+ function resolveBaseUrl ( ) : string {
62+ if ( Platform . OS !== 'web' ) return '' ;
63+ if ( ! normalizedBaseUrl ) return '' ;
64+ if ( typeof window === 'undefined' ) return normalizedBaseUrl ;
65+
66+ const path = window . location . pathname || '' ;
67+ if ( path === normalizedBaseUrl || path . startsWith ( `${ normalizedBaseUrl } /` ) ) {
68+ return normalizedBaseUrl ;
69+ }
70+
71+ // 当部署在根路径时,不应用 baseUrl
72+ return '' ;
73+ }
74+
75+ // Tab 图标配置 - 使用日语汉字
6076const TAB_CONFIG : Record < string , { icon : string } > = {
61- Home : { icon : '○ ' } ,
62- Browse : { icon : '田 ' } ,
63- Stats : { icon : '〓 ' } ,
64- Settings : { icon : '◎ ' } ,
77+ Home : { icon : '学 ' } , // 学習 - 学习
78+ Browse : { icon : '表 ' } , // 五十音表 - 图表
79+ Stats : { icon : '績 ' } , // 成績 - 成绩
80+ Settings : { icon : '設 ' } , // 設定 - 设置
6581} ;
6682
6783// 自定义浮动 TabBar 组件
0 commit comments