fix: delete confirm add

This commit is contained in:
2024-10-08 10:56:19 +08:00
parent c802c4c2f7
commit 1c39c74350
20 changed files with 537 additions and 55 deletions

View File

@@ -2,14 +2,14 @@ import { useShallow } from 'zustand/react/shallow';
import { useAiStore } from './store/ai-store';
import { CloseOutlined, HistoryOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, Dropdown, Form, Input, message, Modal, Tooltip } from 'antd';
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useLayoutEffect, useMemo, useState } from 'react';
import { TextArea } from '../container/components/TextArea';
import clsx from 'clsx';
import { query } from '@/modules';
import { nanoid } from 'nanoid';
import { ChatMessage } from './module/ChatMessage';
import { isObjectNull } from '@/utils/is-null';
import { useNavigate } from 'react-router';
import { useLocation, useNavigate } from 'react-router';
const testId = '60aca66b-4be9-4266-9568-6001032c7e13';
const NormalMessage = ({ onSend }: { onSend: any }) => {
const [message, setMessage] = useState('');
@@ -194,6 +194,8 @@ export const AiMoudle = () => {
}),
);
const [noPrompt, setNoPrompt] = useState(false);
const [currentPage, setCurrentPage] = useState('');
const location = useLocation();
useEffect(() => {
if (!aiStore.open) {
return;
@@ -204,7 +206,6 @@ export const AiMoudle = () => {
} else {
form.setFieldsValue({ inputs: [] });
}
console.log('formData', aiStore.formData);
}, [aiStore.open, aiStore.formData]);
useEffect(() => {
if (!aiStore.open) {
@@ -214,6 +215,12 @@ export const AiMoudle = () => {
}
}, [aiStore.open]);
const { send } = useListenQuery();
useLayoutEffect(() => {
if (aiStore.open) {
aiStore.setOpen(false);
}
}, [location.pathname]);
const onSend = () => {
const data = form.getFieldsValue();
send({ type: 'messages', data: { ...data, root: true } });
@@ -221,11 +228,12 @@ export const AiMoudle = () => {
const onSendNoPrompt = (value) => {
send({ type: 'messages', data: { message: value, root: true } });
};
const inputs = useMemo(() => {
if (!aiStore.open) return [];
const inputs = form.getFieldValue('inputs');
const inputs = aiStore.formData?.inputs || [];
return inputs;
}, [aiStore.open]);
}, [aiStore.open, aiStore.formData]);
const isNotShow = inputs?.length === 0 || !inputs;
const OnlyNormalMessage = (
<Tooltip title='不需要任何预设prompt'>