feat: MujianProvider

This commit is contained in:
Cledwyn Lew
2025-09-03 17:34:12 +08:00
parent 9ad63297f1
commit 4effd946a4
5 changed files with 61 additions and 20 deletions

View File

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