create.config.ts 3.29 KB
import { MessagePropertiesEnum } from '../../../enum/form';
import { RabbitmqFieldsEnum, RabbitmqFieldsNameEnum } from '../../../enum/formField/external';
import { FormSchema } from '/@/components/Form';
import { useI18n } from '/@/hooks/web/useI18n';

const { t } = useI18n();

export const formSchemas: FormSchema[] = [
  {
    field: RabbitmqFieldsEnum.EXCHANGE_NAME_PATTERN,
    label: t(RabbitmqFieldsNameEnum.EXCHANGE_NAME_PATTERN),
    component: 'Input',
    componentProps: {
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.EXCHANGE_NAME_PATTERN)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.ROUTING_KEY_PATTERN,
    label: t(RabbitmqFieldsNameEnum.ROUTING_KEY_PATTERN),
    component: 'Input',
    componentProps: {
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.ROUTING_KEY_PATTERN)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.MESSAGE_PROPERTIES,
    label: t(RabbitmqFieldsNameEnum.MESSAGE_PROPERTIES),
    component: 'Select',
    componentProps: {
      allowClear: true,
      options: Object.keys(MessagePropertiesEnum).map((value) => ({ label: value, value })),
      placeholder: `请选择${t(RabbitmqFieldsNameEnum.ROUTING_KEY_PATTERN)}`,
      getPopupContainer: () => document.body,
    },
  },
  {
    field: RabbitmqFieldsEnum.HOST,
    label: t(RabbitmqFieldsNameEnum.HOST),
    component: 'Input',
    required: true,
    colProps: { span: 12 },
    componentProps: {
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.HOST)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.PORT,
    label: t(RabbitmqFieldsNameEnum.PORT),
    component: 'InputNumber',
    required: true,
    colProps: { span: 12 },
    componentProps: {
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.PORT)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.VIRTUAL_HOST,
    label: t(RabbitmqFieldsNameEnum.VIRTUAL_HOST),
    component: 'Input',
    componentProps: {
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.VIRTUAL_HOST)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.USERNAME,
    label: t(RabbitmqFieldsNameEnum.USERNAME),
    component: 'Input',
    componentProps: {
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.USERNAME)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.PASSWORD,
    label: t(RabbitmqFieldsNameEnum.PASSWORD),
    component: 'Input',
    componentProps: {
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.PASSWORD)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.AUTOMATIC_RECOVERY_ENABLED,
    component: 'Checkbox',
    label: '',
    renderComponentContent: () => ({
      default: () => t(RabbitmqFieldsNameEnum.AUTOMATIC_RECOVERY_ENABLED),
    }),
  },
  {
    field: RabbitmqFieldsEnum.CONNECTION_TIMEOUT,
    label: t(RabbitmqFieldsNameEnum.CONNECTION_TIMEOUT),
    component: 'InputNumber',
    componentProps: {
      min: 0,
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.CONNECTION_TIMEOUT)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.HANDSHAKE_TIMEOUT,
    label: t(RabbitmqFieldsNameEnum.HANDSHAKE_TIMEOUT),
    component: 'InputNumber',
    componentProps: {
      min: 0,
      placeholder: `请输入${t(RabbitmqFieldsNameEnum.HANDSHAKE_TIMEOUT)}`,
    },
  },
  {
    field: RabbitmqFieldsEnum.CLIENT_PROPERTIES,
    label: t(RabbitmqFieldsNameEnum.CLIENT_PROPERTIES),
    component: 'Input',
    slot: RabbitmqFieldsEnum.CLIENT_PROPERTIES,
  },
];