This commit is contained in:
rex
2025-09-03 15:11:11 +08:00
parent 272c87f799
commit 1e97034ebd
6 changed files with 839 additions and 31 deletions

View File

@@ -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>
</>
);