gpt4 book ai didi

javascript - BotFramework-WebChat 用占位符替换聊天头像

转载 作者:行者123 更新时间:2023-11-30 19:59:24 34 4
gpt4 key购买 nike

我想换聊天头像,还有bot的头像,但是设置背景图不行enter image description here

var styleSet = window.WebChat.createStyleSet({
backgroundColor: '#f3f3f3',
bubbleBackground: '#FFFFFF',
bubbleBorderRadius: 5,
bubbleTextColor: 'Black',
bubbleFromUserBackground: '#3a8dde',
bubbleFromUserBorderRadius: 5,
bubbleFromUserTextColor: 'White',

});
styleSet.avatar = {
alignItems: 'center',
borderRadius: '50%',
color: 'white',
backgroundColor: 'gray',


display: 'flex',
height: "50px",
justifyContent: 'center',
overflow: 'hidden',
width: "50px"
};

window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({token: 'My.Secret.token'}),
//styles
styleSet: styleSet,
botAvatarInitials: 'BF',
userAvatarInitials: 'WC'

}, document.getElementById('webchat'));

最佳答案

目前没有设置背景图片的解决方案,但有一个解决方法可以用于特殊样式,最初在 GitHub 上共享 here

import { createStyleSet } from 'botframework-webchat;

const styleSet = createStyleSet({});
styleSet.avatar = {
...styleSet.avatar,
'&.from-user': {
backgroundImage:'url(\'https://github.com/compulim.png?size=64\')'
},
'&:not(.from-user)': {
backgroundImage:'url(\'https://learn.microsoft.com/en-us/azure/bot-service/v4sdk/media/logo_bot.svg?view=azure-bot-service-4.0\')' }
};
};

<ReactWebChat
botAvatarInitials= ' '
userAvatarInitials= ' '
styleSet={styleSet}`
/>

在 JavaScript 中,您可以执行以下操作:

const styleSet = window.WebChat.createStyleSet();
styleSet.avatar = {
...styleSet.avatar,
'&.from-user': {
backgroundImage:'url(\'https://github.com/compulim.png?size=64\')'
},
'&:not(.from-user)': {
backgroundImage:'url(\'https://learn.microsoft.com/en-us/azure/bot-service/v4sdk/media/logo_bot.svg?view=azure-bot-service-4.0\')' }
};

window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token }),
styleSet,
botAvatarInitials: ' ',
userAvatarInitials: ' '
}, document.getElementById('webchat'));

关于javascript - BotFramework-WebChat 用占位符替换聊天头像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53557590/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com