Compare commits
7 Commits
2c34c157f1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0f4d4507f | ||
|
|
38c2f8e6dd | ||
|
|
9b5fcf9190 | ||
|
|
39c373ba2c | ||
|
|
5c36caa07b | ||
|
|
9b472109e9 | ||
|
|
243a22794c |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"mujian": {
|
||||
"mujian-js-sdk": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@mujian/mcp-docs-server"]
|
||||
}
|
||||
|
||||
28
README.md
28
README.md
@@ -1,5 +1,25 @@
|
||||
# Mujian 作品模版工程
|
||||
# 幕间自定义界面-官方模版-React版
|
||||
|
||||
[幕间官网](https://mujian.ai)
|
||||
[幕间文档站](https://docs.mujian.ai)
|
||||
[幕间SDK](https://docs.mujian.ai/creator/sdk/introduction.html)
|
||||
- [幕间官网](https://mujian.ai)
|
||||
- [幕间文档站](https://docs.mujian.ai)
|
||||
- [幕间SDK](https://docs.mujian.ai/creator/sdk/introduction.html)
|
||||
- [教程地址](https://docs.mujian.ai/creator/game-dev/quick-start.html)
|
||||
- [仓库地址](https://git.mujian.me/mujian/react-boilerplate)
|
||||
|
||||
1. 初始化项目,安装依赖
|
||||
|
||||
```sh
|
||||
pnpm i
|
||||
```
|
||||
|
||||
2. 本地开发
|
||||
|
||||
```sh
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
3. 打包
|
||||
|
||||
```sh
|
||||
pnpm build
|
||||
```
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React + TS</title>
|
||||
<title>幕间自定义界面模版 React版</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
},
|
||||
"packageManager": "pnpm@10.0.0",
|
||||
"scripts": {
|
||||
"mujian": "mujian hello world",
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "biome check --write ./src",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mujian/js-sdk": "^0.0.1",
|
||||
"@mujian/js-sdk": "^0.0.6-beta.45",
|
||||
"@tailwindcss/vite": "^4.1.12",
|
||||
"axios": "^1.11.0",
|
||||
"dayjs": "^1.11.18",
|
||||
@@ -37,7 +36,9 @@
|
||||
"@types/react": "^19.1.10",
|
||||
"@types/react-dom": "^19.1.7",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"clsx": "^2.1.1",
|
||||
"globals": "^16.3.0",
|
||||
"tailwind-merge": "^3.4.0",
|
||||
"typescript": "~5.8.3",
|
||||
"vite": "^7.1.2"
|
||||
}
|
||||
|
||||
171
pnpm-lock.yaml
generated
171
pnpm-lock.yaml
generated
@@ -9,8 +9,8 @@ importers:
|
||||
.:
|
||||
dependencies:
|
||||
'@mujian/js-sdk':
|
||||
specifier: ^0.0.1
|
||||
version: 0.0.1
|
||||
specifier: ^0.0.6-beta.45
|
||||
version: 0.0.6-beta.45(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||
'@tailwindcss/vite':
|
||||
specifier: ^4.1.12
|
||||
version: 4.1.12(vite@7.1.3(@types/node@22.18.0)(jiti@2.5.1)(lightningcss@1.30.1))
|
||||
@@ -66,9 +66,15 @@ importers:
|
||||
'@vitejs/plugin-react':
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.2(vite@7.1.3(@types/node@22.18.0)(jiti@2.5.1)(lightningcss@1.30.1))
|
||||
clsx:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
globals:
|
||||
specifier: ^16.3.0
|
||||
version: 16.3.0
|
||||
tailwind-merge:
|
||||
specifier: ^3.4.0
|
||||
version: 3.4.0
|
||||
typescript:
|
||||
specifier: ~5.8.3
|
||||
version: 5.8.3
|
||||
@@ -78,6 +84,9 @@ importers:
|
||||
|
||||
packages:
|
||||
|
||||
'@adobe/css-tools@4.4.4':
|
||||
resolution: {integrity: sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==}
|
||||
|
||||
'@ampproject/remapping@2.3.0':
|
||||
resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
@@ -153,6 +162,10 @@ packages:
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
|
||||
'@babel/runtime@7.28.4':
|
||||
resolution: {integrity: sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/template@7.27.2':
|
||||
resolution: {integrity: sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@@ -346,8 +359,11 @@ packages:
|
||||
engines: {node: '>=18.0.0'}
|
||||
hasBin: true
|
||||
|
||||
'@mujian/js-sdk@0.0.1':
|
||||
resolution: {integrity: sha512-tJK+VL6pfsb5Gmoqtlb9yuYaX2p0SGoYxqS/8reKbu5uI7pK9uO9rHU+A7z94YCwOIDdiIefNCCrtgbTcMVMfg==}
|
||||
'@mujian/js-sdk@0.0.6-beta.45':
|
||||
resolution: {integrity: sha512-TpYyME3gk8wGha8xLDgpkO7QyLS0rE5lkvRp8fJAEeP/Tk+Ntjd/6RqAT30f/eNs1aJeUQ4JQ4tZyQaMMlQC8Q==}
|
||||
peerDependencies:
|
||||
react: ~19.1.1
|
||||
react-dom: ~19.1.1
|
||||
|
||||
'@oclif/core@4.5.2':
|
||||
resolution: {integrity: sha512-eQcKyrEcDYeZJKu4vUWiu0ii/1Gfev6GF4FsLSgNez5/+aQyAUCjg3ZWlurf491WiYZTXCWyKAxyPWk8DKv2MA==}
|
||||
@@ -584,6 +600,9 @@ packages:
|
||||
'@types/estree@1.0.8':
|
||||
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
||||
|
||||
'@types/js-cookie@3.0.6':
|
||||
resolution: {integrity: sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==}
|
||||
|
||||
'@types/lodash-es@4.17.12':
|
||||
resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==}
|
||||
|
||||
@@ -601,12 +620,22 @@ packages:
|
||||
'@types/react@19.1.12':
|
||||
resolution: {integrity: sha512-cMoR+FoAf/Jyq6+Df2/Z41jISvGZZ2eTlnsaJRptmZ76Caldwy1odD4xTr/gNV9VLj0AWgg/nmkevIyUfIIq5w==}
|
||||
|
||||
'@types/trusted-types@2.0.7':
|
||||
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
|
||||
|
||||
'@vitejs/plugin-react@5.0.2':
|
||||
resolution: {integrity: sha512-tmyFgixPZCx2+e6VO9TNITWcCQl8+Nl/E8YbAyPVv85QCc7/A3JrdfG2A8gIzvVhWuzMOVrFW1aReaNxrI6tbw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
peerDependencies:
|
||||
vite: ^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
|
||||
|
||||
ahooks@3.9.5:
|
||||
resolution: {integrity: sha512-TrjXie49Q8HuHKTa84Fm9A+famMDAG1+7a9S9Gq6RQ0h90Jgqmiq3CkObuRjWT/C4d6nRZCw35Y2k2fmybb5eA==}
|
||||
engines: {node: '>=18'}
|
||||
peerDependencies:
|
||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||
|
||||
ansi-escapes@4.3.2:
|
||||
resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -662,6 +691,10 @@ packages:
|
||||
resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
clsx@2.1.1:
|
||||
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
color-convert@2.0.1:
|
||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||
engines: {node: '>=7.0.0'}
|
||||
@@ -673,6 +706,10 @@ packages:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
commander@9.5.0:
|
||||
resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==}
|
||||
engines: {node: ^12.20.0 || >=14}
|
||||
|
||||
convert-source-map@2.0.0:
|
||||
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
||||
|
||||
@@ -703,6 +740,9 @@ packages:
|
||||
resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
dompurify@3.3.0:
|
||||
resolution: {integrity: sha512-r+f6MYR1gGN1eJv0TVQbhA7if/U7P87cdPl3HN5rikqaBSBxLiCb/b9O+2eG0cxz0ghyU+mU1QkbsOwERMYlWQ==}
|
||||
|
||||
dunder-proto@1.0.1:
|
||||
resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -852,6 +892,10 @@ packages:
|
||||
resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
intersection-observer@0.12.2:
|
||||
resolution: {integrity: sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==}
|
||||
deprecated: The Intersection Observer polyfill is no longer needed and can safely be removed. Intersection Observer has been Baseline since 2019.
|
||||
|
||||
is-docker@2.2.1:
|
||||
resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -878,6 +922,10 @@ packages:
|
||||
resolution: {integrity: sha512-twQoecYPiVA5K/h6SxtORw/Bs3ar+mLUtoPSc7iMXzQzK8d7eJ/R09wmTwAjiamETn1cXYPGfNnu7DMoHgu12w==}
|
||||
hasBin: true
|
||||
|
||||
js-cookie@3.0.5:
|
||||
resolution: {integrity: sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
js-tokens@4.0.0:
|
||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||
|
||||
@@ -972,6 +1020,9 @@ packages:
|
||||
lodash-es@4.17.21:
|
||||
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
||||
|
||||
lodash@4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
|
||||
lru-cache@10.4.3:
|
||||
resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}
|
||||
|
||||
@@ -1161,6 +1212,9 @@ packages:
|
||||
peerDependencies:
|
||||
react: ^19.1.1
|
||||
|
||||
react-fast-compare@3.2.2:
|
||||
resolution: {integrity: sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==}
|
||||
|
||||
react-icons@5.5.0:
|
||||
resolution: {integrity: sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==}
|
||||
peerDependencies:
|
||||
@@ -1184,6 +1238,9 @@ packages:
|
||||
resolution: {integrity: sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
resize-observer-polyfill@1.5.1:
|
||||
resolution: {integrity: sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==}
|
||||
|
||||
rollup@4.49.0:
|
||||
resolution: {integrity: sha512-3IVq0cGJ6H7fKXXEdVt+RcYvRCt8beYY9K1760wGQwSAHZcS9eot1zDG5axUbcp/kWRi5zKIIDX8MoKv/TzvZA==}
|
||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||
@@ -1192,6 +1249,10 @@ packages:
|
||||
scheduler@0.26.0:
|
||||
resolution: {integrity: sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==}
|
||||
|
||||
screenfull@5.2.0:
|
||||
resolution: {integrity: sha512-9BakfsO2aUQN2K9Fdbj87RJIEZ82Q9IGim7FqM5OsebfoFC6ZHXgDq/KvniuLTPdeM8wY2o6Dj3WQ7KeQCj3cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
semver@6.3.1:
|
||||
resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}
|
||||
hasBin: true
|
||||
@@ -1204,6 +1265,10 @@ packages:
|
||||
set-cookie-parser@2.7.1:
|
||||
resolution: {integrity: sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==}
|
||||
|
||||
showdown@2.1.0:
|
||||
resolution: {integrity: sha512-/6NVYu4U819R2pUIk79n67SYgJHWCce0a5xTP979WbNp0FL9MN1I1QK662IDU1b6JzKTvmhgI7T7JYIxBi3kMQ==}
|
||||
hasBin: true
|
||||
|
||||
source-map-js@1.2.1:
|
||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -1220,6 +1285,9 @@ packages:
|
||||
resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
tailwind-merge@3.4.0:
|
||||
resolution: {integrity: sha512-uSaO4gnW+b3Y2aWoWfFpX62vn2sR3skfhbjsEnaBI81WD1wBLlHZe5sWf0AqjksNdYTbGBEd0UasQMT3SNV15g==}
|
||||
|
||||
tailwindcss@4.1.12:
|
||||
resolution: {integrity: sha512-DzFtxOi+7NsFf7DBtI3BJsynR+0Yp6etH+nRPTbpWnS2pZBaSksv/JGctNwSWzbFjp0vxSqknaUylseZqMDGrA==}
|
||||
|
||||
@@ -1256,10 +1324,34 @@ packages:
|
||||
peerDependencies:
|
||||
browserslist: '>= 4.21.0'
|
||||
|
||||
uuid@13.0.0:
|
||||
resolution: {integrity: sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==}
|
||||
hasBin: true
|
||||
|
||||
validate-npm-package-name@5.0.1:
|
||||
resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==}
|
||||
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
|
||||
|
||||
virtua@0.45.3:
|
||||
resolution: {integrity: sha512-+nW3VOwXhlte3m4jbS9gVMked/cZo95IKChH0qol+XUApQVZpPaLDGee1BC/rVng0tsMfxs0vJPEPEUAAfKpkw==}
|
||||
peerDependencies:
|
||||
react: '>=16.14.0'
|
||||
react-dom: '>=16.14.0'
|
||||
solid-js: '>=1.0'
|
||||
svelte: '>=5.0'
|
||||
vue: '>=3.2'
|
||||
peerDependenciesMeta:
|
||||
react:
|
||||
optional: true
|
||||
react-dom:
|
||||
optional: true
|
||||
solid-js:
|
||||
optional: true
|
||||
svelte:
|
||||
optional: true
|
||||
vue:
|
||||
optional: true
|
||||
|
||||
vite@7.1.3:
|
||||
resolution: {integrity: sha512-OOUi5zjkDxYrKhTV3V7iKsoS37VUM7v40+HuwEmcrsf11Cdx9y3DIr2Px6liIcZFwt3XSRpQvFpL3WVy7ApkGw==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
@@ -1348,6 +1440,8 @@ packages:
|
||||
|
||||
snapshots:
|
||||
|
||||
'@adobe/css-tools@4.4.4': {}
|
||||
|
||||
'@ampproject/remapping@2.3.0':
|
||||
dependencies:
|
||||
'@jridgewell/gen-mapping': 0.3.13
|
||||
@@ -1442,6 +1536,8 @@ snapshots:
|
||||
'@babel/core': 7.28.3
|
||||
'@babel/helper-plugin-utils': 7.27.1
|
||||
|
||||
'@babel/runtime@7.28.4': {}
|
||||
|
||||
'@babel/template@7.27.2':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.27.1
|
||||
@@ -1574,9 +1670,21 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@mujian/js-sdk@0.0.1':
|
||||
'@mujian/js-sdk@0.0.6-beta.45(react-dom@19.1.1(react@19.1.1))(react@19.1.1)':
|
||||
dependencies:
|
||||
'@adobe/css-tools': 4.4.4
|
||||
ahooks: 3.9.5(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||
dompurify: 3.3.0
|
||||
postmate: 1.5.2
|
||||
react: 19.1.1
|
||||
react-dom: 19.1.1(react@19.1.1)
|
||||
showdown: 2.1.0
|
||||
uuid: 13.0.0
|
||||
virtua: 0.45.3(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||
transitivePeerDependencies:
|
||||
- solid-js
|
||||
- svelte
|
||||
- vue
|
||||
|
||||
'@oclif/core@4.5.2':
|
||||
dependencies:
|
||||
@@ -1775,6 +1883,8 @@ snapshots:
|
||||
|
||||
'@types/estree@1.0.8': {}
|
||||
|
||||
'@types/js-cookie@3.0.6': {}
|
||||
|
||||
'@types/lodash-es@4.17.12':
|
||||
dependencies:
|
||||
'@types/lodash': 4.17.20
|
||||
@@ -1793,6 +1903,9 @@ snapshots:
|
||||
dependencies:
|
||||
csstype: 3.1.3
|
||||
|
||||
'@types/trusted-types@2.0.7':
|
||||
optional: true
|
||||
|
||||
'@vitejs/plugin-react@5.0.2(vite@7.1.3(@types/node@22.18.0)(jiti@2.5.1)(lightningcss@1.30.1))':
|
||||
dependencies:
|
||||
'@babel/core': 7.28.3
|
||||
@@ -1805,6 +1918,21 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
ahooks@3.9.5(react-dom@19.1.1(react@19.1.1))(react@19.1.1):
|
||||
dependencies:
|
||||
'@babel/runtime': 7.28.4
|
||||
'@types/js-cookie': 3.0.6
|
||||
dayjs: 1.11.18
|
||||
intersection-observer: 0.12.2
|
||||
js-cookie: 3.0.5
|
||||
lodash: 4.17.21
|
||||
react: 19.1.1
|
||||
react-dom: 19.1.1(react@19.1.1)
|
||||
react-fast-compare: 3.2.2
|
||||
resize-observer-polyfill: 1.5.1
|
||||
screenfull: 5.2.0
|
||||
tslib: 2.8.1
|
||||
|
||||
ansi-escapes@4.3.2:
|
||||
dependencies:
|
||||
type-fest: 0.21.3
|
||||
@@ -1857,6 +1985,8 @@ snapshots:
|
||||
|
||||
cli-spinners@2.9.2: {}
|
||||
|
||||
clsx@2.1.1: {}
|
||||
|
||||
color-convert@2.0.1:
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
@@ -1867,6 +1997,8 @@ snapshots:
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
|
||||
commander@9.5.0: {}
|
||||
|
||||
convert-source-map@2.0.0: {}
|
||||
|
||||
cookie@1.0.2: {}
|
||||
@@ -1885,6 +2017,10 @@ snapshots:
|
||||
|
||||
detect-libc@2.0.4: {}
|
||||
|
||||
dompurify@3.3.0:
|
||||
optionalDependencies:
|
||||
'@types/trusted-types': 2.0.7
|
||||
|
||||
dunder-proto@1.0.1:
|
||||
dependencies:
|
||||
call-bind-apply-helpers: 1.0.2
|
||||
@@ -2032,6 +2168,8 @@ snapshots:
|
||||
|
||||
indent-string@4.0.0: {}
|
||||
|
||||
intersection-observer@0.12.2: {}
|
||||
|
||||
is-docker@2.2.1: {}
|
||||
|
||||
is-fullwidth-code-point@3.0.0: {}
|
||||
@@ -2050,6 +2188,8 @@ snapshots:
|
||||
|
||||
jiti@2.5.1: {}
|
||||
|
||||
js-cookie@3.0.5: {}
|
||||
|
||||
js-tokens@4.0.0: {}
|
||||
|
||||
jsesc@3.1.0: {}
|
||||
@@ -2113,6 +2253,8 @@ snapshots:
|
||||
|
||||
lodash-es@4.17.21: {}
|
||||
|
||||
lodash@4.17.21: {}
|
||||
|
||||
lru-cache@10.4.3: {}
|
||||
|
||||
lru-cache@5.1.1:
|
||||
@@ -2205,6 +2347,8 @@ snapshots:
|
||||
react: 19.1.1
|
||||
scheduler: 0.26.0
|
||||
|
||||
react-fast-compare@3.2.2: {}
|
||||
|
||||
react-icons@5.5.0(react@19.1.1):
|
||||
dependencies:
|
||||
react: 19.1.1
|
||||
@@ -2221,6 +2365,8 @@ snapshots:
|
||||
|
||||
react@19.1.1: {}
|
||||
|
||||
resize-observer-polyfill@1.5.1: {}
|
||||
|
||||
rollup@4.49.0:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.8
|
||||
@@ -2249,12 +2395,18 @@ snapshots:
|
||||
|
||||
scheduler@0.26.0: {}
|
||||
|
||||
screenfull@5.2.0: {}
|
||||
|
||||
semver@6.3.1: {}
|
||||
|
||||
semver@7.7.2: {}
|
||||
|
||||
set-cookie-parser@2.7.1: {}
|
||||
|
||||
showdown@2.1.0:
|
||||
dependencies:
|
||||
commander: 9.5.0
|
||||
|
||||
source-map-js@1.2.1: {}
|
||||
|
||||
string-width@4.2.3:
|
||||
@@ -2271,6 +2423,8 @@ snapshots:
|
||||
dependencies:
|
||||
has-flag: 4.0.0
|
||||
|
||||
tailwind-merge@3.4.0: {}
|
||||
|
||||
tailwindcss@4.1.12: {}
|
||||
|
||||
tapable@2.2.3: {}
|
||||
@@ -2303,8 +2457,15 @@ snapshots:
|
||||
escalade: 3.2.0
|
||||
picocolors: 1.1.1
|
||||
|
||||
uuid@13.0.0: {}
|
||||
|
||||
validate-npm-package-name@5.0.1: {}
|
||||
|
||||
virtua@0.45.3(react-dom@19.1.1(react@19.1.1))(react@19.1.1):
|
||||
optionalDependencies:
|
||||
react: 19.1.1
|
||||
react-dom: 19.1.1(react@19.1.1)
|
||||
|
||||
vite@7.1.3(@types/node@22.18.0)(jiti@2.5.1)(lightningcss@1.30.1):
|
||||
dependencies:
|
||||
esbuild: 0.25.9
|
||||
|
||||
20
src/components/Button/index.tsx
Normal file
20
src/components/Button/index.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
|
||||
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export const Button: React.FC<ButtonProps> = ({
|
||||
children,
|
||||
className = '',
|
||||
...props
|
||||
}) => {
|
||||
return (
|
||||
<button
|
||||
className={`px-4 py-1 rounded-md font-medium transition-colors ${className} ${props.disabled ? 'opacity-50 cursor-not-allowed' : 'hover:opacity-80'}`}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
@@ -1 +1,2 @@
|
||||
export * from './Button';
|
||||
export * from './Example';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import '@/styles/fonts.css';
|
||||
import '@/styles/global.css';
|
||||
import { MujianProvider } from './providers/MujianProvider.tsx';
|
||||
import { MujianProvider } from '@mujian/js-sdk/react';
|
||||
import { ReactRouterProvider } from './providers/RouterProvider.tsx';
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import './index.css';
|
||||
// import { useGlobalStore } from "@/store/global";
|
||||
|
||||
function About() {
|
||||
// const { count, increment } = useGlobalStore((state) => state);
|
||||
|
||||
return <div>about page</div>;
|
||||
}
|
||||
|
||||
export default About;
|
||||
133
src/pages/chat/index.tsx
Normal file
133
src/pages/chat/index.tsx
Normal file
@@ -0,0 +1,133 @@
|
||||
import { useChat, useMujian } from '@mujian/js-sdk/react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { Button } from '@/components';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import { cn } from '@/utils/cn';
|
||||
|
||||
// import { useGlobalStore } from "@/store/global";
|
||||
|
||||
function Chat() {
|
||||
const { init } = useGlobalStore();
|
||||
const mujian = useMujian();
|
||||
const navigate = useNavigate();
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
const messagesContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
init(mujian);
|
||||
}, []);
|
||||
|
||||
// const { count, increment } = useGlobalStore((state) => state);
|
||||
|
||||
// 调用消息 SDK,获取消息列表、状态、错误信息、添加消息、停止消息
|
||||
const { messages, status, error, append, stop } = useChat({
|
||||
onError: (e) => {
|
||||
console.error(e);
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (messagesContainerRef.current) {
|
||||
messagesContainerRef.current?.scrollTo({
|
||||
top: messagesContainerRef.current.scrollHeight,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
}, [messages]);
|
||||
|
||||
// 发送按钮
|
||||
const handleSend = () => {
|
||||
append(inputValue);
|
||||
setInputValue('');
|
||||
};
|
||||
|
||||
// 停止按钮
|
||||
const handleStop = () => {
|
||||
stop();
|
||||
};
|
||||
|
||||
// 输入框变化
|
||||
const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
setInputValue(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col justify-center items-center h-screen">
|
||||
<div className="font-bold mb-2">
|
||||
这里是首页{' '}
|
||||
<Button
|
||||
className="bg-blue-500 hover:bg-blue-600 text-white rounded-lg"
|
||||
onClick={() => navigate('/second')}
|
||||
>
|
||||
进入第二个页面
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="w-full flex flex-col gap-2 h-[calc(100vh-140px)] max-h-[calc(100vh-140px)] overflow-y-auto px-2"
|
||||
ref={messagesContainerRef}
|
||||
>
|
||||
{messages.map((message) =>
|
||||
message.role === 'user' ? (
|
||||
<div
|
||||
key={message.id}
|
||||
className="text-right p-2 rounded-md bg-red-500/30 text-white w-fit self-end"
|
||||
>
|
||||
User: {message.content}
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
key={message.id}
|
||||
className={cn(
|
||||
'text-left p-2 rounded-md bg-green-500/30 text-white w-fit self-start',
|
||||
message.id === messages[messages.length - 1].id &&
|
||||
status === 'streaming' &&
|
||||
'animate-pulse',
|
||||
)}
|
||||
>
|
||||
Assistant: {message.content || '思考中...'}
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="w-full flex flex-col gap-2 pt-2">
|
||||
<textarea
|
||||
rows={3}
|
||||
placeholder="请输入内容"
|
||||
className="border-2 border-gray-300 rounded-md p-2 w-full"
|
||||
value={inputValue}
|
||||
onChange={handleInputChange}
|
||||
/>
|
||||
<div className="flex gap-2 justify-between">
|
||||
当前状态: {status}
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
className="bg-blue-500 hover:bg-blue-600 text-white rounded-lg"
|
||||
onClick={handleSend}
|
||||
onKeyDown={(e) => {
|
||||
// 按下回车键发送消息
|
||||
if (e.key === 'Enter') {
|
||||
handleSend();
|
||||
}
|
||||
}}
|
||||
disabled={status === 'streaming'}
|
||||
>
|
||||
发送
|
||||
</Button>
|
||||
<Button
|
||||
className="bg-red-500 hover:bg-red-600 text-white rounded-lg"
|
||||
onClick={handleStop}
|
||||
disabled={status !== 'streaming'}
|
||||
>
|
||||
停止
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Chat;
|
||||
@@ -1,18 +0,0 @@
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import './index.css';
|
||||
import { isEmpty } from 'lodash-es';
|
||||
import { Button } from '@/components';
|
||||
|
||||
function Home() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<div className="text-3xl font-bold underline">Hello World2</div>
|
||||
</div>
|
||||
<Button>Click me</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Home;
|
||||
1
src/pages/second/index.css
Normal file
1
src/pages/second/index.css
Normal file
@@ -0,0 +1 @@
|
||||
/* 首页样式 */
|
||||
30
src/pages/second/index.tsx
Normal file
30
src/pages/second/index.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import './index.css';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { Button } from '@/components';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
|
||||
function Second() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { projectInfo, activePersona } = useGlobalStore();
|
||||
return (
|
||||
<div className="flex flex-col justify-center items-center h-screen">
|
||||
<div className="text-2xl font-bold mb-4">这里是第二个页面</div>
|
||||
<Button
|
||||
className="bg-green-500 hover:bg-green-600 text-white rounded-lg"
|
||||
onClick={() => navigate('/')}
|
||||
>
|
||||
返回首页
|
||||
</Button>
|
||||
<div className="w-full max-w-md">
|
||||
<pre className="text-xs text-wrap">{JSON.stringify(projectInfo, null, 2)}</pre>
|
||||
</div>
|
||||
|
||||
<div className="w-full max-w-md">
|
||||
<pre className="text-xs text-wrap">{JSON.stringify(activePersona, null, 2)}</pre>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Second;
|
||||
@@ -1,16 +1,16 @@
|
||||
import { createBrowserRouter } from 'react-router';
|
||||
import { RouterProvider } from 'react-router/dom';
|
||||
import About from '@/pages/about';
|
||||
import Home from '@/pages/home';
|
||||
import Chat from '@/pages/chat';
|
||||
import Second from '@/pages/second';
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
path: '/',
|
||||
element: <Home />,
|
||||
element: <Chat />,
|
||||
},
|
||||
{
|
||||
path: '/about',
|
||||
element: <About />,
|
||||
path: '/second',
|
||||
element: <Second />,
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
import type { MujianSdk } from '@mujian/js-sdk';
|
||||
import type { PersonaInfo, ProjectInfo } from '@mujian/js-sdk/types';
|
||||
import { create } from 'zustand';
|
||||
|
||||
type GlobalState = {
|
||||
count: number;
|
||||
increment: () => void;
|
||||
projectInfo: ProjectInfo | null;
|
||||
activePersona: PersonaInfo | null;
|
||||
init: (mujian: MujianSdk) => Promise<void>;
|
||||
};
|
||||
|
||||
export const useGlobalStore = create<GlobalState>((set) => ({
|
||||
count: 0,
|
||||
increment: () => {
|
||||
console.log('increment');
|
||||
set((state) => ({ count: state.count + 1 }));
|
||||
projectInfo: null,
|
||||
activePersona: null,
|
||||
|
||||
init: async (mujian: MujianSdk) => {
|
||||
const [projectInfo, persona] = await Promise.all([
|
||||
mujian.ai.chat.project.getInfo(),
|
||||
mujian.ai.chat.settings.persona.getActive(),
|
||||
]);
|
||||
set({ projectInfo, activePersona: persona });
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* 全局样式 */
|
||||
|
||||
@import "tailwindcss";
|
||||
|
||||
:root {
|
||||
|
||||
6
src/utils/cn.ts
Normal file
6
src/utils/cn.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { type ClassValue, clsx } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
export const cn = (...inputs: ClassValue[]) => {
|
||||
return twMerge(clsx(inputs));
|
||||
};
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"erasableSyntaxOnly": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true,
|
||||
"baseUrl": ".",
|
||||
|
||||
@@ -11,4 +11,7 @@ export default defineConfig({
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
cors: true,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user