import type { App } from 'vue';
import { isMobile } from './env';

export const registerTDesignComponents = async (app: App) => {
  if (isMobile) {
    // 动态 import：PC 端完全不加载 tdesign-mobile-vue 的 JS 与 CSS
    const [{ default: TDesignMobile }] = await Promise.all([
      import('tdesign-mobile-vue'),
      import('tdesign-mobile-vue/es/style/index.css'),
    ]);
    app.use(TDesignMobile);
  } else {
    // 动态 import：Mobile 端完全不加载 tdesign-vue-next 的 JS 与 CSS
    const [{ default: TDesign }] = await Promise.all([
      import('tdesign-vue-next'),
      import('tdesign-vue-next/es/style/index.css'),
    ]);
    app.use(TDesign);
  }
};
