Files
blog/src/config/index.ts
2026-08-04 17:33:45 +08:00

11 lines
411 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
});
}