feat: 使App.vue和VirtualDirectory解耦
This commit is contained in:
1 parent
6d550505a0
commit
4aba71d451
8 files changed
+162
-66
No files matched your search
@@ -6,25 +6,19 @@ const initPlugin = async (globalAlertTip: alertTipType) => {
|
||||
initPluginCenter(globalAlertTip);
|
||||
const modulesFiles = import.meta.glob("@/plugins/**/export*.ts", { eager: true });
|
||||
const pluginCenter = usePluginCenter();
|
||||
const promiseArray = [];
|
||||
for (let pluginConfig of Object.values(modulesFiles)) {
|
||||
promiseArray.push(
|
||||
new Promise(async resolve => {
|
||||
const _config = pluginConfig as {
|
||||
default: registerComponentOption | Plugin;
|
||||
type: PluginExportType;
|
||||
key?: string;
|
||||
};
|
||||
const { type, key } = _config;
|
||||
if (type === PluginExportType.component) {
|
||||
resolve(pluginCenter.registerComponent(_config.default as registerComponentOption));
|
||||
} else if (type === PluginExportType.default) {
|
||||
resolve(pluginCenter.register(key as string, _config.default as Plugin));
|
||||
}
|
||||
})
|
||||
);
|
||||
const _config = pluginConfig as {
|
||||
default: registerComponentOption | Plugin;
|
||||
type: PluginExportType;
|
||||
key?: string;
|
||||
};
|
||||
const { type, key } = _config;
|
||||
if (type === PluginExportType.component) {
|
||||
pluginCenter.registerComponent(_config.default as registerComponentOption);
|
||||
} else if (type === PluginExportType.default) {
|
||||
pluginCenter.register(key as string, _config.default as Plugin);
|
||||
}
|
||||
}
|
||||
await Promise.all(promiseArray);
|
||||
};
|
||||
|
||||
export default initPlugin;
|
||||
Reference in new issue
Block a user