Skip to content

Commit

Permalink
perf: remove unuse code (#2227)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Jul 31, 2024
1 parent 8c7f4a3 commit 2fdca62
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 90 deletions.
10 changes: 3 additions & 7 deletions packages/web/components/common/Input/HttpInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { $getRoot, EditorState, type LexicalEditor } from 'lexical';
import { useCallback, useTransition } from 'react';
import { useCallback } from 'react';
import { editorStateToText } from '../../Textarea/PromptEditor/utils';
import { EditorVariablePickerType } from '../../Textarea/PromptEditor/type';
import Editor from './Editor';
Expand Down Expand Up @@ -30,18 +30,14 @@ const HttpInput = ({
}) => {
const [currentValue, setCurrentValue] = React.useState(value);

const [, startSts] = useTransition();

const onChangeInput = useCallback((editorState: EditorState, editor: LexicalEditor) => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
setCurrentValue(text);
onChange?.(text);
}, []);
const onBlurInput = useCallback((editor: LexicalEditor) => {
startSts(() => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
});
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
}, []);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useRef, useTransition, useEffect } from 'react';
import { useState, useRef, useTransition } from 'react';
import { LexicalComposer } from '@lexical/react/LexicalComposer';
import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MyModal from '../../MyModal';
import { useTranslation } from 'next-i18next';
import { EditorState, type LexicalEditor } from 'lexical';
import { EditorVariableLabelPickerType, EditorVariablePickerType } from './type.d';
import { useCallback, useTransition } from 'react';
import { useCallback } from 'react';

const PromptEditor = ({
showOpenModal = true,
Expand Down Expand Up @@ -36,18 +36,15 @@ const PromptEditor = ({
isFlow?: boolean;
}) => {
const { isOpen, onOpen, onClose } = useDisclosure();
const [, startSts] = useTransition();
const { t } = useTranslation();

const onChangeInput = useCallback((editorState: EditorState, editor: LexicalEditor) => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onChange?.(text);
}, []);
const onBlurInput = useCallback((editor: LexicalEditor) => {
startSts(() => {
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
});
const text = editorStateToText(editor).replaceAll('}}{{', '}} {{');
onBlur?.(text);
}, []);

return (
Expand Down
65 changes: 7 additions & 58 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/app/src/components/core/app/WelcomeTextConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Flex, TextareaProps } from '@chakra-ui/react';
import React, { useTransition } from 'react';
import React from 'react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import ChatFunctionTip from './Tip';
import MyTextarea from '@/components/common/Textarea/MyTextarea';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, BoxProps, Card, Flex } from '@chakra-ui/react';
import React, { useMemo, useTransition } from 'react';
import React, { useMemo } from 'react';
import ChatController, { type ChatControllerProps } from './ChatController';
import ChatAvatar from './ChatAvatar';
import { MessageCardStyle } from '../constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useRouter } from 'next/router';

import AppCard from '../WorkflowComponents/AppCard';
import { uiWorkflow2StoreWorkflow } from '../WorkflowComponents/utils';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import RouteTab from '../RouteTab';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
const PublishHistories = dynamic(() => import('../PublishHistoriesSlider'));
Expand Down Expand Up @@ -54,6 +53,7 @@ const Header = () => {
router.push('/app/list');
} catch (error) {}
}, [onSaveWorkflow, router]);

// effect
useBeforeunload({
callback: onSaveWorkflow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ const Render = () => {
);
};

export default React.memo(Render);
export default Render;
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ const Render = () => {
);
};

export default React.memo(Render);
export default Render;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node.d';
import React from 'react';
import { SmallCloseIcon } from '@chakra-ui/icons';
import { Box, Flex, HStack, IconButton } from '@chakra-ui/react';
import { Box, Flex, IconButton } from '@chakra-ui/react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { useTranslation } from 'next-i18next';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export function RenderHttpProps({
{t('common:core.module.Http request props')}
<QuestionTip
ml={1}
label={t('core.module.http.Props tip', { variable: variableText })}
label={t('common:core.module.http.Props tip', { variable: variableText })}
></QuestionTip>
</Flex>
<LightRowTabs<TabEnum>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import {
storeNode2FlowNode
} from '@/web/core/workflow/utils';
import { getErrText } from '@fastgpt/global/common/error/utils';
import {
NodeOutputKeyEnum,
RuntimeEdgeStatusEnum,
WorkflowIOValueTypeEnum
} from '@fastgpt/global/core/workflow/constants';
import { NodeOutputKeyEnum, RuntimeEdgeStatusEnum } from '@fastgpt/global/core/workflow/constants';
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
import { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type';
import { FlowNodeItemType, StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
Expand Down Expand Up @@ -49,11 +45,7 @@ import { useDisclosure } from '@chakra-ui/react';
import { uiWorkflow2StoreWorkflow } from './utils';
import { useTranslation } from 'next-i18next';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import {
formatTime2HM,
formatTime2YMDHM,
formatTime2YMDHMW
} from '@fastgpt/global/common/string/time';
import { formatTime2HM, formatTime2YMDHMW } from '@fastgpt/global/common/string/time';
import type { InitProps } from '@/pages/app/detail/components/PublishHistoriesSlider';
import { cloneDeep } from 'lodash';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import dynamic from 'next/dynamic';
import { useChat } from '@/components/core/chat/ChatContainer/useChat';
import { Box } from '@chakra-ui/react';
import ChatBox from '@/components/core/chat/ChatContainer/ChatBox';
import { AppChatConfigType } from '@fastgpt/global/core/app/type';

const PluginRunBox = dynamic(() => import('@/components/core/chat/ChatContainer/PluginRunBox'));
const ChatBox = dynamic(() => import('@/components/core/chat/ChatContainer/ChatBox'));

export const useChatTest = ({
nodes,
Expand Down
3 changes: 3 additions & 0 deletions projects/app/src/pages/app/detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import AppContextProvider, { AppContext } from './components/context';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';

const SimpleEdit = dynamic(() => import('./components/SimpleApp'), {
ssr: false,
loading: () => <Loading fixed={false} />
});
const Workflow = dynamic(() => import('./components/Workflow'), {
ssr: false,
loading: () => <Loading fixed={false} />
});
const Plugin = dynamic(() => import('./components/Plugin'), {
ssr: false,
loading: () => <Loading fixed={false} />
});

Expand Down

0 comments on commit 2fdca62

Please sign in to comment.