File tree Expand file tree Collapse file tree 3 files changed +13
-15
lines changed
Expand file tree Collapse file tree 3 files changed +13
-15
lines changed Original file line number Diff line number Diff line change 5252 " not ie <= 10"
5353 ],
5454 "dependencies" : {
55- "@lobehub/chat-plugin-sdk" : " ^1.18 .0" ,
55+ "@lobehub/chat-plugin-sdk" : " ^1.22 .0" ,
5656 "@lobehub/chat-plugins-gateway" : " ^1" ,
5757 "@lobehub/ui" : " latest" ,
5858 "antd" : " ^5" ,
Original file line number Diff line number Diff line change 1- import {
2- fetchPluginMessage ,
3- postToFillPluginContent ,
4- useOnStandalonePluginInit ,
5- } from '@lobehub/chat-plugin-sdk/client' ;
1+ import { lobeChat } from '@lobehub/chat-plugin-sdk/client' ;
62import { Button } from 'antd' ;
73import { memo , useEffect , useState } from 'react' ;
84import { Center } from 'react-layout-kit' ;
@@ -17,22 +13,24 @@ const Render = memo(() => {
1713
1814 // 初始化时从主应用同步状态
1915 useEffect ( ( ) => {
20- fetchPluginMessage ( ) . then ( setData ) ;
16+ lobeChat . getPluginMessage ( ) . then ( setData ) ;
2117 } , [ ] ) ;
2218
2319 // 记录请求参数
2420 const [ payload , setPayload ] = useState < any > ( ) ;
2521
26- useOnStandalonePluginInit < ResponseData > ( ( payload ) => {
27- if ( payload . func === 'recommendClothes' ) {
28- setPayload ( payload . args ) ;
29- }
30- } ) ;
22+ useEffect ( ( ) => {
23+ lobeChat . getPluginPayload ( ) . then ( ( payload ) => {
24+ if ( payload . name === 'recommendClothes' ) {
25+ setPayload ( payload . arguments ) ;
26+ }
27+ } ) ;
28+ } , [ ] ) ;
3129
3230 const fetchData = async ( ) => {
3331 const data = await fetchClothes ( payload ) ;
3432 setData ( data ) ;
35- postToFillPluginContent ( data ) ;
33+ lobeChat . setPluginMessage ( data ) ;
3634 } ;
3735
3836 return data ? (
Original file line number Diff line number Diff line change 1- import { fetchPluginMessage } from '@lobehub/chat-plugin-sdk/client' ;
1+ import { lobeChat } from '@lobehub/chat-plugin-sdk/client' ;
22import { memo , useEffect , useState } from 'react' ;
33
44import Data from '@/components/Render' ;
@@ -8,7 +8,7 @@ const Render = memo(() => {
88 const [ data , setData ] = useState < ResponseData > ( ) ;
99
1010 useEffect ( ( ) => {
11- fetchPluginMessage ( ) . then ( ( e : ResponseData ) => {
11+ lobeChat . getPluginMessage ( ) . then ( ( e : ResponseData ) => {
1212 setData ( e ) ;
1313 } ) ;
1414 } , [ ] ) ;
You can’t perform that action at this time.
0 commit comments