From c19dc7a413d990c36e02aee70db811aefc52fd64 Mon Sep 17 00:00:00 2001 From: shanhexi Date: Sat, 26 Aug 2023 10:13:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=9E=E6=8E=A5=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 1 + .../ConnectionEdit/config/dataSource.ts | 12 +++++++ .../src/components/ConnectionEdit/index.tsx | 35 ++++++++++++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 11848339..a886d6e3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -47,6 +47,7 @@ "togglefullscreen", "umijs", "umirc", + "USERANDPASSWORD", "uuidv", "VIEWCOLUMN", "VIEWCOLUMNS", diff --git a/chat2db-client/src/components/ConnectionEdit/config/dataSource.ts b/chat2db-client/src/components/ConnectionEdit/config/dataSource.ts index 224b04d0..25c747ef 100644 --- a/chat2db-client/src/components/ConnectionEdit/config/dataSource.ts +++ b/chat2db-client/src/components/ConnectionEdit/config/dataSource.ts @@ -143,6 +143,18 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [ name: 'alias', required: true, }, + { + defaultValue: '', + inputType: InputType.SELECT, + labelNameCN: '环境', + labelNameEN: 'Env', + name: 'env', + required: true, + selects: [], + styles: { + width: '50%', + } + }, { defaultValue: 'localhost', inputType: InputType.INPUT, diff --git a/chat2db-client/src/components/ConnectionEdit/index.tsx b/chat2db-client/src/components/ConnectionEdit/index.tsx index aac25511..d1b3f601 100644 --- a/chat2db-client/src/components/ConnectionEdit/index.tsx +++ b/chat2db-client/src/components/ConnectionEdit/index.tsx @@ -53,15 +53,40 @@ export default forwardRef(function CreateConnection(props: IProps, ref: Forwarde backfillDataLoading: false, sshTestLoading: false }); + const [envList, setEnvList] = useState<{value:string,label:string}[]>([]); + + + useEffect(() => { + setTimeout(() => { + setEnvList([ + { + value: 'prod', + label: '生产环境' + }, + { + value: 'daily', + label: '日常环境' + }, + { + value: 'pre', + label: '预发环境' + }, + ]) + }, 3000); + }, []); const dataSourceFormConfigPropsMemo = useMemo(() => { const deepCloneDataSourceFormConfigs = deepClone(dataSourceFormConfigs) - return deepCloneDataSourceFormConfigs.find((t: IConnectionConfig) => { - const flag = t.type === backfillData.type; - return flag + const data = deepCloneDataSourceFormConfigs.find((t: IConnectionConfig) => { + return t.type === backfillData.type }); - - }, [backfillData]); + data.baseInfo.items.forEach((t: IFormItem) => { + if (t.name === 'env' && envList?.length) { + t.selects = envList; + } + }) + return data; + }, [backfillData, envList]); useEffect(() => { setBackfillData(props.connectionData);