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.
 
 
 
 
 
 

30 lines
621 B

const $globalStore = {};
const storeModule = {};
const uniName = [];
const modulesStore = import.meta.glob("../store/**/*.js", {
import: "default",
eager: true,
});
for (const [, value] of Object.entries(modulesStore)) {
const storeId = value.$id;
if (storeId) {
storeModule[storeId] = value;
uniName.includes(storeId)
? console.error(`Store的唯一ID${storeId},存在重复`)
: uniName.push(storeId);
}
}
const $globalRegisterStore = {
install() {
Object.entries(storeModule).forEach((item) => {
$globalStore[item[0]] = item[1]();
});
},
};
export {
$globalStore,
$globalRegisterStore
};