studio
This commit is contained in:
@@ -1,24 +1,14 @@
|
||||
import Postmate from 'postmate';
|
||||
import { useEffect } from 'react';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import './index.css';
|
||||
import { isEmpty } from 'lodash-es';
|
||||
import { EVENT, mujian } from '@/utils/mujian';
|
||||
|
||||
function Home() {
|
||||
const { count, increment } = useGlobalStore((state) => state);
|
||||
|
||||
console.log('count', count);
|
||||
|
||||
useEffect(() => {
|
||||
const handshake = new Postmate.Model({
|
||||
// Expose your model to the Parent. Property values may be functions, promises, or regular values
|
||||
height: () => (document as any).height || (document.body as any).offsetHeight,
|
||||
});
|
||||
|
||||
// When parent <-> child handshake is complete, events may be emitted to the parent
|
||||
handshake.then((parent) => {
|
||||
parent.emit('some-event', 'Hello, World!');
|
||||
});
|
||||
}, []);
|
||||
console.log('isEmpty', isEmpty(count));
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -29,6 +19,16 @@ function Home() {
|
||||
<button type="button" onClick={increment}>
|
||||
Increment
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
mujian.emit(EVENT.MUJIAN_AI_CHAT_SEND_MESSAGE, {
|
||||
message: 'Hello, World!',
|
||||
});
|
||||
}}
|
||||
>
|
||||
Hello
|
||||
</button>
|
||||
<p>Count: {count}</p>
|
||||
</>
|
||||
);
|
||||
|
||||
8
src/utils/mujian.ts
Normal file
8
src/utils/mujian.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// @rule: do not modify this file
|
||||
import { EVENT, MujianSdk } from '@mujian/js-sdk';
|
||||
|
||||
const mujian = new MujianSdk();
|
||||
|
||||
await mujian.init();
|
||||
|
||||
export { mujian, EVENT };
|
||||
Reference in New Issue
Block a user