Skip to content

Latest commit

 

History

History
70 lines (62 loc) · 2.26 KB

2.自定义组件.md

File metadata and controls

70 lines (62 loc) · 2.26 KB

Custom component

  1. Can refer to

    • com.xiaomi.thain.component.std.MailComponent
    • com.xiaomi.thain.component.std.HttpComponent
  2. Use annotations: com.xiaomi.thain.component.annotation.ThainComponent

    • group: The group to which the component belongs, such as std, xdata, etc., used to distinguish components
    • name: the component name, such as: http
    • defineJson
      • component-defined json
      • This json is used for field validation, front-end component display, etc.
  3. json definition

    • Format:

      /**
       * https://app.quicktype.io/#l=schema This site generates json
       *
       * Component front-end schema
       *
       */
      Export type ComponentDefineJson = Array<{
        /**
         * Key passed to the backend
         */
        Property: string;
        /**
         * Required or not, false or not written is not required
         */
        Required?: boolean;
        /**
         * Enter the identifier in front of the box, do not write the default property
         */
        Label?: string;
        Input:
          | {
              Id: 'line' | 'textarea' | 'sql' | 'shell' | 'richText';
            }
          | {
              Id: 'select';
              Options: Array<{
                /**
                 * the value of the attribute
                 */
                Id: string;
                /**
                 * The candidate in the drop-down box is not written with id instead
                 */
                Name?: string;
              }>;
            };
      }>;
  4. java class design

    • Define the property in json in the java class, and the runtime will automatically inject according to the information filled in by the user.
    • You can define a property of type com.xiaomi.thain.component.tools.ComponentTools
      • ComponentTools has many features in this interface
  5. ComponentTools interface

    • com.xiaomi.thain.component.tools.ComponentTools See comments