From f5fad6083a84702e4bbc9ef8e060f5a2eef8de42 Mon Sep 17 00:00:00 2001
From: archer <545436317@qq.com>
Date: Sat, 22 Jul 2023 21:56:57 +0800
Subject: [PATCH] fix: chat test overflow
---
client/src/components/ChatBox/index.tsx | 150 +++++++++---------
.../app/detail/components/BasicEdit/index.tsx | 5 +-
.../app/detail/components/KBSelectModal.tsx | 2 +
.../pages/app/detail/components/OverView.tsx | 4 +-
client/src/pages/app/detail/index.tsx | 11 +-
5 files changed, 89 insertions(+), 83 deletions(-)
diff --git a/client/src/components/ChatBox/index.tsx b/client/src/components/ChatBox/index.tsx
index 52337c1bb..02a49897b 100644
--- a/client/src/components/ChatBox/index.tsx
+++ b/client/src/components/ChatBox/index.tsx
@@ -100,15 +100,13 @@ const Empty = () => {
const ChatAvatar = ({
src,
- order,
ml,
mr
}: {
- src: string;
- order: number;
+ src?: string;
ml?: (string | number) | (string | number)[];
mr?: (string | number) | (string | number)[];
-}) => ;
+}) => ;
const ChatBox = (
{
@@ -169,8 +167,6 @@ const ChatBox = (
return true;
}, [chatHistory.length, variableModules, variables]);
- const isLargeWidth = ChatBoxRef?.current?.clientWidth && ChatBoxRef?.current?.clientWidth >= 900;
-
const { register, reset, getValues, setValue, handleSubmit } = useForm>({
defaultValues: variables
});
@@ -391,6 +387,9 @@ const ChatBox = (
zIndex: 1,
w: '100%'
};
+ console.log(ChatBoxRef.current?.clientWidth);
+
+ const messageCardMaxW = ['calc(100% - 48px)', 'calc(100% - 65px)'];
const showEmpty = useMemo(
() =>
@@ -410,14 +409,23 @@ const ChatBox = (
return (
-
+
{showEmpty && }
{!!welcomeText && (
{/* avatar */}
-
+
{/* message */}
{/* avatar */}
-
+
{/* message */}
{variableModules.map((item) => (
@@ -503,36 +511,70 @@ const ChatBox = (
)}
{/* chat history */}
-
+
{chatHistory.map((item, index) => (
- {item.obj === 'Human' && }
- {/* avatar */}
-
- {/* message */}
-
- {item.obj === 'AI' ? (
-
+ {item.obj === 'Human' && (
+ <>
+
+
+ {item.value}
+
+
+
+ onclickCopy(item.value)}
+ />
+
+ {onDelMessage && (
+
+ {
+ setChatHistory((state) =>
+ state.filter((chat) => chat._id !== item._id)
+ );
+ onDelMessage({
+ contentId: item._id,
+ index
+ });
+ }}
+ />
+
+ )}
+
+
+
+ >
+ )}
+ {item.obj === 'AI' && (
+ <>
+
+
- ) : (
-
-
- {item.value}
-
-
-
- onclickCopy(item.value)}
- />
-
- {onDelMessage && (
-
- {
- setChatHistory((state) =>
- state.filter((chat) => chat._id !== item._id)
- );
- onDelMessage({
- contentId: item._id,
- index
- });
- }}
- />
-
- )}
-
-
- )}
-
+ >
+ )}
))}
diff --git a/client/src/pages/app/detail/components/BasicEdit/index.tsx b/client/src/pages/app/detail/components/BasicEdit/index.tsx
index 7f51cd7fe..ffd4ed3d5 100644
--- a/client/src/pages/app/detail/components/BasicEdit/index.tsx
+++ b/client/src/pages/app/detail/components/BasicEdit/index.tsx
@@ -161,6 +161,7 @@ const Settings = ({ appId }: { appId: string }) => {
borderRight={'1.5px solid'}
borderColor={'myGray.200'}
pt={4}
+ pl={4}
>
@@ -482,8 +483,8 @@ const ChatTest = ({ appId }: { appId: string }) => {
}, [appDetail, resetChatBox]);
return (
-
-
+
+
调试预览
diff --git a/client/src/pages/app/detail/components/KBSelectModal.tsx b/client/src/pages/app/detail/components/KBSelectModal.tsx
index 4a5535aed..022043b0d 100644
--- a/client/src/pages/app/detail/components/KBSelectModal.tsx
+++ b/client/src/pages/app/detail/components/KBSelectModal.tsx
@@ -212,3 +212,5 @@ export const KbParamsModal = ({
);
};
+
+export default KBSelectModal;
diff --git a/client/src/pages/app/detail/components/OverView.tsx b/client/src/pages/app/detail/components/OverView.tsx
index e3db24876..c20d833a6 100644
--- a/client/src/pages/app/detail/components/OverView.tsx
+++ b/client/src/pages/app/detail/components/OverView.tsx
@@ -49,7 +49,7 @@ const OverView = ({ appId }: { appId: string }) => {
}, [appDetail, setIsLoading, toast, router]);
// load app data
- const { refetch } = useQuery([appId], () => loadAppDetail(appId, true), {
+ useQuery([appId], () => loadAppDetail(appId, true), {
enabled: false
});
@@ -142,7 +142,7 @@ const OverView = ({ appId }: { appId: string }) => {
-
+
diff --git a/client/src/pages/app/detail/index.tsx b/client/src/pages/app/detail/index.tsx
index 00cb7d9d0..fa7ad3a65 100644
--- a/client/src/pages/app/detail/index.tsx
+++ b/client/src/pages/app/detail/index.tsx
@@ -64,10 +64,13 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
);
useEffect(() => {
- window.onbeforeunload = (e) => {
- e.preventDefault();
- e.returnValue = '内容已修改,确认离开页面吗?';
- };
+ window.onbeforeunload =
+ process.env.NODE_ENV === 'production'
+ ? (e) => {
+ e.preventDefault();
+ e.returnValue = '内容已修改,确认离开页面吗?';
+ }
+ : null;
return () => {
window.onbeforeunload = null;