@@ -82,27 +82,28 @@ export function getIcon(icon: string) {
8282 return resolveComponent ( compName ) ;
8383}
8484
85- export const loadFile = ( file : string ) => {
85+ export const loadFile = async ( file : string ) => {
8686 if ( file . startsWith ( 'http' ) ) {
8787 return file ;
8888 }
89- console . log ( 'file' , file ) ;
9089 let path ;
9190 let baseUrl = '' ;
91+ const files = import . meta. glob ( '/**/*' , { import : 'default' } ) ;
92+
9293 if ( file . startsWith ( '@/' ) ) {
93- path = file . replace ( '@/' , '' ) ;
94- console . log ( 'path' , path ) ;
95- const fileModulePath = `./${ path } ` ;
96- console . log ( 'imort.meta.url' , import . meta. url ) ;
97- baseUrl = new URL ( `./${ path } ` , import . meta. url ) . href ;
98- console . log ( 'baseUrl' , baseUrl ) ;
94+ path = file . replace ( '@/' , '/src/' ) ;
9995 } else if ( file . startsWith ( '@@/' ) ) {
100- path = file . replace ( '@@/' , '' ) ;
101- const fileModulePath = `./${ path } ` ;
102- baseUrl = new URL ( `./${ path } ` , new URL ( import . meta. url ) . origin + new URL ( import . meta. url ) . pathname ) . href ;
96+ path = file . replace ( '@@/' , '/src/custom/' ) ;
97+ } else {
98+ path = `./${ file } ` ;
99+ }
100+
101+ const match = files [ path ] ;
102+ if ( ! match ) {
103+ console . error ( `File ${ file } not found` ) ;
103104 } else {
104- const fileModulePath = `./ ${ file } ` ;
105- baseUrl = new URL ( `./ ${ file } ` , new URL ( import . meta . url ) . origin + new URL ( import . meta . url ) . pathname ) . href ;
105+ const result = await match ( ) ;
106+ baseUrl = typeof result === 'string' ? result : '' ;
106107 }
107108 return baseUrl ;
108109}
0 commit comments