This commit is contained in:
rex
2025-09-03 16:09:04 +08:00
parent 1e97034ebd
commit 9ad63297f1
2 changed files with 15 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
import { useGlobalStore } from '@/store/global'; import { useGlobalStore } from '@/store/global';
import './index.css'; import './index.css';
import { isEmpty } from 'lodash-es'; import { isEmpty } from 'lodash-es';
import { EVENT, mujian } from '@/utils/mujian'; import { EVENT, getMujian } from '@/utils/mujian';
function Home() { function Home() {
const { count, increment } = useGlobalStore((state) => state); const { count, increment } = useGlobalStore((state) => state);
@@ -10,6 +10,7 @@ function Home() {
console.log('isEmpty', isEmpty(count)); console.log('isEmpty', isEmpty(count));
return ( return (
<> <>
<div> <div>
@@ -19,17 +20,21 @@ function Home() {
<button type="button" onClick={increment}> <button type="button" onClick={increment}>
Increment Increment
</button> </button>
<p>Count: {count}</p>
<br />
<button <button
type="button" type="button"
onClick={() => { onClick={async() => {
mujian.emit(EVENT.MUJIAN_AI_CHAT_SEND_MESSAGE, { (await getMujian()).emit(EVENT.MUJIAN_AI_CHAT_SEND_MESSAGE, {
message: 'Hello, World!', message: 'Hello, World!',
}); });
}} }}
> >
Hello Hello
</button> </button>
<p>Count: {count}</p>
</> </>
); );
} }

View File

@@ -5,4 +5,9 @@ const mujian = new MujianSdk();
await mujian.init(); await mujian.init();
export { mujian, EVENT }; export { EVENT };
export const getMujian = async () => {
await mujian.init();
return mujian;
};