perf: 优化全局接口功能

This commit is contained in:
奔跑的面条 2022-12-15 19:48:16 +08:00
parent 4baa5719a0
commit 390b1d0fde
3 changed files with 26 additions and 112 deletions

View File

@ -113,94 +113,7 @@ export const useChartEditStore = defineStore({
},
// 数据请求处理(需存储给后端)
requestGlobalConfig: {
requestDataPond: [{
dataPondId: '1',
dataPondName: '我是数据池1',
dataPondRequestConfig: {
requestUrl: '',
requestContentType: 0,
requestDataType: 0,
// @ts-ignore
requestHttpType: 'get',
// @ts-ignore
requestParamsBodyType: 'json',
requestSQLContent: {
sql: 'select *'
},
requestParams: {
Body: {
'form-data': {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
},
'x-www-form-urlencoded': {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
},
json: '{}',
xml: '{}'
},
Header: {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
},
Params: {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
}
}
}
},
{
dataPondId: '2',
dataPondName: '我是数据池2',
dataPondRequestConfig: {
requestUrl: '',
requestContentType: 0,
requestDataType: 0,
// @ts-ignore
requestHttpType: 'get',
// @ts-ignore
requestParamsBodyType: 'none',
requestSQLContent: {
sql: 'select *'
},
requestParams: {
Body: {
'form-data': {
xxx: '23123'
},
'x-www-form-urlencoded': {
xxx: '23123'
},
json: '{}',
xml: '{}'
},
Header: {
xxx: '23123'
},
Params: {
xxx: '23123'
}
}
}
}],
requestDataPond: [],
requestOriginUrl: '',
requestInterval: requestInterval,
requestIntervalUnit: requestIntervalUnit,

View File

@ -8,23 +8,15 @@
<n-input size="small" :placeholder="targetData?.dataPondName || '暂无'" :disabled="true"> </n-input>
</setting-item>
<setting-item name="接口类型">
<n-input
size="small"
:placeholder="targetData?.dataPondRequestConfig.requestHttpType || '暂无'"
:disabled="true"
></n-input>
<n-input size="small" :placeholder="requestHttpType || '暂无'" :disabled="true"></n-input>
</setting-item>
</setting-item-box>
<setting-item-box>
<setting-item name="组件间隔">
<n-input
size="small"
:placeholder="`${targetData?.dataPondRequestConfig.requestInterval || '暂无'}`"
:disabled="true"
>
<n-input size="small" :placeholder="`${requestInterval || '暂无'}`" :disabled="true">
<template #suffix>
{{ targetData && SelectHttpTimeNameObj[targetData.dataPondRequestConfig.requestIntervalUnit] }}
{{ targetData && SelectHttpTimeNameObj[requestIntervalUnit] }}
</template>
</n-input>
</setting-item>
@ -46,7 +38,7 @@
<setting-item-box name="接口地址" :alone="true">
<n-input
size="small"
:placeholder="targetData?.dataPondRequestConfig.requestUrl || '暂无'"
:placeholder="requestUrl || '暂无'"
:disabled="true"
>
<template #prefix>
@ -60,7 +52,7 @@
<setting-item name="配置类型">
<n-input
size="small"
:placeholder="targetData && requestContentTypeObj[targetData?.dataPondRequestConfig.requestContentType]"
:placeholder="targetData && requestContentTypeObj[requestContentType]"
:disabled="true"
></n-input>
</setting-item>
@ -68,7 +60,7 @@
<n-input size="small" :placeholder="targetData && requestParamsBodyType" :disabled="true"></n-input>
</setting-item>
</setting-item-box>
<div v-if="targetData?.dataPondRequestConfig.requestContentType === RequestContentTypeEnum.DEFAULT">
<div v-if="requestContentType === RequestContentTypeEnum.DEFAULT">
<n-tabs type="line" animated v-model:value="tabValue">
<n-tab v-for="item in RequestParamsTypeEnum" :key="item" :name="item" :tab="item"> {{ item }} </n-tab>
</n-tabs>
@ -124,7 +116,7 @@
<n-text>sql</n-text>
</setting-item-box>
<setting-item-box name="键值">
<n-code :code="targetData?.dataPondRequestConfig.requestSQLContent.sql || ''" language="sql"></n-code>
<n-code :code="requestSQLContent.sql || ''" language="sql"></n-code>
</setting-item-box>
</div>
</div>
@ -154,9 +146,18 @@ const props = defineProps({
})
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
const { requestHttpType, requestContentType, requestSQLContent, requestParams, requestParamsBodyType } = toRefs(
(props.targetData as RequestDataPondItemType).dataPondRequestConfig
)
const {
requestUrl,
requestInterval,
requestHttpType,
requestContentType,
requestSQLContent,
requestParams,
requestParamsBodyType,
requestIntervalUnit
} = toRefs((props.targetData as RequestDataPondItemType).dataPondRequestConfig)
console.log((props.targetData as RequestDataPondItemType).dataPondRequestConfig)
const tabs = [RequestParamsTypeEnum.HEADER]
const requestContentTypeObj = {

View File

@ -5,12 +5,6 @@
<n-timeline-item type="success"></n-timeline-item>
</n-timeline>
<div class="pond-item-box">
<n-space v-if="!requestDataPond.length" justify="center">
<n-text class="not-layer-text" :depth="3">
暂无数据内容
<n-a @click="createPond">立即创建</n-a>
</n-text>
</n-space>
<!-- 新增 -->
<n-button class="create-btn go-py-4" ghost @click="createPond">
<span> 创建 </span>
@ -21,6 +15,12 @@
</template>
</n-button>
<n-divider style="margin: 10px 0"></n-divider>
<n-space v-if="!requestDataPond.length" justify="center">
<n-text class="not-layer-text" :depth="3">
暂无数据内容
<n-a @click="createPond">立即创建</n-a>
</n-text>
</n-space>
<n-scrollbar style="max-height: 490px">
<div
v-for="item in requestDataPond"