“自动滚动”在MicrosoftbotFramework上不起作用(基于Python SDK)

2024-06-16 08:40:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我对微软的botframework有些意见。在

我用微软的botframeworkpythonsdk做了一个聊天机器人。在

所以我把它部署为Webchat,我把它放在我的网站Wordpress上。在

但是,自动滚动卡不起作用。

当新卡出现时,自动滚动不起作用。在

所以这是我的关键问题,我真的需要别人的帮助。在

谢谢。在


Tags: 网站部署wordpress机器人意见botframeworkwebchat关键问题
2条回答

这对我有效,但我有一个奇怪的用法(directline嵌入到Sharepoint页面中,即不是绝对/固定位置):

 const store = window.WebChat.createStore(
    {},
    ({ dispatch }) => next => action => {
        if (action.type === 'DIRECT_LINE/POST_ACTIVITY_FULFILLED') {
            var scrollDiv = $('ul[role="list"]').first().parent();
            scrollDiv.scrollTop(scrollDiv[0].scrollHeight);
        }
        return next(action);
    }
  );    


  window.WebChat.renderWebChat(
  {
    directLine: window.WebChat.createDirectLine({
      token: 'mySecret'
    }),
    store,
    ...

希望它能帮助别人。在

如果不想使用jQuery,请将2个scrollDiv行替换为:

^{pr2}$

这是WebChat中已知的issue。有一个解决方法,可以使用自定义的WebChat活动中间件,当聊天窗口接收到新消息时,该中间件将最后一条消息滚动到视图中。看看下面的代码片段。在

const store = window.WebChat.createStore(
    {},
    ({ dispatch }) => next => action => {
        if (action.type === 'DIRECT_LINE/POST_ACTIVITY_FULFILLED') {
            document.querySelector('ul[role="list"]').lastChild.scrollIntoView({behavior: 'smooth', block: 'start'});
        }
        return next(action);
    }
);

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

希望这有帮助!在

相关问题 更多 >