2
This commit is contained in:
@@ -22,7 +22,6 @@ export const MessageEditArea = ({
|
||||
const t = textareaRef.current;
|
||||
if (t) {
|
||||
const parent = t.parentElement;
|
||||
console.log(parent);
|
||||
|
||||
t.style.height = 'auto';
|
||||
t.style.height = t.scrollHeight + 'px';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Alert, ScrollShadow, Spinner } from '@heroui/react';
|
||||
import { useChat, useMujian } from '@mujian/js-sdk/react';
|
||||
import type { ProjectInfo } from '@mujian/js-sdk/types';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import { MessageList } from './MessageList';
|
||||
@@ -9,15 +10,23 @@ import { MsgSend } from './MsgSend';
|
||||
declare global {
|
||||
interface Window {
|
||||
$mj_engine: {
|
||||
chat: {
|
||||
complete?: (message: string) => Promise<void>;
|
||||
ai: {
|
||||
chat: {
|
||||
complete?: (message: string) => Promise<void>;
|
||||
project?: ProjectInfo;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
window.$mj_engine = {
|
||||
chat: {},
|
||||
ai: {
|
||||
chat: {
|
||||
complete: undefined,
|
||||
project: undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
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) => {
|
||||
// 找到要删除的消息
|
||||
@@ -83,12 +96,12 @@ export const Chat = () => {
|
||||
|
||||
// 将chat对象挂载到window上
|
||||
useEffect(() => {
|
||||
window.$mj_engine.chat.complete = async (message: string) => {
|
||||
window.$mj_engine.ai.chat.complete = async (message: string) => {
|
||||
await onSend(message);
|
||||
};
|
||||
|
||||
return () => {
|
||||
delete window.$mj_engine.chat.complete;
|
||||
delete window.$mj_engine.ai.chat.complete;
|
||||
};
|
||||
}, [onSend]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user