import { defineAsyncComponent } from 'vue';

// 自动注册src/components目录下的所有.vue文件
export default function registerGlobalComponents(app) {
  const components = import.meta.glob('./components/**/*.vue');

  for (const path in components) {
    const componentName = path
      .split('/')
      .pop()
      .replace(/\.\w+$/, '');

    app.component(componentName, defineAsyncComponent(components[path]));
  }
}
