feat: API数据源支持Token认证 #9189

This commit is contained in:
taojinlong 2024-06-26 15:10:17 +08:00
parent ce11ef9b04
commit b96dcfc3b0
2 changed files with 12 additions and 2 deletions

View File

@ -854,12 +854,14 @@ public class CalciteProvider {
DatasourceConfiguration configuration = null; DatasourceConfiguration configuration = null;
String database = ""; String database = "";
switch (datasourceType) { switch (datasourceType) {
case StarRocks:
case doris:
tableSqls.add("show tables");
break;
case mysql: case mysql:
case mongo: case mongo:
case mariadb: case mariadb:
case TiDB: case TiDB:
case StarRocks:
case doris:
configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), Mysql.class); configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), Mysql.class);
if (StringUtils.isEmpty(configuration.getUrlType()) || configuration.getUrlType().equalsIgnoreCase("hostName")) { if (StringUtils.isEmpty(configuration.getUrlType()) || configuration.getUrlType().equalsIgnoreCase("hostName")) {
database = configuration.getDataBase(); database = configuration.getDataBase();

View File

@ -97,6 +97,7 @@ const showEmpty = ref(false)
const edit_api_item = ref(false) const edit_api_item = ref(false)
const active = ref(1) const active = ref(1)
const loading = ref(false) const loading = ref(false)
const formLoading = ref(false)
const columns = shallowRef([]) const columns = shallowRef([])
const valueList = shallowRef([]) const valueList = shallowRef([])
const tableData = shallowRef([]) const tableData = shallowRef([])
@ -252,8 +253,12 @@ const next = () => {
cancelMap['/datasource/checkApiDatasource']?.() cancelMap['/datasource/checkApiDatasource']?.()
const params = Base64.encode(JSON.stringify(paramsList)) const params = Base64.encode(JSON.stringify(paramsList))
disabledNext.value = true
formLoading.value = true
checkApiItem({ data: Base64.encode(JSON.stringify(apiItem)), paramsList: params }) checkApiItem({ data: Base64.encode(JSON.stringify(apiItem)), paramsList: params })
.then(response => { .then(response => {
disabledNext.value = false
formLoading.value = false
apiItem.jsonFields = response.data.jsonFields apiItem.jsonFields = response.data.jsonFields
apiItem.fields = [] apiItem.fields = []
handleFiledChange(apiItem) handleFiledChange(apiItem)
@ -261,6 +266,8 @@ const next = () => {
active.value += 1 active.value += 1
}) })
.catch(error => { .catch(error => {
disabledNext.value = false
formLoading.value = false
console.log(error?.message) console.log(error?.message)
}) })
} }
@ -438,6 +445,7 @@ defineExpose({
label-width="100px" label-width="100px"
require-asterisk-position="right" require-asterisk-position="right"
:rules="rule" :rules="rule"
v-loading="formLoading"
> >
<div class="title-form_primary base-info"> <div class="title-form_primary base-info">
<span>{{ t('datasource.base_info') }}</span> <span>{{ t('datasource.base_info') }}</span>