feat: add chat history and edit

This commit is contained in:
2024-09-30 02:53:13 +08:00
parent 029710f31c
commit 441b94a061
10 changed files with 269 additions and 30 deletions

View File

@@ -10,6 +10,7 @@ import { EditOutlined, SettingOutlined, LinkOutlined, SaveOutlined, DeleteOutlin
import clsx from 'clsx';
import { isObjectNull } from '@/utils/is-null';
import { CardBlank } from '@/components/card/CardBlank';
import { useAiStore } from '@/pages/ai-chat';
const FormModal = () => {
const [form] = Form.useForm();
const containerStore = useContainerStore(
@@ -103,6 +104,15 @@ export const ContainerList = () => {
};
}),
);
const aiStore = useAiStore(
useShallow((state) => {
return {
open: state.open,
setOpen: state.setOpen,
setData: state.setData,
};
}),
);
const [codeEdit, setCodeEdit] = useState(false);
const [code, setCode] = useState('');
useEffect(() => {
@@ -212,7 +222,12 @@ export const ContainerList = () => {
icon={<LinkOutlined />}></Button>
</Tooltip>
<Tooltip title='ai编程'>
<Button onClick={(e) => {}} icon={<MessageOutlined />}></Button>
<Button
onClick={(e) => {
aiStore.setOpen(true);
// aiStore.setData({ ...containerStore.formData });
}}
icon={<MessageOutlined />}></Button>
</Tooltip>
</div>
</div>

View File

@@ -4,6 +4,8 @@ import { Outlet, useLocation } from 'react-router';
import { useContainerStore } from '../store';
import { useEffect } from 'react';
import { useShallow } from 'zustand/react/shallow';
import { AiMoudle } from '@/pages/ai-chat';
import { LayoutMain } from '@/modules/layout';
export const Main = () => {
const containerStore = useContainerStore(
@@ -17,30 +19,20 @@ export const Main = () => {
const location = useLocation();
const isEdit = location.pathname.includes('edit/list');
return (
<div className='flex w-full h-full flex-col'>
<div className='layout-menu'>
Container
<Button
className={!isEdit ? 'hidden' : ''}
icon={<PlusOutlined />}
onClick={() => {
console.log('add');
containerStore.setFormData({});
containerStore.setShowEdit(true);
}}
/>
</div>
<div
className='flex'
style={{
height: 'calc(100vh - 3rem)',
}}>
<div className='flex-grow overflow-hidden'>
<div className='w-full h-full rounded-lg'>
<Outlet />
</div>
</div>
</div>
</div>
<LayoutMain
title={
<>
Container
<Button
className={!isEdit ? 'hidden' : ''}
icon={<PlusOutlined />}
onClick={() => {
console.log('add');
containerStore.setFormData({});
containerStore.setShowEdit(true);
}}
/>
</>
}></LayoutMain>
);
};