11 lines
411 B
TypeScript
11 lines
411 B
TypeScript
export function useConfig() {
|
||
const files = import.meta.glob("./*.ts", { eager: true }) as Record<string, any>;
|
||
Object.keys(files)
|
||
// 排除自身 index.ts,避免挂载出无意义的 $index
|
||
.filter(key => !key.endsWith("/index.ts"))
|
||
.forEach(key => {
|
||
const name = key.replace(/(\.\/|\.ts)/g, "");
|
||
(window as Record<string, any>)["$" + name] = files[key].default as any;
|
||
});
|
||
}
|