发布于 2022-02-07 16:38:49
本文件应该能让你开始工作。大多数基本样式都可以通过配置设置获得。
例如,文本消息的边框可以通过样式选项实现:
<!DOCTYPE html>
<head>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
</head>
<body>
<div style="height: 60%; width: 40%; margin-top:5%; margin-left:10%" id="webchat" role="main"></div>
<script>
// Set the CSS rules.
const styleSet = window.WebChat.createStyleSet({
...
bubbleBorderColor: '#E6E6E6',
bubbleBorderRadius: 2,
bubbleBorderStyle: 'solid',
bubbleBorderWidth: 1,
...
});
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({
token: '<Your Direct Line token>'}),
styleSet
}, document.getElementById('webchat'));
</script>
</body>发布于 2022-02-17 02:35:31
BotFramework-网络聊天有一个可以覆盖在以下位置的StyleOptions列表:
https://github.com/microsoft/BotFramework-WebChat/blob/main/packages/api/src/defaultStyleOptions.ts
可以使用WebChat的activityMiddleware来呈现您自己的自定义消息气泡组件:
const activityMiddleware = () => (next: any) => (...args) => {
const [card] = args;
if (card.activity) {
if (condition) {
return (
<div key={card.activity.id} className='custom-class'>
{next(card)(children)}
</div>
)
}
}
}
...
return (
<ReactWebChat
activityMiddleware={activityMiddleware}
directLine={adapter}
styleOptions={styleOptions}
/>
);https://stackoverflow.com/questions/71005239
复制相似问题