-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
const modules1 = import.meta.glob('./[A-Z][a-zA-Z]+/index.ts(x)?'); | ||
const modules2 = import.meta.glob('./[A-Z][a-zA-Z]+/*/index.ts(x)?'); | ||
const exportModule: any = {}; | ||
const modules = { | ||
...modules1, | ||
...modules2, | ||
}; | ||
const componentMap: { [key: string]: any } = {}; | ||
|
||
/** | ||
* 按需加载组件 | ||
*/ | ||
const modules: { [key: string]: () => Promise<any> } = import.meta.glob('./[a-zA-Z]+/**'); | ||
|
||
let regex = /\/([a-z]+)\/index/i; | ||
for (const path in modules) { | ||
const componentName = path.match(regex); | ||
if (componentName?.[1]) { | ||
exportModule[componentName[1]] = modules[path]; | ||
const [type, name] = path.split('/').slice(-2); | ||
if (type === 'MarsRender') continue; | ||
if (type === name.split('.')?.[0]) { | ||
componentMap[type] = modules[path]; | ||
} | ||
} | ||
export const module = exportModule; | ||
|
||
export const module = componentMap; |