本文内容

消息卡片总体结构

消息卡片由 header、elements、i18n 和 config 组成,卡片相关限制:

  • 卡片组件数:每个卡片组件数不得超过 20 个。
  • 卡片内容阈值:每个卡片内容不得超过 5000 个字符。
卡片结构 是否必须 类型 说明
config object 卡片配置
∟ operator_allow array 是否允许右键操作
null:全部允许, -1:全部禁止
∟ todo_switch string 添加卡片待办状态,需要在更新卡片时手动更改该配置为 off
on:开启待办,off:关闭待办
∟ filter_key string 添加卡片筛选状态,需要在开发者后台配置筛选项
∟ update_single bool 是否独享,true: 开启独享,false: 开启共享
∟ nonsupport_client object 消息卡片不支持展示的客户端
link object 配置整个卡片跳转链接
header object 卡片标题,包括标题和副标题
elements object 卡片内容
i18n map 卡片消息多语言内容,map 类型,key 为多语言标识 简体中文 zh-CN 繁体中文 zh-TW 英文 en-US, value 格式 {"header": {...}, "elements":[...] },考虑到原有卡片内容即为简体中文,多语言可以不用重复配置简体中文内容
∟ header object 卡片多语言-标题,包括标题和副标题
∟ elements array 卡片多语言-组件列表

代码示例

{
    "config": {
    "operator_allow": [-1], // null:全部允许, -1:全部禁止
    "todo_switch": "on", // on:开启待办,off:关闭待办
    "filter_key": "key", // 添加卡片筛选状态,需要在开发者后台配置筛选项
    "update_single": true, // 是否独享,true: 开启独享,false: 开启共享
    "nonsupport_client": {
        "client_type": ["pc"], //  三个枚举: "pc", "ios", "android"   代表不支持的客户端
        "describe": "[收到一条授权登录消息,请前往移动端操作]"   // 不支持的客户端文本描述
        }
     },
     "link": {
        "url": "https://xz.wps.cn/",
        "android_url": "https://xz.wps.cn/",
        "ios_url": "https://xz.wps.cn/",
        "pc_url": "https://xz.wps.cn/"
     },
    "header": {
        "title": {
            "tag": "text",
            "content": {
                "type": "plainText",
                "text": "标题"
            }
        },
        "subtitle": {
            "tag": "text",
            "content": {
                "type": "plainText",
                "text": "副标题"
            }
        }
    },
    "elements": [
        {
            //组件内容
        }
    ],
    "i18n": {
        "zh-TW": {
            "header": {
                "title": {
                    "tag": "text",
                    "content": {
                        "type": "plainText",
                        "text": "標題"
                    }
                },
                "subtitle": {
                    "tag": "text",
                    "content": {
                        "type": "plainText",
                        "text": "副標題"
                    }
                }
            },
            "elements": [
                {
                    //组件内容
                }
            ]
        },
        "en-US": {
            "header": {
                "title": {
                    "tag": "text",
                    "content": {
                        "type": "plainText",
                        "text": "Title"
                    }
                },
                "subtitle": {
                    "tag": "text",
                    "content": {
                        "type": "plainText",
                        "text": "Subtitle"
                    }
                }
            },
            "elements": [
                {
                    //组件内容
                }
            ]
        }
    }
}

卡片内容

目前支持的卡片组件如表格所示:

模块分类 组件 说明
文本模块 单列文本(tag=text)、双列文本(tag=div)
图文模块 图片(tag=img)、轮播图(tag=carousel)、视频(tag=video)、文本+中图(tag=picText)、文本+小图(tag=note)
分割线模块 分割线(tag=hr)
交互模块 按钮(tag=button)、列表选择器(tag=selection)、日期选择器(tag=datePicker)、输入框(tag=input) 交互模块必须包含在 tag=action 下

本文内容