/* 
 * 组件库配置文件
 */
import { h } from 'vue';
import { CompTypeEnum } from "@/enum/compTypeEnum";
import compIcon from "@/assets/comp-icon/index";
import {
  AppstoreAddOutlined,
  FileTextOutlined,
  PieChartOutlined,
  PlaySquareOutlined,
} from "@ant-design/icons-vue";

export interface CompItem {
  // 名称
  name: string;
  // 渲染组件
  componetName: string;
  // 图标
  icon: string;
}

export interface CompGroup {
  // 名称
  name: string;
  // 子组件
  children: CompItem[];
}

export interface CompCategory {
  // 类型
  type: CompTypeEnum;
  // 名称
  name: string;
  // 图标
  icon: () => any;
  // 是否是组
  isGroup?: boolean;
  // 组件
  children?: CompGroup[] | CompItem[];
}


interface CompSetting {
  // 组件列表
  compList: CompCategory[];
}

/**
 * 组件库配置文件
 *  */
export const compSetting: CompSetting = {
  compList: [
    {
      type: CompTypeEnum.CHART,
      name: '图表',
      icon: () => h(PieChartOutlined),
      isGroup: true,
      children: [
        {
          name: '柱状图类',
          children: [
            {
              name: '柱状图',
              componetName: 'BasicBar',
              icon: compIcon['icon-1']
            }
          ]
        },
        {
          name: '折线图类',
          children: [
            {
              name: '折线图',
              componetName: 'BasicLine',
              icon: compIcon['icon-2']
            }
          ]
        },
        {
          name: '饼状图类',
          children: [
            {
              name: '饼状图',
              componetName: 'BasicPie',
              icon: compIcon['icon-4']
            }
          ]
        }
      ]
    },
    {
      type: CompTypeEnum.TEXT,
      name: '文本',
      icon: () => h(FileTextOutlined),
      isGroup: false,
      children: [
        {
          name: '标题',
          componetName: 'Title',
          icon: compIcon['icon-3']
        },
      ]
    },
    {
      type: CompTypeEnum.MEDIA,
      name: '媒体',
      icon: () => h(PlaySquareOutlined),
      isGroup: false,
    },
    {
      type: CompTypeEnum.INPUT_COMP,
      name: '控件',
      icon: () => h(AppstoreAddOutlined),
      isGroup: false,
    }
  ]
}