【问题标题】:Color of svg image stopped showing in teams message - adaptive cardsvg 图像的颜色停止在团队消息中显示 - 自适应卡
【发布时间】:2022-08-03 15:43:52
【问题描述】:

我有一个 azure 函数,每次成功部署新版本时都会发送 Teams 消息。它显示了所有交付的工作项:错误和故事。直到几个月前,我在消息中的图标还显示颜色。它已停止这样做,它只显示黑色。图像的 url 仍然显示正确的图像和颜色,因此没有任何问题。

Teams 渲染器是否发生了一些变化,或者我是否需要调整我的自适应卡片模板?

以下是我的模板:

    {
  \"type\": \"message\",
  \"attachments\": [
    {
      \"contentType\": \"application/vnd.microsoft.card.adaptive\",
      \"contentUrl\": null,
      \"content\": {
        \"type\": \"AdaptiveCard\",
        \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",
        \"version\": \"1.3\",
        \"msteams\": {
          \"width\": \"Full\"
        },
        \"body\": [
          {
            \"type\": \"ColumnSet\",
            \"columns\": [
              {
                \"type\": \"Column\",
                \"items\": [
                  {
                    \"size\": \"Large\",
                    \"type\": \"TextBlock\",
                    \"text\": \"${ReleaseTitle}\",
                    \"weight\": \"Bolder\"
                  }
                ],
                \"width\": \"stretch\"
              }
            ]
          },
          {
            \"type\": \"ColumnSet\",
            \"columns\": [
              {
                \"type\": \"Column\",
                \"width\": \"auto\",
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"[Go to query](${QueryUrl})\",
                    \"isSubtle\": true,
                    \"height\": \"stretch\"
                  }
                ]
              },
              {
                \"$when\": \"${ShowAdditionalQuery == true}\",
                \"type\": \"Column\",
                \"width\": \"auto\",
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"[additional query](${AdditionalQueryUrl})\",
                    \"isSubtle\": true,
                    \"height\": \"stretch\"
                  }
                ]
              }
            ]
          },
          {
            \"separator\": true,
            \"text\": \"\",
            \"type\": \"TextBlock\"
          },
          {
            \"$when\": \"${$root.UserStories.Count > 0}\",
            \"type\": \"ColumnSet\",
            \"columns\": [
              {
                \"type\": \"Column\",
                \"items\": [
                  {
                    \"type\": \"Image\",
                    \"url\": \"https://tfsprodweusu4.visualstudio.com/_apis/wit/workItemIcons/icon_book?v=2&color=0098C7\",
                    \"width\": \"20px\"
                  }
                ],
                \"width\": \"auto\"
              },
              {
                \"type\": \"Column\",
                \"width\": \"stretch\",
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"User Stories\",
                    \"weight\": \"Bolder\"
                  }
                ]
              }
            ]
          },
          {
            \"$when\": \"${$root.UserStories.Count > 0}\",
            \"type\": \"ColumnSet\",
            \"columns\": [
              {
                \"type\": \"Column\",
                \"width\": 4,
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"[${WorkItemId} - ${Title}](${Url})\",
                    \"isSubtle\": true
                  }
                ]
              },
              {
                \"type\": \"Column\",
                \"width\": 1,
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"${State}\",
                    \"isSubtle\": true
                  }
                ]
              }
            ],
            \"$data\": \"${$root.UserStories}\"
          },
          {
            \"$when\": \"${$root.Bugs.Count > 0}\",
            \"type\": \"ColumnSet\",
            \"columns\": [
              {
                \"type\": \"Column\",
                \"items\": [
                  {
                    \"type\": \"Image\",
                    \"url\": \"https://tfsprodweusu4.visualstudio.com/_apis/wit/workItemIcons/icon_insect?v=2&color=CC293D\",
                    \"width\": \"20px\"
                  }
                ],
                \"width\": \"auto\"
              },
              {
                \"type\": \"Column\",
                \"width\": \"stretch\",
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"Bugfixes\",
                    \"weight\": \"Bolder\"
                  }
                ]
              }
            ]
          },
          {
            \"$when\": \"${$root.Bugs.Count > 0}\",
            \"type\": \"ColumnSet\",
            \"columns\": [
              {
                \"type\": \"Column\",
                \"width\": 4,
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"[${WorkItemId} - ${Title}](${Url})\",
                    \"isSubtle\": true
                  }
                ]
              },
              {
                \"type\": \"Column\",
                \"width\": 1,
                \"items\": [
                  {
                    \"type\": \"TextBlock\",
                    \"text\": \"${State}\",
                    \"isSubtle\": true
                  }
                ]
              }
            ],
            \"$data\": \"${$root.Bugs}\"
          }
        ]
      }

    }
  ]
}

任何帮助将不胜感激

  • 您能否分享图标(图片)的公共网址。这样我们就可以在最后本地检查它。
  • 我们能够重现这个问题。我们为此提出了一个错误。如果有任何更新,我们会通知您。
  • 关于这个@Meghana-MSFT 的任何消息?
  • 由于后端代码中有关允许的 SVG 格式的限制,工程团队已指示使用以下 URL,tfsprodweusu4.visualstudio.com/_apis/wit/workItemIcons/… 团队还将进行后端更改以适应任一格式,因此不限于此格式。

标签: svg microsoft-teams adaptive-cards


【解决方案1】:

正如 Meghana-MSFT 所指出的:

更改“v”和“color”查询字符串参数的位置可以解决此问题。

例如 旧的(不工作 - 没有颜色) https://tfsprodweusu4.visualstudio.com/_apis/wit/workItemIcons/icon_book?v=2&color=0098C7

新的(工作 - 有颜色) https://tfsprodweusu4.visualstudio.com/_apis/wit/workItemIcons/icon_book?color=0098C7&v=2

【讨论】:

    猜你喜欢
    • 2021-11-12
    • 2019-12-24
    • 1970-01-01
    • 2020-05-18
    • 2020-08-13
    • 1970-01-01
    • 2019-10-19
    • 2021-03-08
    • 1970-01-01
    相关资源
    最近更新 更多