整体优化
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
export function useConfig() {
|
||||
const files = import.meta.glob("./*.ts", { eager: true }) as Record<string, any>;
|
||||
Object.keys(files).forEach(key => {
|
||||
const name = key.replace(/(\.\/|\.ts)/g, "");
|
||||
(window as Record<string, any>)["$" + name] = files[key].default as 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;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user