@@ -69,11 +69,12 @@ async function initializeApp() {
6969 await setI18nLocale ( userLocale ) ;
7070 logger . debug ( '✅ vue-i18n plugin locale set:' , userLocale )
7171
72- // Check for tab query parameter for Firefox shortcuts navigation
73- let initialRoute = '/' ;
72+ // Check for tab query parameter for Firefox shortcuts navigation and hash URLs
73+ let initialRoute = '/languages' ; // Default to languages tab
7474 let shouldNavigateToHelp = false ;
7575
7676 try {
77+ // First check query parameters (for Firefox shortcuts)
7778 const urlParams = new URLSearchParams ( window . location . search ) ;
7879 const tabParam = urlParams . get ( 'tab' ) ;
7980
@@ -86,6 +87,21 @@ async function initializeApp() {
8687 // For Firefox help navigation, redirect to help tab
8788 initialRoute = '/help' ;
8889 logger . debug ( 'Detected tab=help parameter, redirecting to help tab for Firefox' ) ;
90+ } else {
91+ // If no query parameter, check hash URL
92+ const hash = window . location . hash . replace ( '#' , '' ) . replace ( '/' , '' ) ;
93+ if ( hash === 'help' || hash === 'shortcuts' ) {
94+ initialRoute = '/help' ;
95+ logger . debug ( `Detected hash #${ hash } , redirecting to help tab` ) ;
96+ } else if ( hash && hash !== '' ) {
97+ // Use the hash path if it's valid
98+ const validRoutes = [ 'languages' , 'appearance' , 'activation' , 'prompt' , 'api' , 'import-export' , 'advance' , 'about' , 'help' ] ;
99+ if ( validRoutes . includes ( hash ) ) {
100+ initialRoute = `/${ hash } ` ;
101+ logger . debug ( `Detected hash #${ hash } , redirecting to ${ initialRoute } tab` ) ;
102+ }
103+ }
104+ // If hash is empty or '/', keep default languages route
89105 }
90106 } catch ( e ) {
91107 logger . debug ( 'Failed to parse URL parameters:' , e ) ;
@@ -96,7 +112,22 @@ async function initializeApp() {
96112 const router = createRouter ( {
97113 history : createWebHashHistory ( ) ,
98114 routes : [
99- { path : '/' , redirect : initialRoute } ,
115+ { path : '/' , redirect : ( ) => {
116+ // Avoid infinite redirect by checking current hash
117+ const currentHash = window . location . hash . replace ( '#' , '' ) . replace ( '/' , '' ) ;
118+ if ( currentHash === '' || currentHash === '/' ) {
119+ logger . debug ( `Root redirect: current hash is empty, redirecting to ${ initialRoute } ` ) ;
120+ return initialRoute ;
121+ }
122+ // If current hash matches a valid route, use it instead
123+ const validRoutes = [ 'languages' , 'appearance' , 'activation' , 'prompt' , 'api' , 'import-export' , 'advance' , 'about' , 'help' ] ;
124+ if ( validRoutes . includes ( currentHash ) ) {
125+ logger . debug ( `Root redirect: current hash #${ currentHash } is valid, using it` ) ;
126+ return `/${ currentHash } ` ;
127+ }
128+ logger . debug ( `Root redirect: using default route ${ initialRoute } ` ) ;
129+ return initialRoute ;
130+ } } ,
100131 { path : '/languages' , component : LanguagesTab , name : 'languages' } ,
101132 { path : '/appearance' , component : AppearanceTab , name : 'appearance' } ,
102133 { path : '/activation' , component : ActivationTab , name : 'activation' } ,
0 commit comments