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,8 +1,8 @@
{ {
"mcpServers": { "mcpServers": {
"assistant-ui": { "mujian": {
"command": "npx", "command": "npx",
"args": ["-y", "@assistant-ui/mcp-docs-server"] "args": ["-y", "@mujian/mcp-docs-server"]
} }
} }
} }

View File

@@ -3,3 +3,18 @@ description:
globs: globs:
alwaysApply: false alwaysApply: false
--- ---
@tailwindcss
localforage
lodash-es
motion
react
react-dom
react-router
tailwindcss
zustand
dayjs
Axios
react-icons

View File

@@ -9,23 +9,31 @@
}, },
"packageManager": "pnpm@10.0.0", "packageManager": "pnpm@10.0.0",
"scripts": { "scripts": {
"mujian": "mujian hello world",
"dev": "vite", "dev": "vite",
"build": "tsc -b && vite build", "build": "tsc -b && vite build",
"lint": "biome check --write ./src", "lint": "biome check --write ./src",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@mujian/js-sdk": "^0.0.1",
"@tailwindcss/vite": "^4.1.12", "@tailwindcss/vite": "^4.1.12",
"postmate": "^1.5.2", "axios": "^1.11.0",
"dayjs": "^1.11.18",
"localforage": "^1.10.0",
"lodash-es": "^4.17.21",
"motion": "^12.23.12",
"react": "^19.1.1", "react": "^19.1.1",
"react-dom": "^19.1.1", "react-dom": "^19.1.1",
"react-icons": "^5.5.0",
"react-router": "^7.8.2", "react-router": "^7.8.2",
"tailwindcss": "^4.1.12", "tailwindcss": "^4.1.12",
"zustand": "^5.0.8" "zustand": "^5.0.8"
}, },
"devDependencies": { "devDependencies": {
"@mujian/cli": "^0.0.0",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.13.9", "@types/node": "^22.13.9",
"@types/postmate": "^1.5.4",
"@types/react": "^19.1.10", "@types/react": "^19.1.10",
"@types/react-dom": "^19.1.7", "@types/react-dom": "^19.1.7",
"@vitejs/plugin-react": "^5.0.0", "@vitejs/plugin-react": "^5.0.0",

805
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +1,14 @@
import Postmate from 'postmate';
import { useEffect } from 'react';
import { useGlobalStore } from '@/store/global'; import { useGlobalStore } from '@/store/global';
import './index.css'; import './index.css';
import { isEmpty } from 'lodash-es';
import { EVENT, mujian } from '@/utils/mujian';
function Home() { function Home() {
const { count, increment } = useGlobalStore((state) => state); const { count, increment } = useGlobalStore((state) => state);
console.log('count', count); console.log('count', count);
useEffect(() => { console.log('isEmpty', isEmpty(count));
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!');
});
}, []);
return ( return (
<> <>
@@ -29,6 +19,16 @@ function Home() {
<button type="button" onClick={increment}> <button type="button" onClick={increment}>
Increment Increment
</button> </button>
<button
type="button"
onClick={() => {
mujian.emit(EVENT.MUJIAN_AI_CHAT_SEND_MESSAGE, {
message: 'Hello, World!',
});
}}
>
Hello
</button>
<p>Count: {count}</p> <p>Count: {count}</p>
</> </>
); );

8
src/utils/mujian.ts Normal file
View 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 };