Commit 88a8638770bff172245b886048d0edf6997bba0c
Merge branch 'perf/third-interface-05-23' into 'main_dev'
perf(src/views): 优化第三方接口 See merge request yunteng/thingskit-view!265
Showing
8 changed files
with
52 additions
and
69 deletions
... | ... | @@ -4,6 +4,7 @@ import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore |
4 | 4 | import { isShareMode } from '@/views/share/hook' |
5 | 5 | import { customHttp } from './http' |
6 | 6 | import { SelectTimeAggregationFieldEnum } from '@/views/chart/ContentConfigurations/components/ChartData/external/components/SelectTImeAggregation' |
7 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | |
7 | 8 | |
8 | 9 | export enum ParamsType { |
9 | 10 | REQUIRED, |
... | ... | @@ -146,8 +147,11 @@ export const customRequest = async (request: RequestConfigType) => { |
146 | 147 | pondRequestOriginUrl, |
147 | 148 | pondRequestGlobalTokenKey, |
148 | 149 | pondRequestGlobalTokenSuffix, |
149 | - | |
150 | 150 | } = request as ExtraRequestConfigType |
151 | + const chartEditStore = useChartEditStore() | |
152 | + | |
153 | + const {requestOriginUrl: globalRequestOriginUrl} = chartEditStore.getRequestGlobalConfig | |
154 | + | |
151 | 155 | let { requestUrl } = request as ExtraRequestConfigType |
152 | 156 | const { Header, Body } = requestParams |
153 | 157 | let { Params } = requestParams |
... | ... | @@ -171,7 +175,7 @@ export const customRequest = async (request: RequestConfigType) => { |
171 | 175 | { |
172 | 176 | url: |
173 | 177 | requestHttpType === RequestHttpEnum.GET.toUpperCase() ? requestUrl : `${requestUrl}?${objConvertQuery(Params)}`, |
174 | - baseURL: requestVerificationToken ? pondRequestOriginUrl : getOriginUrl(requestOriginUrl!), | |
178 | + baseURL: requestVerificationToken ? pondRequestOriginUrl : globalRequestOriginUrl ? globalRequestOriginUrl : getOriginUrl(requestOriginUrl!), | |
175 | 179 | method: requestHttpType, |
176 | 180 | params: requestHttpType === RequestHttpEnum.GET.toUpperCase() ? Params : null, |
177 | 181 | data: body, |
... | ... | @@ -180,7 +184,8 @@ export const customRequest = async (request: RequestConfigType) => { |
180 | 184 | { |
181 | 185 | joinPrefix: false, |
182 | 186 | apiUrl: '', |
183 | - withShareToken: isShareMode(), | |
187 | + withToken:true, | |
188 | + withShareToken: !requestVerificationToken ? isShareMode(): false, | |
184 | 189 | withThirdTokenString: requestVerificationToken, |
185 | 190 | withThirdTokenKey: pondRequestGlobalTokenKey, |
186 | 191 | withThirdTokenPrefix: pondRequestGlobalTokenSuffix | ... | ... |
... | ... | @@ -236,11 +236,10 @@ export interface RequestConfigType extends RequestPublicConfigType { |
236 | 236 | pondRequestGlobalTokenKey?: string |
237 | 237 | pondRequestGlobalCascaderOption?: Recordable |
238 | 238 | pondRequestGlobalCascaderKey?: string |
239 | - pondRequestHttpType?: string | |
239 | + pondRequestHttpType?: RequestHttpEnum | |
240 | 240 | pondRequestInterval?: number |
241 | 241 | pondRequestIntervalUnit?: string |
242 | 242 | pondRequestContentType?: number |
243 | - pondRequestHttpType?: string | |
244 | 243 | pondRequestParams?: RequestParams |
245 | 244 | pondRequestParamsBodyType?: RequestBodyEnum |
246 | 245 | pondRequestUrl?: string |
... | ... | @@ -250,6 +249,7 @@ export interface RequestConfigType extends RequestPublicConfigType { |
250 | 249 | thirdTokenIsExp?: boolean |
251 | 250 | thirdSelectCascaderLabel?: string |
252 | 251 | publicInterfaceSelectId?: string |
252 | + thirdRequestDataPondId?: string | |
253 | 253 | } |
254 | 254 | |
255 | 255 | // Store 类型 | ... | ... |
... | ... | @@ -52,58 +52,58 @@ |
52 | 52 | <setting-item name="配置类型"> |
53 | 53 | <n-input |
54 | 54 | size="small" |
55 | - :placeholder="targetData && requestContentTypeObj[requestContentType]" | |
55 | + :placeholder="targetData && requestContentTypeObj[pondRequestContentType!]" | |
56 | 56 | :disabled="true" |
57 | 57 | ></n-input> |
58 | 58 | </setting-item> |
59 | - <setting-item name="body 类型" v-if="requestContentType === RequestContentTypeEnum.DEFAULT"> | |
59 | + <setting-item name="body 类型" v-if="pondRequestContentType === RequestContentTypeEnum.DEFAULT"> | |
60 | 60 | <n-input size="small" :placeholder="targetData && requestParamsBodyType" :disabled="true"></n-input> |
61 | 61 | </setting-item> |
62 | 62 | </setting-item-box> |
63 | - <div v-if="requestContentType === RequestContentTypeEnum.DEFAULT"> | |
63 | + <div v-if="pondRequestContentType === RequestContentTypeEnum.DEFAULT"> | |
64 | 64 | <n-tabs type="line" animated v-model:value="tabValue"> |
65 | 65 | <n-tab v-for="item in RequestParamsTypeEnum" :key="item" :name="item" :tab="item"> {{ item }} </n-tab> |
66 | 66 | </n-tabs> |
67 | 67 | <!-- 各个页面 --> |
68 | 68 | <div class="go-mt-3"> |
69 | 69 | <div v-if="tabValue !== RequestParamsTypeEnum.BODY"> |
70 | - <display-table class="go-my-3" :target="requestParams[tabValue]"> </display-table> | |
70 | + <display-table class="go-my-3" :target="pondRequestParams![tabValue]"> </display-table> | |
71 | 71 | </div> |
72 | 72 | |
73 | 73 | <!-- 选择了 body --> |
74 | 74 | <div v-else> |
75 | 75 | <!-- 为 none 时 --> |
76 | - <n-card class="go-mt-3 go-pb-3" v-if="requestParamsBodyType === RequestBodyEnum['NONE']"> | |
76 | + <n-card class="go-mt-3 go-pb-3" v-if="pondRequestParamsBodyType === RequestBodyEnum['NONE']"> | |
77 | 77 | <n-text depth="3">该接口没有 Body 体</n-text> |
78 | 78 | </n-card> |
79 | 79 | |
80 | 80 | <!-- 具有对象属性时 --> |
81 | 81 | <template |
82 | 82 | v-else-if=" |
83 | - requestParamsBodyType === RequestBodyEnum['FORM_DATA'] || | |
84 | - requestParamsBodyType === RequestBodyEnum['X_WWW_FORM_URLENCODED'] | |
83 | + pondRequestParamsBodyType === RequestBodyEnum['FORM_DATA'] || | |
84 | + pondRequestParamsBodyType === RequestBodyEnum['X_WWW_FORM_URLENCODED'] | |
85 | 85 | " |
86 | 86 | > |
87 | 87 | <display-table |
88 | 88 | class="go-my-3" |
89 | - :target="requestParams[RequestParamsTypeEnum.BODY][requestParamsBodyType]" | |
89 | + :target="pondRequestParams![RequestParamsTypeEnum.BODY][pondRequestParamsBodyType]" | |
90 | 90 | ></display-table> |
91 | 91 | </template> |
92 | 92 | |
93 | 93 | <!-- json --> |
94 | - <template v-else-if="requestParamsBodyType === RequestBodyEnum['JSON']"> | |
94 | + <template v-else-if="pondRequestParamsBodyType === RequestBodyEnum['JSON']"> | |
95 | 95 | <n-card size="small" style="padding-bottom: 7px"> |
96 | 96 | <n-code |
97 | - :code="requestParams[RequestParamsTypeEnum.BODY][requestParamsBodyType] || '暂无内容'" | |
97 | + :code="pondRequestParams![RequestParamsTypeEnum.BODY][pondRequestParamsBodyType] || '暂无内容'" | |
98 | 98 | language="json" |
99 | 99 | ></n-code> |
100 | 100 | </n-card> |
101 | 101 | </template> |
102 | 102 | |
103 | 103 | <!-- xml --> |
104 | - <template v-else-if="requestParamsBodyType === RequestBodyEnum['XML']"> | |
104 | + <template v-else-if="pondRequestParamsBodyType === RequestBodyEnum['XML']"> | |
105 | 105 | <n-code |
106 | - :code="requestParams[RequestParamsTypeEnum.BODY][requestParamsBodyType] || ''" | |
106 | + :code="pondRequestParams![RequestParamsTypeEnum.BODY][pondRequestParamsBodyType!] || ''" | |
107 | 107 | language="html" |
108 | 108 | ></n-code> |
109 | 109 | </template> |
... | ... | @@ -127,7 +127,6 @@ |
127 | 127 | <script setup lang="ts"> |
128 | 128 | import { PropType, ref, toRefs } from 'vue' |
129 | 129 | import { icon } from '@/plugins' |
130 | -import { MonacoEditor } from '@/components/Pages/MonacoEditor' | |
131 | 130 | import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' |
132 | 131 | import { RequestDataPondItemType, RequestGlobalConfigType } from '@/store/modules/chartEditStore/chartEditStore.d' |
133 | 132 | import displayTable from './displayTable.vue' |
... | ... | @@ -136,8 +135,6 @@ import { |
136 | 135 | RequestParamsTypeEnum, |
137 | 136 | SelectHttpTimeNameObj, |
138 | 137 | RequestContentTypeEnum, |
139 | - RequestBodyEnumList, | |
140 | - RequestParamsObjType | |
141 | 138 | } from '@/enums/httpEnum' |
142 | 139 | |
143 | 140 | const props = defineProps({ |
... | ... | @@ -145,45 +142,28 @@ const props = defineProps({ |
145 | 142 | targetData: Object as PropType<RequestDataPondItemType> |
146 | 143 | }) |
147 | 144 | |
148 | -const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5 | |
145 | +const { FlashIcon, PulseIcon } = icon.ionicons5 | |
146 | + | |
149 | 147 | const { |
150 | - requestUrl, | |
151 | 148 | requestInterval, |
152 | - requestHttpType, | |
153 | - requestContentType, | |
154 | 149 | requestSQLContent, |
155 | - requestParams, | |
156 | 150 | requestParamsBodyType, |
157 | 151 | requestIntervalUnit, |
158 | 152 | pondRequestOriginUrl, |
159 | 153 | pondRequestUrl, |
160 | - pondRequestHttpType | |
154 | + pondRequestHttpType, | |
155 | + pondRequestContentType, | |
156 | + pondRequestParamsBodyType, | |
157 | + pondRequestParams, | |
161 | 158 | } = toRefs((props.targetData as RequestDataPondItemType).dataPondRequestConfig) |
162 | -const tabs = [RequestParamsTypeEnum.HEADER] | |
159 | + | |
163 | 160 | const requestContentTypeObj = { |
164 | 161 | [RequestContentTypeEnum.DEFAULT]: '普通请求', |
165 | 162 | [RequestContentTypeEnum.SQL]: 'SQL 请求' |
166 | -} | |
167 | -const tabValue = ref<RequestParamsTypeEnum>(RequestParamsTypeEnum.PARAMS) | |
163 | +} as Recordable | |
168 | 164 | |
169 | -// 更新参数表格数据 | |
170 | -const updateRequestParams = (paramsObj: RequestParamsObjType) => { | |
171 | - if (tabValue.value !== RequestParamsTypeEnum.BODY) { | |
172 | - requestParams.value[tabValue.value] = paramsObj | |
173 | - } | |
174 | -} | |
165 | +const tabValue = ref<RequestParamsTypeEnum>(RequestParamsTypeEnum.PARAMS) | |
175 | 166 | |
176 | -// 更新参数表格数据 | |
177 | -const updateRequestBodyTable = (paramsObj: RequestParamsObjType) => { | |
178 | - if ( | |
179 | - tabValue.value === RequestParamsTypeEnum.BODY && | |
180 | - // 仅有两种类型有 body | |
181 | - (requestParamsBodyType.value === RequestBodyEnum.FORM_DATA || | |
182 | - requestParamsBodyType.value === RequestBodyEnum.X_WWW_FORM_URLENCODED) | |
183 | - ) { | |
184 | - requestParams.value[RequestParamsTypeEnum.BODY][requestParamsBodyType.value] = paramsObj | |
185 | - } | |
186 | -} | |
187 | 167 | </script> |
188 | 168 | |
189 | 169 | <style lang="scss" scoped> | ... | ... |
1 | 1 | <template> |
2 | - <n-modal class="go-chart-data-pond-control" v-model:show="modelShowRef" :mask-closable="false"> | |
2 | + <n-modal class="go-chart-data-pond-control" v-model:show="modelShow" :mask-closable="false"> | |
3 | 3 | <n-card :bordered="false" role="dialog" size="small" aria-modal="true" style="width: 900px; height: 650px"> |
4 | 4 | <template #header></template> |
5 | 5 | <template #header-extra> </template> |
... | ... | @@ -57,7 +57,7 @@ import { icon } from '@/plugins' |
57 | 57 | import { getUUID, goDialog } from '@/utils' |
58 | 58 | import { cloneDeep } from 'lodash' |
59 | 59 | |
60 | -const props = defineProps({ | |
60 | +defineProps({ | |
61 | 61 | modelShow: Boolean |
62 | 62 | }) |
63 | 63 | |
... | ... | @@ -71,8 +71,6 @@ const { requestDataPond } = toRefs(chartEditStore.getRequestGlobalConfig) |
71 | 71 | |
72 | 72 | const requestShow = ref(false) |
73 | 73 | |
74 | -const modelShowRef = ref(false) | |
75 | - | |
76 | 74 | const loading = ref(false) |
77 | 75 | |
78 | 76 | const isEdit = ref(false) |
... | ... | @@ -89,14 +87,6 @@ const pondData = computed(() => { |
89 | 87 | return data[0] |
90 | 88 | }) |
91 | 89 | |
92 | -watch(() => props.modelShow, (newValue) => { | |
93 | - if (newValue) { | |
94 | - modelShowRef.value = true | |
95 | - } else { | |
96 | - modelShowRef.value = false | |
97 | - } | |
98 | -}) | |
99 | - | |
100 | 90 | const cacheEditData = ref<RequestDataPondItemType>() |
101 | 91 | |
102 | 92 | watch( |
... | ... | @@ -258,10 +248,10 @@ const deletePond = (targetData: RequestDataPondItemType) => { |
258 | 248 | const closeHandle = () => { |
259 | 249 | // 将所选内容赋值给对象 |
260 | 250 | if (pondData.value) { |
261 | - targetData.value.request = { | |
262 | - ...toRaw(pondData.value.dataPondRequestConfig), | |
263 | - requestDataPondId: pondData.value.dataPondId | |
264 | - } | |
251 | + // targetData.value.request = { | |
252 | + // ...toRaw(pondData.value.dataPondRequestConfig), | |
253 | + // requestDataPondId: pondData.value.dataPondId | |
254 | + // } | |
265 | 255 | } |
266 | 256 | emit('update:modelShow', false) |
267 | 257 | } | ... | ... |
... | ... | @@ -18,7 +18,7 @@ import { |
18 | 18 | CascaderOption, |
19 | 19 | NCascader, |
20 | 20 | } from 'naive-ui' |
21 | -import { computed, onMounted, reactive, ref, unref } from 'vue' | |
21 | +import { computed, onMounted, reactive, ref, unref, watch } from 'vue' | |
22 | 22 | import GlobalParamsConfiguration from './GlobalParamsConfiguration.vue' |
23 | 23 | import { ChevronDown, ChevronUp } from '@vicons/carbon' |
24 | 24 | import { useDesignStore } from '@/store/modules/designStore/designStore' |
... | ... | @@ -109,7 +109,7 @@ const handleSelectGlobalPond = (_:string, options:RequestDataPondItemType & {lab |
109 | 109 | targetData.value.request.requestDataPondId = options.dataPondId |
110 | 110 | getTokenString.value ='' |
111 | 111 | resOptions.value = [] |
112 | - resValue.value=null | |
112 | + resValue.value = null | |
113 | 113 | handleExecuteRequest() |
114 | 114 | } |
115 | 115 | |
... | ... | @@ -126,6 +126,7 @@ const handleExecuteRequest = async () => { |
126 | 126 | } |
127 | 127 | const res = await customThirdInterfaceRequest(request as unknown as thirdInterfaceRequest) |
128 | 128 | resOptions.value = convertToCascadingData(res) as unknown as CascaderOption[] |
129 | + resValue.value = targetData.value?.request?.thirdSelectCascaderLabel | |
129 | 130 | } |
130 | 131 | } catch (e) { |
131 | 132 | getTokenString.value = JSON.stringify(e) as string | ... | ... |
... | ... | @@ -173,11 +173,11 @@ const props = withDefaults( |
173 | 173 | |
174 | 174 | const emit = defineEmits(['update:value']) |
175 | 175 | |
176 | -const createNewRow = () => { | |
177 | - return { id: getUUID(), result: true } as DataSource | |
176 | +const createNewRow = (index?: number) => { | |
177 | + return { id: getUUID(), result: true, indexName: index, typeName: DataTypeEnum.DATA_INPUT } as DataSource | |
178 | 178 | } |
179 | 179 | |
180 | -const dataSource = ref<DataSource[]>([createNewRow()]) | |
180 | +const dataSource = ref<DataSource[]>([createNewRow(0)]) | |
181 | 181 | |
182 | 182 | const blurFlag = ref(false) |
183 | 183 | |
... | ... | @@ -187,7 +187,7 @@ watch( |
187 | 187 | if (target && isObject(target) && Object.keys(target).length) { |
188 | 188 | if (blurFlag.value) return |
189 | 189 | dataSource.value = Object.keys(props.value || {}).map((keyName, keyIndex) => ({ |
190 | - ...createNewRow(), | |
190 | + ...createNewRow(keyIndex), | |
191 | 191 | keyName, |
192 | 192 | indexName: keyIndex, |
193 | 193 | typeName: isArray(props.value![keyName]) ? DataTypeEnum.DATA_RANGE : DataTypeEnum.DATA_INPUT, |
... | ... | @@ -207,12 +207,15 @@ const canAddRow = computed(() => { |
207 | 207 | |
208 | 208 | const handleAddRow = (record: DataSource) => { |
209 | 209 | const index = unref(dataSource).findIndex(item => item.id === record.id) |
210 | - unref(dataSource).splice(index + 1, 0, createNewRow()) | |
210 | + unref(dataSource).splice(index + 1, 0, createNewRow(index + 1)) | |
211 | 211 | } |
212 | 212 | |
213 | 213 | const handleSubtractRow = (record: DataSource) => { |
214 | 214 | const index = unref(dataSource).findIndex(item => item.id === record.id) |
215 | 215 | if (unref(dataSource).length === 1) { |
216 | + unref(dataSource)[0].keyName = '' | |
217 | + unref(dataSource)[0].value = '' | |
218 | + unref(dataSource)[0].dateRange = [] | |
216 | 219 | emit('update:value', {}) |
217 | 220 | } else { |
218 | 221 | unref(dataSource).splice(index, 1) | ... | ... |
... | ... | @@ -115,6 +115,7 @@ const onEsc = () => { |
115 | 115 | |
116 | 116 | onMounted(()=>{ |
117 | 117 | pondPublicConfigurationRef?.value?.setConfigurationData(targetData.value.request) |
118 | + pondRequestConfigurationRef?.value?.setConfigurationData(targetData.value.request) | |
118 | 119 | }) |
119 | 120 | </script> |
120 | 121 | ... | ... |