开发组件规范

  • 样例说明

截屏2022-08-26 17.50.32.png

  • 组件必须包含一份主文件和一份meta.js, 如图TemplateComponents内index.js为组件主文件,meta.js是对该组件的名称、类型、自定义编辑属性、属性编辑表单类型、属性默认初始化值等的描述定义,index.svg是组件icon,目前组件icon的配置形式有两种:1 直接配置svg文件 ; 2 通过以iconfont的形式(https://www.iconfont.cn/manage/index?spm=a313x.7781069.1998910419.23&manage_type=myprojects&projectId=3290880),可申请加入项目,iconfont方便图标联动切换主题色
    1. export default {
    2. "id": "CarouselCompFive",
    3. "type": "CarouselCompFive",//与导出打包组件一致
    4. "name": "CarouselCompFive",// 与导出打包组件一致
    5. "title": "差异版本走马灯", // 组件名称
    6. "info": {
    7. "author": {
    8. "name": "",
    9. "url": "",
    10. },
    11. "description": "走马灯,用于页面中部描述性说明",
    12. "links": [],
    13. "logos": {
    14. "large": "",
    15. "small": "",// 本地svg
    16. "fontClass":""// iconfont 优先级最高
    17. },
    18. "build": {
    19. "time": "",
    20. "repo": "",
    21. "branch": "",
    22. "hash": "",
    23. },
    24. "screenshots": [],
    25. "updated": "",
    26. "version": "",
    27. "docs": "<a target='_blank' href='https://3x.ant.design/components/alert-cn/'>组件文档地址</a>",
    28. },
    29. "state": "",
    30. "latestVersion": "1.0",
    31. "configSchema": {
    32. "defaults": {
    33. "type": "CarouselCompFive",
    34. "config": {
    35. "message": "动态专题介绍组件",
    36. "showIcon": false,
    37. "alertType": "success",
    38. "closable": false,
    39. "closeText": "关闭",
    40. "icon":"",
    41. "description": "动态专题介绍组件",
    42. },
    43. },
    44. "schema": {
    45. "type": "object",
    46. "properties": { // 对组件进行自定义属性的可编辑项
    47. "backgroundImgList": {
    48. "description": "多背景图片,每次可上传多张,上传操作为覆盖更新操作,增删操作即:重新上传", // 属性tooltip说明
    49. "title": "多背景图片", // 属性名称,见于表单label
    50. "required": false,
    51. "type": "string",
    52. "x-component": "IMAGE_UPLOAD_MULTI", // 目标属性的编辑表单类型,在docs文件夹有目前支持的全部类型,可根据需求便宜选取
    53. "initValue": "",
    54. },
    55. "carouselHeight": {
    56. "description": "高度,百分比或者数字,如 30%,200,",
    57. "title": "高度",
    58. "required": false, // 是否必填
    59. "type": "string",
    60. "initValue":'100%', // 目标属性初始化默认值
    61. "x-component": "Input",
    62. },
    63. "carouselWidth": {
    64. "description": "宽度,百分比或者数字,如 100%,200",
    65. "title": "宽度",
    66. "required": false,
    67. "initValue":'100%',
    68. "type": "string",
    69. "x-component": "Input",
    70. },
    71. "autoPlay": {
    72. "description": "是否自动切换",
    73. "title": "自动切换",
    74. "required": false,
    75. "type": "string",
    76. "initValue":true,
    77. "x-component": "Radio",
    78. "x-component-props": {
    79. "options": [{"value": false, "label": "否"}, {"value": true, "label": "是"}],
    80. },
    81. },
    82. "dots": {
    83. "description": "是否展示指示点",
    84. "title": "是否展示指示点",
    85. "required": false,
    86. "initValue":true,
    87. "x-component": "Radio",
    88. "x-component-props": {
    89. "options": [{"value": false, "label": "否"}, {"value": true, "label": "是"}],
    90. },
    91. },
    92. "dotPosition": {
    93. "description": "指示点位置",
    94. "title": "指示点位置",
    95. "required": false,
    96. "type": "string",
    97. "x-component": "Select",
    98. "x-component-props": {
    99. "options": [{"value": "top", "label": "top"}, {"value": "bottom", "label": "bottom"},
    100. {"value": "left", "label": "left"},{"value": "right", "label": "right"}],
    101. },
    102. },
    103. "links": {
    104. "description": "图片超链接,添加顺序同图片顺序",
    105. "title": "图片超链接",
    106. "required": false,
    107. "type": "string",
    108. "x-component": "HANDLE_TAG",
    109. },
    110. "easing": {
    111. "description": "动画效果",
    112. "title": "动画效果",
    113. "required": false,
    114. "type": "string",
    115. "initValue":"linear",
    116. "x-component": "Input",
    117. },
    118. "effect": {
    119. "description": "动画效果函数",
    120. "title": "动画效果函数",
    121. "required": false,
    122. "type": "string",
    123. "x-component": "Select",
    124. "x-component-props": { // seclect类型的待选项设置形式
    125. "options": [{"value": "scrollx", "label": "scrollx"}, {"value": "fade", "label": "fade"}],
    126. },
    127. }
    128. },
    129. },
    130. "supportItemToolbar":false,
    131. "dataMock": {},
    132. },
    133. "catgory": "remote", // 用于组件列表的分类,默认值不变”remote“,代表远程组件
    134. };

meta.js集成到基座的实际效果
image.png

  • 应用基座注入组件的可用数据
    1. export default {
    2. widgetData: {}, // 组件已配备数据源,通过统一的数据源采集器获得的数据,可以是object,array,number,string等类型
    3. widgetConfig: {}, // 对应各组件定义的meta可配置属性字段,编辑后得到的属性value,供组件个性化渲染使用
    4. pageModel: {
    5. appId: 'testApp',//应用id
    6. nodeTypePath: 'testApp|app|T:pwIf7D9PC',//节点path
    7. },
    8. currentUser: {
    9. loginName: 'admin',//登录名
    10. lang: "zh_CN",//国际化语言类型
    11. nickname: "管理员",
    12. roles: [],// 角色
    13. userId: "empid::999999999",
    14. avatar: '',// 头像
    15. },
    16. nodeParams: {
    17. app_id: "testView2",
    18. },//节点参数阈,appId,数据源数据,过滤器字段等运行时参数字段都可以在nodeParams获取
    19. }
    widget组件库可提供COMPONENTS_PROPS.js包含组件集成到工程基座时的可用数据如上图,当前信息作为组件defaultProps使用,组件集成到基座时会被实际的应用信息覆盖