From 4918f38811300e0a4ecadbaecb7dce6548922706 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Thu, 26 Sep 2024 13:48:25 +0800 Subject: [PATCH 1/5] perf: support child layout --- projects/app/src/pages/_app.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/projects/app/src/pages/_app.tsx b/projects/app/src/pages/_app.tsx index 5539d5b9eba8..7889bb8672dc 100644 --- a/projects/app/src/pages/_app.tsx +++ b/projects/app/src/pages/_app.tsx @@ -11,9 +11,17 @@ import { useInitApp } from '@/web/context/useInitApp'; import { useTranslation } from 'next-i18next'; import '@/web/styles/reset.scss'; import NextHead from '@/components/common/NextHead'; -import { useEffect } from 'react'; +import { ReactElement, useEffect } from 'react'; +import { NextPage } from 'next'; -function App({ Component, pageProps }: AppProps) { +type NextPageWithLayout = NextPage & { + setLayout?: (page: ReactElement) => JSX.Element; +}; +type AppPropsWithLayout = AppProps & { + Component: NextPageWithLayout; +}; + +function App({ Component, pageProps }: AppPropsWithLayout) { const { feConfigs, scripts, title } = useInitApp(); const { t } = useTranslation(); @@ -30,6 +38,8 @@ function App({ Component, pageProps }: AppProps) { ); }, []); + const setLayout = Component.setLayout || ((page) => <>{page}); + return ( <> - - - + {setLayout()} From 843b842282f73236eeb4fc5db7d1137ae6296501 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Thu, 26 Sep 2024 14:33:55 +0800 Subject: [PATCH 2/5] perf: user form ui --- .../template/system/interactive/formInput.ts | 4 ++-- .../workflow/dispatch/interactive/formInput.ts | 4 +++- packages/web/i18n/en/app.json | 2 -- packages/web/i18n/en/common.json | 1 - packages/web/i18n/en/workflow.json | 5 +++++ packages/web/i18n/zh/app.json | 4 +--- packages/web/i18n/zh/common.json | 1 - packages/web/i18n/zh/workflow.json | 5 +++++ .../core/chat/components/AIResponseBox.tsx | 18 ++++++------------ .../chat/components/WholeResponseModal.tsx | 5 +---- .../Flow/nodes/NodeFormInput/index.tsx | 8 ++++---- 11 files changed, 27 insertions(+), 30 deletions(-) diff --git a/packages/global/core/workflow/template/system/interactive/formInput.ts b/packages/global/core/workflow/template/system/interactive/formInput.ts index 5c2a60bf8270..5750a50aa011 100644 --- a/packages/global/core/workflow/template/system/interactive/formInput.ts +++ b/packages/global/core/workflow/template/system/interactive/formInput.ts @@ -46,8 +46,8 @@ export const FormInputNode: FlowNodeTemplateType = { id: NodeOutputKeyEnum.formInputResult, key: NodeOutputKeyEnum.formInputResult, required: true, - label: i18nT('app:workflow.form_input_result'), - description: i18nT('app:workflow.form_input_result_tip'), + label: i18nT('workflow:form_input_result'), + description: i18nT('workflow:form_input_result_tip'), valueType: WorkflowIOValueTypeEnum.object, type: FlowNodeOutputTypeEnum.static } diff --git a/packages/service/core/workflow/dispatch/interactive/formInput.ts b/packages/service/core/workflow/dispatch/interactive/formInput.ts index 532fc67bbc86..2235603e3c5b 100644 --- a/packages/service/core/workflow/dispatch/interactive/formInput.ts +++ b/packages/service/core/workflow/dispatch/interactive/formInput.ts @@ -9,6 +9,7 @@ import { UserInputFormItemType, UserInputInteractive } from '@fastgpt/global/core/workflow/template/system/interactive/type'; +import { addLog } from '../../../../common/system/log'; type Props = ModuleDispatchProps<{ [NodeInputKeyEnum.description]: string; @@ -48,7 +49,8 @@ export const dispatchFormInput = async (props: Props): Promise { ); if (value.type === ChatItemValueTypeEnum.tool && value.tools) return ; - if ( - value.type === ChatItemValueTypeEnum.interactive && - value.interactive && - value.interactive.type === 'userSelect' - ) - return ; - if ( - value.type === ChatItemValueTypeEnum.interactive && - value.interactive && - value.interactive?.type === 'userInput' - ) - return ; + if (value.type === ChatItemValueTypeEnum.interactive && value.interactive) { + if (value.interactive.type === 'userSelect') + return ; + if (value.interactive?.type === 'userInput') + return ; + } }; export default React.memo(AIResponseBox); diff --git a/projects/app/src/components/core/chat/components/WholeResponseModal.tsx b/projects/app/src/components/core/chat/components/WholeResponseModal.tsx index 77154a1f39fa..81199f3d3e61 100644 --- a/projects/app/src/components/core/chat/components/WholeResponseModal.tsx +++ b/projects/app/src/components/core/chat/components/WholeResponseModal.tsx @@ -354,10 +354,7 @@ export const WholeResponseContent = ({ /> {/* form input */} - + ) : null; }; diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeFormInput/index.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeFormInput/index.tsx index 1541d0c2c1a3..9f61f9f8edb1 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeFormInput/index.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/NodeFormInput/index.tsx @@ -120,7 +120,7 @@ const NodeFormInput = ({ data, selected }: NodeProps) => { return ( - {t('common:core.module.input_form')} + {t('workflow:user_form_input_config')}