This commit is contained in:
Cledwyn Lew
2025-11-27 18:44:14 +08:00
parent 54f9dc947d
commit 8f084dc75d
4 changed files with 24 additions and 12 deletions

View File

@@ -18,7 +18,7 @@
"dependencies": { "dependencies": {
"@heroui/react": "2.8.3", "@heroui/react": "2.8.3",
"@heroui/theme": "2.4.21", "@heroui/theme": "2.4.21",
"@mujian/js-sdk": "0.0.6-beta.33", "@mujian/js-sdk": "0.0.6-beta.41",
"@tailwindcss/vite": "4.1.12", "@tailwindcss/vite": "4.1.12",
"ahooks": "3.9.5", "ahooks": "3.9.5",
"axios": "1.11.0", "axios": "1.11.0",

10
pnpm-lock.yaml generated
View File

@@ -15,8 +15,8 @@ importers:
specifier: 2.4.21 specifier: 2.4.21
version: 2.4.21(tailwindcss@4.1.12) version: 2.4.21(tailwindcss@4.1.12)
'@mujian/js-sdk': '@mujian/js-sdk':
specifier: 0.0.6-beta.33 specifier: 0.0.6-beta.41
version: 0.0.6-beta.33(react-dom@19.1.1(react@19.1.1))(react@19.1.1) version: 0.0.6-beta.41(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
'@tailwindcss/vite': '@tailwindcss/vite':
specifier: 4.1.12 specifier: 4.1.12
version: 4.1.12(vite@7.1.2(@types/node@22.13.9)(jiti@2.5.1)(lightningcss@1.30.1)) version: 4.1.12(vite@7.1.2(@types/node@22.13.9)(jiti@2.5.1)(lightningcss@1.30.1))
@@ -951,8 +951,8 @@ packages:
engines: {node: '>=18.0.0'} engines: {node: '>=18.0.0'}
hasBin: true hasBin: true
'@mujian/js-sdk@0.0.6-beta.33': '@mujian/js-sdk@0.0.6-beta.41':
resolution: {integrity: sha512-x2pT2rD3c1njXMbyPpVGMuA2mhN4qZ6bKtyUCKaOiqKPsj0U7VzCBcMBu2PvJWEFTCGfkvxNWRLRe6ebVg/uew==} resolution: {integrity: sha512-D61IblTK5h7LfL/4maeikxRkNzq+SVGDVPY18MBCKfJ8c+AEvaEM3QKnq9V0ytAQikV8oA+sOnJkAgmwXxEFTQ==}
peerDependencies: peerDependencies:
react: ~19.1.1 react: ~19.1.1
react-dom: ~19.1.1 react-dom: ~19.1.1
@@ -4471,7 +4471,7 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
'@mujian/js-sdk@0.0.6-beta.33(react-dom@19.1.1(react@19.1.1))(react@19.1.1)': '@mujian/js-sdk@0.0.6-beta.41(react-dom@19.1.1(react@19.1.1))(react@19.1.1)':
dependencies: dependencies:
'@adobe/css-tools': 4.4.4 '@adobe/css-tools': 4.4.4
ahooks: 3.9.5(react-dom@19.1.1(react@19.1.1))(react@19.1.1) ahooks: 3.9.5(react-dom@19.1.1(react@19.1.1))(react@19.1.1)

View File

@@ -22,7 +22,6 @@ export const MessageEditArea = ({
const t = textareaRef.current; const t = textareaRef.current;
if (t) { if (t) {
const parent = t.parentElement; const parent = t.parentElement;
console.log(parent);
t.style.height = 'auto'; t.style.height = 'auto';
t.style.height = t.scrollHeight + 'px'; t.style.height = t.scrollHeight + 'px';

View File

@@ -1,5 +1,6 @@
import { Alert, ScrollShadow, Spinner } from '@heroui/react'; import { Alert, ScrollShadow, Spinner } from '@heroui/react';
import { useChat, useMujian } from '@mujian/js-sdk/react'; import { useChat, useMujian } from '@mujian/js-sdk/react';
import type { ProjectInfo } from '@mujian/js-sdk/types';
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { useGlobalStore } from '@/store/global'; import { useGlobalStore } from '@/store/global';
import { MessageList } from './MessageList'; import { MessageList } from './MessageList';
@@ -9,15 +10,23 @@ import { MsgSend } from './MsgSend';
declare global { declare global {
interface Window { interface Window {
$mj_engine: { $mj_engine: {
chat: { ai: {
complete?: (message: string) => Promise<void>; chat: {
complete?: (message: string) => Promise<void>;
project?: ProjectInfo;
};
}; };
}; };
} }
} }
window.$mj_engine = { window.$mj_engine = {
chat: {}, ai: {
chat: {
complete: undefined,
project: undefined,
},
},
}; };
export const Chat = () => { export const Chat = () => {
@@ -41,6 +50,10 @@ export const Chat = () => {
}, },
}); });
useEffect(() => {
window.$mj_engine.ai.chat.project = projectInfo ?? undefined;
}, [projectInfo]);
// 自定义删除消息函数 // 自定义删除消息函数
const handleDeleteMessage = async (messageId: string) => { const handleDeleteMessage = async (messageId: string) => {
// 找到要删除的消息 // 找到要删除的消息
@@ -83,12 +96,12 @@ export const Chat = () => {
// 将chat对象挂载到window上 // 将chat对象挂载到window上
useEffect(() => { useEffect(() => {
window.$mj_engine.chat.complete = async (message: string) => { window.$mj_engine.ai.chat.complete = async (message: string) => {
await onSend(message); await onSend(message);
}; };
return () => { return () => {
delete window.$mj_engine.chat.complete; delete window.$mj_engine.ai.chat.complete;
}; };
}, [onSend]); }, [onSend]);