什么是 HostConfig?What is HostConfig?

HostConfig 是一个跨平台配置对象,用于指定自适应卡片呈现器生成 UI 的方式。HostConfig is a cross-platform configuration object that specifies how an Adaptive Card Renderer generates UI.

这样,那些跨平台的属性就可以在不同平台和设备的呈现器中共享。This allows properties which are platform agnostic to be shared among renderers on different platforms and devices. 另外还可以创建工具,让你了解该卡片在给定环境下的外观。It also allows tooling to be created which gives you an idea of the look and feel that card would have for a given environment.

请查看 HostConfig.json 示例,了解其内容。See a sample HostConfig.json to get a feeling for its contents.


卡片配置Card Configuration

AdaptiveCardConfigAdaptiveCardConfig

AdaptiveCards 的顶级选项Toplevel options for AdaptiveCards

属性Property 类型Type 必需Required 说明Description 版本Version
allowCustomStyleallowCustomStyle boolean 否,默认值为:trueNo, default: true 控制是否允许自定义样式设置Controls whether custom styling is allowed 1.01.0
supportsInteractivitysupportsInteractivity boolean 否,默认值为:trueNo, default: true 控制是否允许调用交互式 ActionControl whether interactive Actions are allowed to be invoke 1.01.0
imageBaseUrlimageBaseUrl string No 在加载资源时需要使用的 URLBase URL to be used when loading resources 1.01.0
fontFamilyfontFamily string 否,默认值为:"Calibri"No, default: "Calibri" 呈现文本时需要使用的字体Font face to use when rendering text 1.01.0
actionsactions object No Action 的选项Options for Actions 1.01.0
adaptiveCardadaptiveCard object No AdaptiveCards 的顶级选项Toplevel options for AdaptiveCards 1.01.0
containerStylescontainerStyles object No 控制默认的强调容器的样式设置Controls styling for default and emphasis containers 1.01.0
imageSizesimageSizes object No 控制 Image 大小Controls Image sizes 1.01.0
imageSetimageSet object No 控制 ImageSet 的显示方式Controls how ImageSets are displayed 1.01.0
factSetfactSet object No 控制 FactSet 的显示Controls the display of FactSets 1.01.0
fontSizesfontSizes object No 控制不同文本样式的字体大小指标Controls font size metrics for different text styles 1.01.0
fontWeightsfontWeights object No 控制字体粗细指标Controls font weight metrics 1.01.0
spacingspacing object No 控制元素的布局方式Controls how elements are to be laid out 1.01.0
separator separator object No 控制分隔符的显示方式Controls how separators are displayed 1.01.0
mediamedia object No 控制 Media 元素的显示和行为Controls the display and behavior of Media elements 1.11.1

ActionsConfigActionsConfig

Action 的选项Options for Actions

属性Property 类型Type 必需Required 说明Description 版本Version
actionsOrientationactionsOrientation string 否,默认值为:"horizontal"No, default: "horizontal" 控制按钮的布局方式Controls how buttons are laid out 1.01.0
actionAlignmentactionAlignment string 否,默认值为:"stretch"No, default: "stretch" 控制按钮的布局Control layout of buttons 1.01.0
buttonSpacingbuttonSpacing integer 否,默认值为:10No, default: 10 控制在按钮之间使用的空间量Controls how much spacing to use between buttons 1.01.0
maxActionsmaxActions integer 否,默认值为:5No, default: 5 控制允许的操作总数Controls how many actions are allowed in total 1.01.0
spacingspacing string 否,默认值为:"default"No, default: "default" 控制操作元素的总体间距Controls overall spacing of action element 1.01.0
showCardshowCard object No 控制 Action.ShowCard 的行为和样式设置Controls behavior and styling of Action.ShowCard 1.01.0
iconPlacementiconPlacement string 否,默认值为:"aboveTitle"No, default: "aboveTitle" 控制操作图标的放置位置Controls where to place the action icon 1.01.0
iconSizeiconSize integer 否,默认值为:30No, default: 30 控制操作图标的大小Controls size of action icon 1.01.0

ContainerStylesConfigContainerStylesConfig

控制默认的强调容器的样式设置Controls styling for default and emphasis containers

属性Property 类型Type 必需Required 说明Description 版本Version
defaultdefault object No 默认的容器样式Default container style 1.01.0
emphasisemphasis object No 用于强调的容器样式Container style to use for emphasis 1.01.0

FactSetConfigFactSetConfig

控制 FactSet 的显示Controls the display of FactSets

属性Property 类型Type 必需Required 说明Description 版本Version
titletitle object 否,默认值为:{"weight":"bolder","size":"default","color":"default","isSubtle":false,"wrap":true,"maxWidth":150}No, default: {"weight":"bolder","size":"default","color":"default","isSubtle":false,"wrap":true,"maxWidth":150} 控制文本显示的参数Parameters controlling the display of text 1.01.0
valuevalue object 否,默认值为:{"weight":"default","size":"default","color":"default","isSubtle":false,"wrap":true,"maxWidth":0}No, default: {"weight":"default","size":"default","color":"default","isSubtle":false,"wrap":true,"maxWidth":0} 控制文本显示的参数Parameters controlling the display of text 1.01.0
spacingspacing integer 否,默认值为:10No, default: 10   1.01.0

FontSizesConfigFontSizesConfig

控制不同文本样式的字体大小指标Controls font size metrics for different text styles

属性Property 类型Type 必需Required 说明Description 版本Version
smallsmall integer 否,默认值为:10No, default: 10 小字号Small font size 1.01.0
defaultdefault integer 否,默认值为:12No, default: 12 默认字号Default font size 1.01.0
mediummedium integer 否,默认值为:14No, default: 14 中字号Medium font size 1.01.0
largelarge integer 否,默认值为:17No, default: 17 大字号Large font size 1.01.0
extraLargeextraLarge integer 否,默认值为:20No, default: 20 超大字号Extra large font size 1.01.0

FontWeightsConfigFontWeightsConfig

控制字体粗细指标Controls font weight metrics

属性Property 类型Type 必需Required 说明Description 版本Version
lighterlighter integer 否,默认值为:200No, default: 200   1.01.0
defaultdefault integer 否,默认值为:400No, default: 400   1.01.0
bolderbolder integer 否,默认值为:800No, default: 800   1.01.0

ForegroundColorsConfigForegroundColorsConfig

控制各种字体颜色Controls various font colors

属性Property 类型Type 必需Required 说明Description 版本Version
defaultdefault object 否,默认值为:{"default":"#FF000000","subtle":"#B2000000"}No, default: {"default":"#FF000000","subtle":"#B2000000"}   1.01.0
accentaccent object 否,默认值为:{"default":"#FF0000FF","subtle":"#B20000FF"}No, default: {"default":"#FF0000FF","subtle":"#B20000FF"}   1.01.0
darkdark object 否,默认值为:{"default":"#FF101010","subtle":"#B2101010"}No, default: {"default":"#FF101010","subtle":"#B2101010"}   1.01.0
lightlight object 否,默认值为:{"default":"#FFFFFFFF","subtle":"#B2FFFFFF"}No, default: {"default":"#FFFFFFFF","subtle":"#B2FFFFFF"}   1.01.0
goodgood object 否,默认值为:{"default":"#FF008000","subtle":"#B2008000"}No, default: {"default":"#FF008000","subtle":"#B2008000"}   1.01.0
warningwarning object 否,默认值为:{"default":"#FFFFD700","subtle":"#B2FFD700"}No, default: {"default":"#FFFFD700","subtle":"#B2FFD700"}   1.01.0
attentionattention object 否,默认值为:{"default":"#FF8B0000","subtle":"#B28B0000"}No, default: {"default":"#FF8B0000","subtle":"#B28B0000"}   1.01.0

ImageSetConfigImageSetConfig

控制 ImageSet 的显示方式Controls how ImageSets are displayed

属性Property 类型Type 必需Required 说明Description 版本Version
imageSizeimageSize string 否,默认值为:"auto"No, default: "auto" 控制单个图像大小Controls individual image sizing 1.01.0
maxImageHeightmaxImageHeight integer 否,默认值为:100No, default: 100 将图像高度限制为此值Constrain image height to this value 1.01.0

ImageSizesConfigImageSizesConfig

控制 Image 大小Controls Image sizes

属性Property 类型Type 必需Required 说明Description 版本Version
smallsmall integer 否,默认值为:80No, default: 80 小型图像大小值Small image size value 1.01.0
mediummedium integer 否,默认值为:120No, default: 120 中型图像大小值Medium image size value 1.01.0
largelarge integer 否,默认值为:180No, default: 180 大型图像大小值Large image size value 1.01.0

InputsConfigInputsConfig

控制标签和错误消息的显示方式Controls how labels and error messages are displayed

属性Property 类型Type 必需Required 说明Description 版本Version
labellabel LabelConfig No 控制标签的显示方式Controls how labels are displayed 1.31.3
errorMessageerrorMessage ErrorMessageConfig No 控制错误消息的显示方式Controls how error messages are displayed 1.31.3

LabelConfigLabelConfig

控制标签的显示方式Controls how labels are displayed

属性Property 类型Type 必需Required 说明Description 版本Version
requiredInputsrequiredInputs InputLabelConfig No 控制必需输入项的标签的显示方式Controls how labels for required inputs are displayed 1.31.3
optionalInputsoptionalInputs InputLabelConfig No 控制可选输入项的标签的显示方式Controls how labels for optional inputs are displayed 1.31.3
spacingspacing string 否,默认值为:"default"No, default: "default" 标签与输入项之间的间距Spacing between the label and the input 1.31.3

InputLabelConfigInputLabelConfig

控制必需标签或可选标签的显示方式Controls how required or optional labels are displayed

属性Property 类型Type 必需Required 说明Description 版本Version
colorcolor string 否,默认值为:"default"No, default: "default" 标签的字体颜色(后缀始终以 attention 颜色呈现)Font color of the label (the suffix is always rendered in attention color) 1.31.3
isSubtleisSubtle bool 否,默认值为:falseNo, default: false 定义是否使用 subtle 前景色Defines whether to use the subtle foreground color 1.31.3
大小size string 否,默认值为:"default"No, default: "default" 要显示的标签的字体大小sizeFont size of the label to be displayed 1.31.3
suffixsuffix string 否,默认值为:"*"No, default: "*" 要在必需输入项的标签末尾显示的后缀。Suffix to be displayed at the end of the label for required inputs. 如果未定义任何后缀,则向标签追加星号 *If none is defined, an asterisk * is appended to the label 1.31.3
weightweight string 否,默认值为:"default"No, default: "default" 标签的字体粗细Font weight of the label 1.31.3

ErrorMessageConfigErrorMessageConfig

控制错误消息的显示方式。Controls how error messages are displayed. 错误消息始终以 attention 颜色显示。Error messages are always displayed with the attention color.

属性Property 类型Type 必需Required 说明Description 版本Version
spacingspacing string 否,默认值为:"default"No, default: "default" 输入项与错误消息之间的间距Spacing between the input and the error message 1.31.3
大小size string 否,默认值为:"default"No, default: "default" 错误消息的字体大小Font size of the error message 1.31.3
weightweight string 否,默认值为:"default"No, default: "default" 错误消息的字体粗细Font weight of the error message 1.31.3

MediaConfigMediaConfig

控制 Media 元素的显示和行为Controls the display and behavior of Media elements

在版本 1.1 中引入Introduced in version 1.1

属性Property 类型Type 必需Required 说明Description 版本Version
defaultPosterdefaultPoster string No 在播放按钮尚未调用时需显示的图像的 URIURI to image to display when play button hasn't been invoked 1.11.1
playButtonplayButton string No 将显示为播放按钮的图像Image to display as play button 1.11.1
allowInlinePlaybackallowInlinePlayback boolean 否,默认值为:trueNo, default: true 是以内联方式显示媒体,还是通过外部方式进行调用Whether to display media inline or invoke externally 1.11.1

SeparatorConfigSeparatorConfig

控制分隔符的显示方式Controls how separators are displayed

属性Property 类型Type 必需Required 说明Description 版本Version
lineThicknesslineThickness integer 否,默认值为:1No, default: 1 分隔线的粗细Thickness of separator line 1.01.0
lineColorlineColor string,null 否,默认值为:#B2000000No, default: #B2000000 绘制分隔线时需使用的颜色Color to use when drawing separator line 1.01.0

ShowCardConfigShowCardConfig

控制 Action.ShowCard 的行为和样式设置Controls behavior and styling of Action.ShowCard

属性Property 类型Type 必需Required 说明Description 版本Version
actionModeactionMode string 否,默认值为:"inline"No, default: "inline" 控制卡的显示方式Controls how the card is displayed 1.01.0
stylestyle object 否,默认值为:emphasisNo, default: emphasis 控制容器的样式设置Controls styling of a container 1.01.0
inlineTopMargininlineTopMargin integer 否,默认值为:16No, default: 16 显示卡片时需使用的边距Amount of margin to use when displaying the card 1.01.0

SpacingsConfigSpacingsConfig

控制元素的布局方式Controls how elements are to be laid out

属性Property 类型Type 必需Required 说明Description 版本Version
smallsmall integer 否,默认值为:3No, default: 3 小间距值Small spacing value 1.01.0
defaultdefault integer 否,默认值为:8No, default: 8 默认间距值Default spacing value 1.01.0
mediummedium integer 否,默认值为:20No, default: 20 中间距值Medium spacing value 1.01.0
largelarge integer 否,默认值为:30No, default: 30 大间距值Large spacing value 1.01.0
extraLargeextraLarge integer 否,默认值为:40No, default: 40 超大间距值Extra large spacing value 1.01.0
paddingpadding integer 否,默认值为:20No, default: 20 填充值Padding value 1.01.0

TextBlockConfigTextBlockConfig

控制文本显示的参数Parameters controlling the display of text

属性Property 类型Type 必需Required 说明Description 版本Version
大小size string 否,默认值为:"default"No, default: "default" 卡片未指定时需使用的字号Font size to use when a card doesn't specify 1.01.0
weightweight string 否,默认值为:"normal"No, default: "normal" 卡片未指定时需使用的字体粗细Font weight to use when a card doesn't specify 1.01.0
colorcolor string 否,默认值为:"default"No, default: "default" 卡片未指定时需使用的字体颜色Font color to use when a card doesn't specify 1.01.0
isSubtleisSubtle boolean 否,默认值为:falseNo, default: false 卡片未指定时文本是否为细微Should text be subtle if a card doesn't specify 1.01.0
wrapwrap boolean 否,默认值为:trueNo, default: true 卡片未指定时文本是否换行Should text wrap if a card doesn't specify 1.01.0
maxWidthmaxWidth integer 否,默认值为:0No, default: 0 卡片未指定时要使用的最大宽度Maximum width to use if a card doesn't specify 1.01.0