Commit 3671e550 by Archer Committed by GitHub

4.8.10 test (#2618)

* perf: menu arrow ui

* perf: http node placeholder

* perf: http node form input

* perf: chatBox performance
parent 3bcc3430
...@@ -49,7 +49,7 @@ const Markdown = ({ ...@@ -49,7 +49,7 @@ const Markdown = ({
const formatSource = useMemo(() => { const formatSource = useMemo(() => {
const formatSource = source const formatSource = source
.replace( .replace(
/([\u4e00-\u9fa5\u3000-\u303f])([\w\u0020-\u007e])|([a-zA-Z0-9\u0020-\u007e])([\u4e00-\u9fa5\u3000-\u303f])/g, /([\u4e00-\u9fa5\u3000-\u303f])([a-zA-Z0-9])|([a-zA-Z0-9])([\u4e00-\u9fa5\u3000-\u303f])/g,
'$1$3 $2$4' '$1$3 $2$4'
) // Chinese and english chars separated by space ) // Chinese and english chars separated by space
.replace(/\n*(\[QUOTE SIGN\]\(.*\))/g, '$1'); .replace(/\n*(\[QUOTE SIGN\]\(.*\))/g, '$1');
......
...@@ -9,11 +9,13 @@ import { formatChatValue2InputType } from '../utils'; ...@@ -9,11 +9,13 @@ import { formatChatValue2InputType } from '../utils';
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants'; import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
import { ChatBoxContext } from '../Provider'; import { ChatBoxContext } from '../Provider';
import { useContextSelector } from 'use-context-selector'; import { useContextSelector } from 'use-context-selector';
import { SendPromptFnType } from '../type';
export type ChatControllerProps = { export type ChatControllerProps = {
isLastChild: boolean; isLastChild: boolean;
chat: ChatSiteItemType; chat: ChatSiteItemType;
showVoiceIcon?: boolean; showVoiceIcon?: boolean;
onSendMessage: SendPromptFnType;
onRetry?: () => void; onRetry?: () => void;
onDelete?: () => void; onDelete?: () => void;
onMark?: () => void; onMark?: () => void;
...@@ -25,7 +27,6 @@ export type ChatControllerProps = { ...@@ -25,7 +27,6 @@ export type ChatControllerProps = {
const ChatController = ({ const ChatController = ({
chat, chat,
isLastChild,
showVoiceIcon, showVoiceIcon,
onReadUserDislike, onReadUserDislike,
onCloseUserLike, onCloseUserLike,
......
...@@ -217,8 +217,8 @@ function ExportPopover({ ...@@ -217,8 +217,8 @@ function ExportPopover({
return ( return (
<MyPopover <MyPopover
placement={'right-start'} placement={'right-start'}
offset={[-5, 5]} offset={[0, 0]}
hasArrow={false} hasArrow
trigger={'hover'} trigger={'hover'}
w={'8.6rem'} w={'8.6rem'}
Trigger={ Trigger={
......
...@@ -448,20 +448,16 @@ const RenderForm = ({ ...@@ -448,20 +448,16 @@ const RenderForm = ({
setList((prevList) => { setList((prevList) => {
if (!newKey) { if (!newKey) {
setUpdateTrigger((prev) => !prev); setUpdateTrigger((prev) => !prev);
toast({ // toast({
status: 'warning', // status: 'warning',
title: t('common:core.module.http.Key cannot be empty') // title: t('common:core.module.http.Key cannot be empty')
}); // });
return prevList; } else if (prevList.find((item, i) => i !== index && item.key == newKey)) {
}
const checkExist = prevList.find((item, i) => i !== index && item.key == newKey);
if (checkExist) {
setUpdateTrigger((prev) => !prev); setUpdateTrigger((prev) => !prev);
toast({ toast({
status: 'warning', status: 'warning',
title: t('common:core.module.http.Key already exists') title: t('common:core.module.http.Key already exists')
}); });
return prevList;
} }
return prevList.map((item, i) => (i === index ? { ...item, key: newKey } : item)); return prevList.map((item, i) => (i === index ? { ...item, key: newKey } : item));
}); });
...@@ -470,14 +466,15 @@ const RenderForm = ({ ...@@ -470,14 +466,15 @@ const RenderForm = ({
[t, toast] [t, toast]
); );
// Add new params/headers key
const handleAddNewProps = useCallback( const handleAddNewProps = useCallback(
(key: string, value: string = '') => { (value: string) => {
setList((prevList) => { setList((prevList) => {
if (!key) { if (!value) {
return prevList; return prevList;
} }
const checkExist = prevList.find((item) => item.key === key); const checkExist = prevList.find((item) => item.key === value);
if (checkExist) { if (checkExist) {
setUpdateTrigger((prev) => !prev); setUpdateTrigger((prev) => !prev);
toast({ toast({
...@@ -486,7 +483,7 @@ const RenderForm = ({ ...@@ -486,7 +483,7 @@ const RenderForm = ({
}); });
return prevList; return prevList;
} }
return [...prevList, { key, type: 'string', value }]; return [...prevList, { key: value, type: 'string', value: '' }];
}); });
setShouldUpdateNode(true); setShouldUpdateNode(true);
...@@ -520,17 +517,15 @@ const RenderForm = ({ ...@@ -520,17 +517,15 @@ const RenderForm = ({
<Tr key={`${input.key}${index}`}> <Tr key={`${input.key}${index}`}>
<Td p={0} w={'50%'} borderRight={'1px solid'} borderColor={'myGray.200'}> <Td p={0} w={'50%'} borderRight={'1px solid'} borderColor={'myGray.200'}>
<HttpInput <HttpInput
placeholder={ placeholder={t('common:textarea_variable_picker_tip')}
index !== list.length
? t('common:core.module.http.Props name_and_tips')
: t('common:core.module.http.Add props_and_tips')
}
value={item.key} value={item.key}
variableLabels={variables} variableLabels={variables}
variables={variables} variables={variables}
onBlur={(val) => { onBlur={(val) => {
handleKeyChange(index, val); handleKeyChange(index, val);
if (index === list.length) {
// Last item blur, add the next item.
if (index === list.length && val) {
handleAddNewProps(val); handleAddNewProps(val);
setUpdateTrigger((prev) => !prev); setUpdateTrigger((prev) => !prev);
} }
...@@ -541,11 +536,7 @@ const RenderForm = ({ ...@@ -541,11 +536,7 @@ const RenderForm = ({
<Td p={0} w={'50%'}> <Td p={0} w={'50%'}>
<Box display={'flex'} alignItems={'center'}> <Box display={'flex'} alignItems={'center'}>
<HttpInput <HttpInput
placeholder={ placeholder={t('common:textarea_variable_picker_tip')}
index !== list.length
? t('common:core.module.http.Props value_and_tips')
: ''
}
value={item.value} value={item.value}
variables={variables} variables={variables}
variableLabels={variables} variableLabels={variables}
...@@ -694,6 +685,7 @@ const RenderBody = ({ ...@@ -694,6 +685,7 @@ const RenderBody = ({
{(typeInput?.value === ContentTypes.xml || typeInput?.value === ContentTypes.raw) && ( {(typeInput?.value === ContentTypes.xml || typeInput?.value === ContentTypes.raw) && (
<PromptEditor <PromptEditor
value={jsonBody.value} value={jsonBody.value}
placeholder={t('common:textarea_variable_picker_tip')}
onChange={(e) => { onChange={(e) => {
startSts(() => { startSts(() => {
onChangeNode({ onChangeNode({
......
...@@ -204,7 +204,6 @@ const InputDataModal = ({ ...@@ -204,7 +204,6 @@ const InputDataModal = ({
a: '', a: '',
indexes: [] indexes: []
}); });
console.log('执行onSuccess');
onSuccess(e); onSuccess(e);
}, },
errorToast: t('common:common.error.unKnow') errorToast: t('common:common.error.unKnow')
......
...@@ -17,6 +17,8 @@ export const useCopyData = () => { ...@@ -17,6 +17,8 @@ export const useCopyData = () => {
title: string | null = t('common:common.Copy Successful'), title: string | null = t('common:common.Copy Successful'),
duration = 1000 duration = 1000
) => { ) => {
data = data.trim();
try { try {
if ((hasHttps() || !isProduction) && navigator.clipboard) { if ((hasHttps() || !isProduction) && navigator.clipboard) {
await navigator.clipboard.writeText(data); await navigator.clipboard.writeText(data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment