index.ts 4.62 KB
import { FormSchema } from '/@/components/Form';

/**
 * RabbitMq表单相关默认值配置
 */
class RabbitMqFormPartialConfig {
  static topicPattern = 'my-topic'; //消息主题默认值
  static host = true; //主机
  static port = 5672; //端口
  static virtualHost = '/'; //虚拟端口(以/开头)
  static username = 'guest'; //用户名
  static password = 'guest'; //密码
  static connectionTimeout = 60000; //连接超时(毫秒)
  static handshakeTimeout = 10000; //握手超时(毫秒)
  static automaticRecoveryEnabled = false;

  //anonymous Select options配置
  static getMessageProperties() {
    return [
      { label: 'BASIC', value: 'BASIC' },
      { label: 'TEXT_PLAIN', value: 'TEXT_PLAIN' },
      { label: 'MINIMAL_BASIC', value: 'MINIMAL_BASIC' },
      { label: 'MINIMAL_PERSISTENT_BASIC', value: 'MINIMAL_PERSISTENT_BASIC' },
      { label: 'PERSISTENT_BASIC', value: 'PERSISTENT_BASIC' },
      { label: 'PERSISTENT_TEXT_PLAIN', value: 'PERSISTENT_TEXT_PLAIN' },
    ];
  }
}

export const modeRabbitMqForm: FormSchema[] = [
  {
    field: 'name',
    label: '名称',
    colProps: { span: 12 },
    required: true,
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入名称',
    },
  },
  {
    field: 'exchangeNamePattern',
    label: '交换名称模式',
    colProps: { span: 12 },
    component: 'Input',
    defaultValue: '',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入模式',
    },
  },
  {
    field: 'routingKeyPattern',
    label: '路由密钥模式',
    colProps: { span: 12 },
    defaultValue: '',
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入模式',
    },
  },
  {
    field: 'messageProperties',
    component: 'Select',
    label: '消息属性',
    colProps: { span: 12 },
    defaultValue: null,
    componentProps: {
      placeholder: '请选择消息属性',
      options: RabbitMqFormPartialConfig.getMessageProperties(),
    },
  },
  {
    field: 'host',
    label: '主机',
    colProps: { span: 12 },
    component: 'Input',
    required: RabbitMqFormPartialConfig.host,
    defaultValue: 'localhost',
    componentProps: {
      maxLength: 255,
      placeholder: 'localhost',
    },
  },
  {
    field: 'port',
    label: '端口',
    colProps: { span: 12 },
    component: 'InputNumber',
    defaultValue: RabbitMqFormPartialConfig.port,
    required: true,
    componentProps: {
      maxLength: 255,
      placeholder: '请输入Port',
    },
  },
  {
    field: 'virtualHost',
    label: '虚拟端口',
    colProps: { span: 12 },
    component: 'Input',
    defaultValue: RabbitMqFormPartialConfig.virtualHost,
    componentProps: {
      maxLength: 255,
      placeholder: '/',
    },
  },
  {
    field: 'username',
    label: '用户名',
    colProps: { span: 12 },
    component: 'Input',
    defaultValue: RabbitMqFormPartialConfig.username,
    componentProps: {
      maxLength: 255,
      placeholder: '请输入用户名',
    },
  },
  {
    field: 'password',
    label: '密码',
    colProps: { span: 12 },
    component: 'InputPassword',
    defaultValue: RabbitMqFormPartialConfig.password,
    componentProps: {
      maxLength: 255,
      placeholder: '请输入密码',
    },
  },
  {
    field: 'automaticRecoveryEnabled',
    label: '是否启用',
    colProps: { span: 12 },
    defaultValue: RabbitMqFormPartialConfig.automaticRecoveryEnabled,
    component: 'Checkbox',
    renderComponentContent: '自动恢复',
  },
  {
    field: 'connectionTimeout',
    label: '连接超时(毫秒)',
    colProps: { span: 12 },
    component: 'InputNumber',
    defaultValue: RabbitMqFormPartialConfig.connectionTimeout,
    componentProps: {
      maxLength: 255,
      placeholder: '请输入Connection timeout (ms)',
    },
  },
  {
    field: 'handshakeTimeout',
    label: '握手超时(毫秒)',
    colProps: { span: 12 },
    component: 'InputNumber',
    defaultValue: RabbitMqFormPartialConfig.handshakeTimeout,
    componentProps: {
      maxLength: 255,
      placeholder: '请输入Handshake timeout (ms)',
    },
  },
  {
    field: 'clientProperties',
    label: '客户端属性',
    colProps: { span: 24 },
    component: 'JAddInput',
    defaultValue: {},
  },
  {
    field: 'description',
    label: '说明',
    colProps: { span: 24 },
    component: 'InputTextArea',
    componentProps: {
      maxLength: 255,
      rows: 4,
      placeholder: '请输入说明',
    },
  },
];