You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
678 B

import { keys, orderBy } from "lodash-es";
import { module } from "../module";
export async function createModules() {
// 加载 uni_modules 插件
const files: any = import.meta.glob("/uni_modules/cool-*/config.ts", {
eager: true,
});
const modules = orderBy(
keys(files).map((k) => {
const [, , name] = k.split("/");
return {
name,
value: files[k]?.default,
};
}),
"order",
"desc",
);
for (let i in modules) {
const { name, value } = modules[i];
const data = value ? value() : undefined;
// 添加模块
module.add({
name,
...data,
});
// 触发加载事件
if (data) {
await data.onLoad?.(data.options);
}
}
}