From 421ff59583448d0bd9b7f95b07b2bd88c80f4c86 Mon Sep 17 00:00:00 2001 From: junjun Date: Tue, 19 Aug 2025 17:02:35 +0800 Subject: [PATCH] refactor: add schema --- frontend/src/api/datasource.ts | 1 + frontend/src/i18n/en.json | 5 +- frontend/src/i18n/zh-CN.json | 5 +- frontend/src/views/ds/DatasourceForm.vue | 58 ++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/frontend/src/api/datasource.ts b/frontend/src/api/datasource.ts index 33e89765..96571845 100644 --- a/frontend/src/api/datasource.ts +++ b/frontend/src/api/datasource.ts @@ -22,4 +22,5 @@ export const datasourceApi = { saveField: (data: any) => request.post('/datasource/editField', data), getDs: (id: number) => request.post(`/datasource/get/${id}`), cancelRequests: () => request.cancelRequests(), + getSchema: (data: any) => request.post('/datasource/getSchemaByConf', data) } diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 2bda28c8..1ec86bff 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -270,7 +270,8 @@ "field_original_notes": "Field original notes", "field_notes_1": "Field notes", "no_table": "No Table", - "go_add": "Add" + "go_add": "Add", + "get_schema": "Get Schema" }, "model": { "default_model": "Default model", @@ -618,4 +619,4 @@ "setting_successfully": "Setting Successfully", "customize_theme_color": "Customize theme color" } -} \ No newline at end of file +} diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index 25f50713..ed2a378d 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -270,7 +270,8 @@ "field_original_notes": "字段原始备注", "field_notes_1": "字段备注", "no_table": "暂无数据表", - "go_add": "去添加" + "go_add": "去添加", + "get_schema": "获取Schema" }, "model": { "default_model": "默认模型", @@ -618,4 +619,4 @@ "setting_successfully": "设置成功", "customize_theme_color": "自定义主题色" } -} \ No newline at end of file +} diff --git a/frontend/src/views/ds/DatasourceForm.vue b/frontend/src/views/ds/DatasourceForm.vue index 631a77b6..6541c5ef 100644 --- a/frontend/src/views/ds/DatasourceForm.vue +++ b/frontend/src/views/ds/DatasourceForm.vue @@ -46,6 +46,7 @@ const getUploadURL = import.meta.env.VITE_API_BASE_URL + '/datasource/uploadExce const saveLoading = ref(false) const uploadLoading = ref(false) const { t } = useI18n() +const schemaList = ref([]) const rules = reactive({ name: [ @@ -340,6 +341,16 @@ const check = () => { }) } +const getSchema = () => { + schemaList.value = [] + const requestObj = buildConf() + datasourceApi.getSchema(requestObj).then((res: any) => { + for (let item of res) { + schemaList.value.push({ label: item, value: item }) + } + }) +} + onBeforeUnmount(() => (saveLoading.value = false)) const next = debounce(async (formEl: FormInstance | undefined) => { @@ -644,13 +655,30 @@ defineExpose({ " /> - - + + - Get Schema + > + +