init
This commit is contained in:
@@ -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>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user