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 52
52
" not ie <= 10"
53
53
],
54
54
"dependencies" : {
55
- "@lobehub/chat-plugin-sdk" : " ^1.18 .0" ,
55
+ "@lobehub/chat-plugin-sdk" : " ^1.22 .0" ,
56
56
"@lobehub/chat-plugins-gateway" : " ^1" ,
57
57
"@lobehub/ui" : " latest" ,
58
58
"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' ;
6
2
import { Button } from 'antd' ;
7
3
import { memo , useEffect , useState } from 'react' ;
8
4
import { Center } from 'react-layout-kit' ;
@@ -17,22 +13,24 @@ const Render = memo(() => {
17
13
18
14
// 初始化时从主应用同步状态
19
15
useEffect ( ( ) => {
20
- fetchPluginMessage ( ) . then ( setData ) ;
16
+ lobeChat . getPluginMessage ( ) . then ( setData ) ;
21
17
} , [ ] ) ;
22
18
23
19
// 记录请求参数
24
20
const [ payload , setPayload ] = useState < any > ( ) ;
25
21
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
+ } , [ ] ) ;
31
29
32
30
const fetchData = async ( ) => {
33
31
const data = await fetchClothes ( payload ) ;
34
32
setData ( data ) ;
35
- postToFillPluginContent ( data ) ;
33
+ lobeChat . setPluginMessage ( data ) ;
36
34
} ;
37
35
38
36
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' ;
2
2
import { memo , useEffect , useState } from 'react' ;
3
3
4
4
import Data from '@/components/Render' ;
@@ -8,7 +8,7 @@ const Render = memo(() => {
8
8
const [ data , setData ] = useState < ResponseData > ( ) ;
9
9
10
10
useEffect ( ( ) => {
11
- fetchPluginMessage ( ) . then ( ( e : ResponseData ) => {
11
+ lobeChat . getPluginMessage ( ) . then ( ( e : ResponseData ) => {
12
12
setData ( e ) ;
13
13
} ) ;
14
14
} , [ ] ) ;
You can’t perform that action at this time.
0 commit comments