File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 < div id ="app " class ="w-full h-full ">
1919 < div id ="iframe "> </ div >
2020 </ div >
21- < pwa-install id ="pwa-install "> </ pwa-install >
22- < script >
23- document . addEventListener ( 'DOMContentLoaded' , ( ) => {
24- const install = document . getElementById ( 'pwa-install' ) ;
25- if ( install ) {
26- const manifest = document . querySelector ( 'link[rel="manifest"]' ) ;
27- if ( manifest ) install . setAttribute ( 'manifestpath' , manifest . href ) ;
28- const icon = document . querySelector ( 'link[rel="icon"]' ) ;
29- if ( icon ) install . setAttribute ( 'iconpath' , icon . href ) ;
30- }
31- } ) ;
32- </ script >
3321</ body >
3422< script type ="module " src ="./index.ts "> </ script >
3523
Original file line number Diff line number Diff line change @@ -87,3 +87,22 @@ if ('serviceWorker' in navigator) {
8787 } ) ;
8888 } ) ;
8989}
90+
91+ // Initialize PWA install component
92+ const initPwaInstall = ( ) => {
93+ const pwaInstall = document . createElement ( 'pwa-install' ) ;
94+ pwaInstall . id = 'pwa-install' ;
95+
96+ // Calculate absolute paths to avoid subfolder resolution issues
97+ const baseUrl = window . location . href . split ( '?' ) [ 0 ] . split ( '#' ) [ 0 ] ;
98+ const baseDir = baseUrl . substring ( 0 , baseUrl . lastIndexOf ( '/' ) + 1 ) ;
99+
100+ // Set paths relative to the current directory
101+ pwaInstall . setAttribute ( 'manifestpath' , `${ baseDir } manifest.json` ) ;
102+ pwaInstall . setAttribute ( 'iconpath' , `${ baseDir } img/pwa-512.png` ) ;
103+
104+ document . body . appendChild ( pwaInstall ) ;
105+ } ;
106+
107+ // Start PWA initialization after short delay to ensure everything is settled
108+ setTimeout ( initPwaInstall , 1000 ) ;
You can’t perform that action at this time.
0 commit comments