私有部署开发的内置插件,在打开历史对话记录会再次调用插件功能 #8377
Unanswered
YanHua95
asked this question in
General Question
Replies: 1 comment
-
|
你的插件在打开历史对话时会重新调用 getData,是因为 Lobe Chat 当前不会区分“历史查看模式”和“激活模式”,每次渲染消息时插件组件都会重新挂载,useEffect 里的副作用就会再次执行。这是 React 的正常行为,也是 Lobe Chat 现有插件渲染机制的结果。 目前插件渲染相关的 props(如 apiName、args、content、identifier、messageId 等)里没有任何标志可以用来判断当前是否处于历史记录查看模式,官方代码和文档也没有提供相关区分或防止副作用的机制[代码参考1] [代码参考2]。 临时的解决思路有:
根本的解决办法需要框架层面增加“模式”标志,并传递到插件组件,插件才能精准判断当前渲染场景。如果你有能力,可以考虑在主仓库提议或自行扩展实现。 To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
你好,请问私有部署后开发的内置插件,在打开历史对话记录时会再次调用插件功能后渲染页面,而不是直接将历史对话记录渲染怎么解决呢
下面是插件的ui
export default memo<BuiltinRenderProps<any>>((arg) => { useEffect(() => { getData() },[]) const getData = () => { console.log('获取数据') } return<div>123</div> }Beta Was this translation helpful? Give feedback.
All reactions