mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 13:07:17 +08:00
样式优化
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
import { ProChat, ProChatInstance, ProChatProvider, useProChat } from '@ant-design/pro-chat';
|
||||
import { useStore } from '@renderer/store/useStore';
|
||||
import { ProChat, ProChatInstance, ProChatProvider } from '@ant-design/pro-chat';
|
||||
import useChat from '@renderer/hooks/useChat';
|
||||
import { useStore } from '@renderer/store/useStore';
|
||||
import { useTheme } from 'antd-style';
|
||||
import { useRef } from 'react';
|
||||
export default function Chat(props: {id: number}) {
|
||||
const {id} = props;
|
||||
const setMessages = useStore(state=>state.setChatMessage)
|
||||
const chatMessages = useStore(state=>state.chatMessages)
|
||||
export default function Chat(props: {id: number, revalidator: () => void}) {
|
||||
const {id, revalidator} = props;
|
||||
const {getResponse} = useChat()
|
||||
const theme = useTheme();
|
||||
const proChatRef = useRef<ProChatInstance>();
|
||||
|
||||
const chatMessages = useStore(state=>state.chatMessages)
|
||||
const setMessages = useStore(state=>state.setChatMessage)
|
||||
return (
|
||||
<ProChatProvider>
|
||||
<ProChat
|
||||
@@ -22,12 +21,12 @@ export default function Chat(props: {id: number}) {
|
||||
style={{ background: theme.colorBgLayout }}
|
||||
// assistantMeta={{ avatar: '', title: '智子', backgroundColor: '#67dedd' }}
|
||||
helloMessage={
|
||||
<div className='text-black'>你好,我叫智子,你的智能Agent助手!我可以帮你生成自动化代码,有什么要求可以随时吩咐!</div>
|
||||
<div className='text-black'><b>你好,我叫智子,你的AI自动化代码助手!</b>有什么要求可以随时吩咐!</div>
|
||||
}
|
||||
|
||||
request={async (messages) => {
|
||||
// // const proChat = useProChat()
|
||||
const response = await getResponse(messages, id, proChatRef.current)
|
||||
const response = await getResponse(messages, id, proChatRef.current, revalidator)
|
||||
return response// 支持流式和非流式
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -8,17 +8,17 @@ import "./codeEditor.scss"
|
||||
interface CodeEditorProps {
|
||||
id: number;
|
||||
defaultValue: string;
|
||||
revalidator: () => void;
|
||||
|
||||
}
|
||||
|
||||
export default function CodeEditor(props: CodeEditorProps) {
|
||||
const { id, defaultValue} = props;
|
||||
const { id, defaultValue, revalidator} = props;
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
{/* <Spin tip="Loading" size="large"> */}
|
||||
<FloatButton icon={<QuestionCircleOutlined />} type="primary" onClick={() => {
|
||||
<FloatButton icon={<QuestionCircleOutlined />} type="primary" onClick={() => {
|
||||
setOpen(true);
|
||||
}} />
|
||||
<Drawer
|
||||
@@ -32,9 +32,7 @@ export default function CodeEditor(props: CodeEditorProps) {
|
||||
padding: 0,
|
||||
},
|
||||
}}>
|
||||
<div style={{ height: '100%', width: '100%' }}>
|
||||
<Chat id={id}/>
|
||||
</div>
|
||||
<Chat id={id} revalidator={revalidator}/>
|
||||
</Drawer>
|
||||
|
||||
<CodeMirror
|
||||
|
||||
@@ -3,7 +3,7 @@ import useOpenai from "./useOpenai";
|
||||
import { ProChatInstance } from "@ant-design/pro-chat";
|
||||
|
||||
export default ()=>{
|
||||
const getResponse=(chat_messages: Array<any>, id:number, proChatRef: ProChatInstance|undefined)=>{
|
||||
const getResponse=(chat_messages: Array<any>, id:number, proChatRef: ProChatInstance|undefined, revalidator: () => void)=>{
|
||||
const messages = chat_messages.map((m) => {
|
||||
return {
|
||||
role: m.role,
|
||||
@@ -23,6 +23,7 @@ export default ()=>{
|
||||
'update',
|
||||
{content: allContent, id})
|
||||
proChatRef!.setMessageContent(chat_id, "代码已经生成完毕!")
|
||||
revalidator()
|
||||
|
||||
}
|
||||
if (allContent.includes("【自动化方案】")) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Form, useLoaderData, useSubmit } from "react-router-dom"
|
||||
import { Form, useLoaderData, useRevalidator, useSubmit } from "react-router-dom"
|
||||
import "./content.scss"
|
||||
import CodeEditor from "@renderer/components/CodeEditor"
|
||||
export const Content = () => {
|
||||
@@ -6,6 +6,7 @@ export const Content = () => {
|
||||
content: ContentType
|
||||
categories: CategoryType[]
|
||||
}
|
||||
const revalidator = useRevalidator();
|
||||
const submit = useSubmit()
|
||||
return (
|
||||
<Form method="PUT">
|
||||
@@ -26,7 +27,7 @@ export const Content = () => {
|
||||
submit(e.target.form)
|
||||
setCode(e.target.value)
|
||||
}}/> */}
|
||||
<CodeEditor id={content.id} defaultValue={content.content}/>
|
||||
<CodeEditor id={content.id} defaultValue={content.content} revalidator={()=>revalidator.revalidate()} />
|
||||
</main>
|
||||
</Form>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user