Commit 3c8f52ecd7fe4f404f8f82ecb783093098b139dc
Merge branch 'perf/third-interface-05-7' into 'main_dev'
perf(src/views): 优化第三方接口 See merge request yunteng/thingskit-view!269
Showing
13 changed files
with
90 additions
and
84 deletions
@@ -147,6 +147,7 @@ export const customRequest = async (request: RequestConfigType) => { | @@ -147,6 +147,7 @@ export const customRequest = async (request: RequestConfigType) => { | ||
147 | pondRequestOriginUrl, | 147 | pondRequestOriginUrl, |
148 | pondRequestGlobalTokenKey, | 148 | pondRequestGlobalTokenKey, |
149 | pondRequestGlobalTokenSuffix, | 149 | pondRequestGlobalTokenSuffix, |
150 | + pondRequestGlobalIsToken | ||
150 | } = request as ExtraRequestConfigType | 151 | } = request as ExtraRequestConfigType |
151 | const chartEditStore = useChartEditStore() | 152 | const chartEditStore = useChartEditStore() |
152 | 153 | ||
@@ -175,7 +176,7 @@ export const customRequest = async (request: RequestConfigType) => { | @@ -175,7 +176,7 @@ export const customRequest = async (request: RequestConfigType) => { | ||
175 | { | 176 | { |
176 | url: | 177 | url: |
177 | requestHttpType === RequestHttpEnum.GET.toUpperCase() ? requestUrl : `${requestUrl}?${objConvertQuery(Params)}`, | 178 | requestHttpType === RequestHttpEnum.GET.toUpperCase() ? requestUrl : `${requestUrl}?${objConvertQuery(Params)}`, |
178 | - baseURL: requestVerificationToken ? pondRequestOriginUrl : globalRequestOriginUrl ? globalRequestOriginUrl : getOriginUrl(requestOriginUrl!), | 179 | + baseURL: pondRequestGlobalIsToken ? requestVerificationToken ? pondRequestOriginUrl : globalRequestOriginUrl ? globalRequestOriginUrl : getOriginUrl(requestOriginUrl!): pondRequestOriginUrl, |
179 | method: requestHttpType, | 180 | method: requestHttpType, |
180 | params: requestHttpType === RequestHttpEnum.GET.toUpperCase() ? Params : null, | 181 | params: requestHttpType === RequestHttpEnum.GET.toUpperCase() ? Params : null, |
181 | data: body, | 182 | data: body, |
@@ -59,6 +59,13 @@ onMounted(() => { | @@ -59,6 +59,13 @@ onMounted(() => { | ||
59 | watch( | 59 | watch( |
60 | () => props.modelValue, | 60 | () => props.modelValue, |
61 | (val: string) => { | 61 | (val: string) => { |
62 | + if(props.language === 'json') { | ||
63 | + try { | ||
64 | + JSON.parse(val) | ||
65 | + } catch (_) { | ||
66 | + window.$message.error('JSON格式有误,请仔细检查!') | ||
67 | + } | ||
68 | + } | ||
62 | val !== getEditor()?.getValue() && updateMonacoVal(val) | 69 | val !== getEditor()?.getValue() && updateMonacoVal(val) |
63 | } | 70 | } |
64 | ) | 71 | ) |
@@ -63,7 +63,8 @@ export const requestConfig: RequestConfigType = { | @@ -63,7 +63,8 @@ export const requestConfig: RequestConfigType = { | ||
63 | }, | 63 | }, |
64 | "Header": {}, | 64 | "Header": {}, |
65 | "Params": {} | 65 | "Params": {} |
66 | - } | 66 | + }, |
67 | + pondRequestGlobalIsToken: true | ||
67 | } | 68 | } |
68 | 69 | ||
69 | // 单实例类 | 70 | // 单实例类 |
@@ -223,7 +223,7 @@ export interface RequestConfigType extends RequestPublicConfigType { | @@ -223,7 +223,7 @@ export interface RequestConfigType extends RequestPublicConfigType { | ||
223 | sql: string | 223 | sql: string |
224 | } | 224 | } |
225 | 225 | ||
226 | - // Token | 226 | + // 三方Token相关 |
227 | requestVerificationToken?: string | 227 | requestVerificationToken?: string |
228 | // 请求头里的Token键 | 228 | // 请求头里的Token键 |
229 | requestTokenKey?: string | 229 | requestTokenKey?: string |
@@ -250,6 +250,8 @@ export interface RequestConfigType extends RequestPublicConfigType { | @@ -250,6 +250,8 @@ export interface RequestConfigType extends RequestPublicConfigType { | ||
250 | thirdSelectCascaderLabel?: string | 250 | thirdSelectCascaderLabel?: string |
251 | publicInterfaceSelectId?: string | 251 | publicInterfaceSelectId?: string |
252 | thirdRequestDataPondId?: string | 252 | thirdRequestDataPondId?: string |
253 | + pondRequestGlobalIsToken?: boolean | ||
254 | + // | ||
253 | } | 255 | } |
254 | 256 | ||
255 | // Store 类型 | 257 | // Store 类型 |
@@ -59,15 +59,23 @@ | @@ -59,15 +59,23 @@ | ||
59 | <div class="editor-data-show"> | 59 | <div class="editor-data-show"> |
60 | <NSpace> | 60 | <NSpace> |
61 | <NText depth="3">接口返回数据(res):</NText> | 61 | <NText depth="3">接口返回数据(res):</NText> |
62 | - <NScrollbar style="max-height: 300px;"> | ||
63 | - <NCode :code="toString(isSocketRequest ? targetData.wsOriginalMessage : sourceData) || '暂无'" language="json" :word-wrap="true"></NCode> | ||
64 | - </NScrollbar> | 62 | + <n-collapse :default-expanded-names="['1']"> |
63 | + <n-collapse-item title="res" name="1"> | ||
64 | + <NScrollbar style="max-height: 300px;"> | ||
65 | + <NCode :code="toString(isSocketRequest ? targetData.wsOriginalMessage : sourceData) || '暂无'" language="json" :word-wrap="true"></NCode> | ||
66 | + </NScrollbar> | ||
67 | + </n-collapse-item> | ||
68 | + </n-collapse> | ||
65 | </NSpace> | 69 | </NSpace> |
66 | </div> | 70 | </div> |
67 | <div class="editor-data-show"> | 71 | <div class="editor-data-show"> |
68 | <NSpace> | 72 | <NSpace> |
69 | <NText depth="3">过滤器结果:</NText> | 73 | <NText depth="3">过滤器结果:</NText> |
70 | - <NCode :code="filterRes || '暂无'" language="json" :word-wrap="true"></NCode> | 74 | + <n-collapse> |
75 | + <n-collapse-item title="结果" name="2"> | ||
76 | + <NCode :code="filterRes || '暂无'" language="json" :word-wrap="true"></NCode> | ||
77 | + </n-collapse-item> | ||
78 | + </n-collapse> | ||
71 | </NSpace> | 79 | </NSpace> |
72 | </div> | 80 | </div> |
73 | </NSpace> | 81 | </NSpace> |
@@ -52,7 +52,7 @@ import { ChartDataDisplay } from '../ChartDataDisplay' | @@ -52,7 +52,7 @@ import { ChartDataDisplay } from '../ChartDataDisplay' | ||
52 | import { requestConfig } from '@/packages/public/publicConfig' | 52 | import { requestConfig } from '@/packages/public/publicConfig' |
53 | import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook' | 53 | import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook' |
54 | import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d' | 54 | import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d' |
55 | -import { RequestBodyEnum, RequestContentTypeEnum, RequestDataTypeEnum, RequestHttpEnum } from '@/enums/httpEnum' | 55 | +import { RequestDataTypeEnum } from '@/enums/httpEnum' |
56 | import { icon } from '@/plugins' | 56 | import { icon } from '@/plugins' |
57 | import { getUUID, goDialog } from '@/utils' | 57 | import { getUUID, goDialog } from '@/utils' |
58 | import { cloneDeep } from 'lodash' | 58 | import { cloneDeep } from 'lodash' |
@@ -108,57 +108,10 @@ watch( | @@ -108,57 +108,10 @@ watch( | ||
108 | const openPond = (isEditFlag = false) => { | 108 | const openPond = (isEditFlag = false) => { |
109 | isEdit.value = !!isEditFlag | 109 | isEdit.value = !!isEditFlag |
110 | requestShow.value = true | 110 | requestShow.value = true |
111 | - editData.value = cacheEditData.value || { | ||
112 | - dataPondId: getUUID(), | ||
113 | - dataPondName: getUUID(), | ||
114 | - dataPondRequestConfig: { | ||
115 | - requestDataPondId: '', | ||
116 | - requestInterval: 0, | ||
117 | - requestDataType: RequestDataTypeEnum.AJAX, | ||
118 | - requestHttpType: RequestHttpEnum.GET, | ||
119 | - requestUrl: '', | ||
120 | - requestContentType: RequestContentTypeEnum.DEFAULT, | ||
121 | - requestParamsBodyType: RequestBodyEnum.NONE, | ||
122 | - requestSQLContent: { | ||
123 | - sql: '' | ||
124 | - }, | ||
125 | - requestVerificationToken: '', | ||
126 | - requestTokenKey: '', | ||
127 | - requestTokenSuffix: '', | ||
128 | - requestParams: { | ||
129 | - "Body": { | ||
130 | - "form-data": {}, | ||
131 | - "x-www-form-urlencoded": {}, | ||
132 | - "json": "", | ||
133 | - "xml": "" | ||
134 | - }, | ||
135 | - "Header": {}, | ||
136 | - "Params": {} | ||
137 | - }, | ||
138 | - pondRequestOriginUrl: '', | ||
139 | - pondRequestInterval: 0, | ||
140 | - pondRequestIntervalUnit: '', | ||
141 | - pondRequestGlobalTokenSuffix: '', | ||
142 | - pondRequestGlobalTokenKey: '', | ||
143 | - pondRequestHttpType:'', | ||
144 | - pondRequestUrl:'', | ||
145 | - pondRequestContentType:RequestContentTypeEnum.DEFAULT, | ||
146 | - pondRequestSQLContent: { | ||
147 | - sql: '' | ||
148 | - }, | ||
149 | - pondRequestParamsBodyType: RequestBodyEnum.NONE, | ||
150 | - pondRequestParams: { | ||
151 | - "Body": { | ||
152 | - "form-data": {}, | ||
153 | - "x-www-form-urlencoded": {}, | ||
154 | - "json": "", | ||
155 | - "xml": "" | ||
156 | - }, | ||
157 | - "Header": {}, | ||
158 | - "Params": {} | ||
159 | - } | ||
160 | - } | ||
161 | - } as unknown as RequestDataPondItemType | 111 | + if (isEditFlag) { |
112 | + editData.value = cacheEditData.value | ||
113 | + targetData.value.request.pondRequestGlobalIsToken = editData.value?.dataPondRequestConfig.pondRequestGlobalIsToken | ||
114 | + } | ||
162 | } | 115 | } |
163 | 116 | ||
164 | // 创建 | 117 | // 创建 |
@@ -167,9 +120,9 @@ const createPond = () => { | @@ -167,9 +120,9 @@ const createPond = () => { | ||
167 | editData.value = { | 120 | editData.value = { |
168 | dataPondId: id, | 121 | dataPondId: id, |
169 | dataPondName: id, | 122 | dataPondName: id, |
170 | - dataPondRequestConfig: cloneDeep({ ...requestConfig, requestDataType: RequestDataTypeEnum.Pond }) | 123 | + dataPondRequestConfig: cloneDeep({ ...requestConfig, requestDataType: RequestDataTypeEnum.AJAX }) |
171 | } | 124 | } |
172 | - cacheEditData.value = editData.value | 125 | + targetData.value.request.pondRequestGlobalIsToken = true |
173 | openPond() | 126 | openPond() |
174 | } | 127 | } |
175 | 128 | ||
@@ -248,10 +201,10 @@ const deletePond = (targetData: RequestDataPondItemType) => { | @@ -248,10 +201,10 @@ const deletePond = (targetData: RequestDataPondItemType) => { | ||
248 | const closeHandle = () => { | 201 | const closeHandle = () => { |
249 | // 将所选内容赋值给对象 | 202 | // 将所选内容赋值给对象 |
250 | if (pondData.value) { | 203 | if (pondData.value) { |
251 | - targetData.value.request = { | ||
252 | - ...toRaw(pondData.value.dataPondRequestConfig), | ||
253 | - requestDataPondId: pondData.value.dataPondId | ||
254 | - } | 204 | + // targetData.value.request = { |
205 | + // ...toRaw(pondData.value.dataPondRequestConfig), | ||
206 | + // requestDataPondId: pondData.value.dataPondId | ||
207 | + // } | ||
255 | } | 208 | } |
256 | emit('update:modelShow', false) | 209 | emit('update:modelShow', false) |
257 | } | 210 | } |
@@ -100,6 +100,7 @@ const deletePond = (target: Event, targetData: RequestDataPondItemType) => { | @@ -100,6 +100,7 @@ const deletePond = (target: Event, targetData: RequestDataPondItemType) => { | ||
100 | // 选中 | 100 | // 选中 |
101 | const clickHandle = (item: RequestDataPondItemType) => { | 101 | const clickHandle = (item: RequestDataPondItemType) => { |
102 | targetData.value.request.requestDataPondId = item.dataPondId | 102 | targetData.value.request.requestDataPondId = item.dataPondId |
103 | + targetData.value.request.pondRequestGlobalIsToken = item.dataPondRequestConfig.pondRequestGlobalIsToken | ||
103 | } | 104 | } |
104 | </script> | 105 | </script> |
105 | 106 |
1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
2 | -import { ref, computed, onBeforeUnmount, watchEffect, unref } from 'vue' | 2 | +import { ref, computed, onBeforeUnmount, watchEffect, unref, watch } from 'vue' |
3 | import { icon } from '@/plugins' | 3 | import { icon } from '@/plugins' |
4 | import { useDesignStore } from '@/store/modules/designStore/designStore' | 4 | import { useDesignStore } from '@/store/modules/designStore/designStore' |
5 | import { SettingItemBox } from '@/components/Pages/ChartItemSetting' | 5 | import { SettingItemBox } from '@/components/Pages/ChartItemSetting' |
@@ -99,6 +99,10 @@ const controlModel = ref(false) | @@ -99,6 +99,10 @@ const controlModel = ref(false) | ||
99 | 99 | ||
100 | const handleOpenChartDataPondModal = () => controlModel.value = true | 100 | const handleOpenChartDataPondModal = () => controlModel.value = true |
101 | 101 | ||
102 | +watch(()=>targetData.value, (newValue) => { | ||
103 | + selectedRequestType.value = newValue?.request?.requestDataType as unknown as any | ||
104 | +}) | ||
105 | + | ||
102 | </script> | 106 | </script> |
103 | 107 | ||
104 | <template> | 108 | <template> |
@@ -18,14 +18,14 @@ import { | @@ -18,14 +18,14 @@ import { | ||
18 | CascaderOption, | 18 | CascaderOption, |
19 | NCascader, | 19 | NCascader, |
20 | } from 'naive-ui' | 20 | } from 'naive-ui' |
21 | -import { computed, onMounted, reactive, ref, unref, watch } from 'vue' | 21 | +import { computed, onMounted, reactive, ref, unref } from 'vue' |
22 | import GlobalParamsConfiguration from './GlobalParamsConfiguration.vue' | 22 | import GlobalParamsConfiguration from './GlobalParamsConfiguration.vue' |
23 | import { ChevronDown, ChevronUp } from '@vicons/carbon' | 23 | import { ChevronDown, ChevronUp } from '@vicons/carbon' |
24 | import { useDesignStore } from '@/store/modules/designStore/designStore' | 24 | import { useDesignStore } from '@/store/modules/designStore/designStore' |
25 | import { selectTimeOptions } from '../../../index.d' | 25 | import { selectTimeOptions } from '../../../index.d' |
26 | import { useTargetData } from '../../../../hooks/useTargetData.hook' | 26 | import { useTargetData } from '../../../../hooks/useTargetData.hook' |
27 | import { RequestDataTypeEnum, RequestHttpIntervalEnum } from '@/enums/httpEnum' | 27 | import { RequestDataTypeEnum, RequestHttpIntervalEnum } from '@/enums/httpEnum' |
28 | -import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d' | 28 | +import { RequestConfigType, RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d' |
29 | import { convertToCascadingData } from '@/utils/external/utils' | 29 | import { convertToCascadingData } from '@/utils/external/utils' |
30 | import { customThirdInterfaceRequest, thirdInterfaceRequest } from '@/api/external/customRequest' | 30 | import { customThirdInterfaceRequest, thirdInterfaceRequest } from '@/api/external/customRequest' |
31 | 31 | ||
@@ -52,6 +52,8 @@ const themeColor = computed(() => { | @@ -52,6 +52,8 @@ const themeColor = computed(() => { | ||
52 | 52 | ||
53 | const selectGlobalPondValue = ref('') | 53 | const selectGlobalPondValue = ref('') |
54 | 54 | ||
55 | +const selectGlobalPondIsToken = ref(true) | ||
56 | + | ||
55 | const cacheSelectOption = ref<Recordable>({ | 57 | const cacheSelectOption = ref<Recordable>({ |
56 | dataPondRequestConfig:{ | 58 | dataPondRequestConfig:{ |
57 | pondRequestOriginUrl:'', | 59 | pondRequestOriginUrl:'', |
@@ -104,6 +106,7 @@ const findCurrentPond = () => { | @@ -104,6 +106,7 @@ const findCurrentPond = () => { | ||
104 | } | 106 | } |
105 | 107 | ||
106 | const handleSelectGlobalPond = (_:string, options:RequestDataPondItemType & {label: string, value: string}) => { | 108 | const handleSelectGlobalPond = (_:string, options:RequestDataPondItemType & {label: string, value: string}) => { |
109 | + selectGlobalPondIsToken.value = options.dataPondRequestConfig.pondRequestGlobalIsToken! | ||
107 | cacheSelectOption.value = options | 110 | cacheSelectOption.value = options |
108 | targetData.value.request = options.dataPondRequestConfig | 111 | targetData.value.request = options.dataPondRequestConfig |
109 | targetData.value.request.requestDataPondId = options.dataPondId | 112 | targetData.value.request.requestDataPondId = options.dataPondId |
@@ -136,8 +139,12 @@ const handleExecuteRequest = async () => { | @@ -136,8 +139,12 @@ const handleExecuteRequest = async () => { | ||
136 | onMounted(()=>{ | 139 | onMounted(()=>{ |
137 | getTokenString.value = targetData.value?.request?.requestVerificationToken | 140 | getTokenString.value = targetData.value?.request?.requestVerificationToken |
138 | selectGlobalPondValue.value = findCurrentPond()?.dataPondId as string | 141 | selectGlobalPondValue.value = findCurrentPond()?.dataPondId as string |
142 | + selectGlobalPondIsToken.value = findCurrentPond()?.dataPondRequestConfig.pondRequestGlobalIsToken as boolean | ||
139 | cacheSelectOption.value = findCurrentPond() as RequestDataPondItemType | 143 | cacheSelectOption.value = findCurrentPond() as RequestDataPondItemType |
140 | resValue.value = targetData.value?.request?.thirdSelectCascaderLabel | 144 | resValue.value = targetData.value?.request?.thirdSelectCascaderLabel |
145 | + targetData.value.request.pondRequestOriginUrl = findCurrentPond()?.dataPondRequestConfig?.pondRequestOriginUrl | ||
146 | + targetData.value.request.pondRequestGlobalTokenKey = findCurrentPond()?.dataPondRequestConfig?.pondRequestGlobalTokenKey | ||
147 | + targetData.value.request.pondRequestGlobalTokenSuffix = findCurrentPond()?.dataPondRequestConfig?.pondRequestGlobalTokenSuffix | ||
141 | handleExecuteRequest() | 148 | handleExecuteRequest() |
142 | }) | 149 | }) |
143 | </script> | 150 | </script> |
@@ -245,7 +252,7 @@ onMounted(()=>{ | @@ -245,7 +252,7 @@ onMounted(()=>{ | ||
245 | </SettingItem> | 252 | </SettingItem> |
246 | </SettingItemBox> | 253 | </SettingItemBox> |
247 | <NDivider /> | 254 | <NDivider /> |
248 | - <div style="margin:0 70px" v-if="selectGlobalPondValue"> | 255 | + <div style="margin:0 70px" v-if="selectGlobalPondValue && selectGlobalPondIsToken"> |
249 | <n-space vertical> | 256 | <n-space vertical> |
250 | <n-button type="primary" @click="handleExecuteRequest">执行请求</n-button> | 257 | <n-button type="primary" @click="handleExecuteRequest">执行请求</n-button> |
251 | <NCascader | 258 | <NCascader |
@@ -13,7 +13,6 @@ | @@ -13,7 +13,6 @@ | ||
13 | <div class="go-pr-3"> | 13 | <div class="go-pr-3"> |
14 | <n-space vertical> | 14 | <n-space vertical> |
15 | <PondPublicConfiguration ref="pondPublicConfigurationRef" /> | 15 | <PondPublicConfiguration ref="pondPublicConfigurationRef" /> |
16 | - <NDivider /> | ||
17 | <PondRequestConfiguration ref="pondRequestConfigurationRef" /> | 16 | <PondRequestConfiguration ref="pondRequestConfigurationRef" /> |
18 | </n-space> | 17 | </n-space> |
19 | </div> | 18 | </div> |
@@ -48,11 +47,10 @@ | @@ -48,11 +47,10 @@ | ||
48 | 47 | ||
49 | <script script lang="ts" setup> | 48 | <script script lang="ts" setup> |
50 | import { PropType, ref, watch, onMounted, nextTick } from 'vue' | 49 | import { PropType, ref, watch, onMounted, nextTick } from 'vue' |
51 | -import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d' | 50 | +import { RequestConfigType, RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d' |
52 | import { goDialog } from '@/utils' | 51 | import { goDialog } from '@/utils' |
53 | import PondPublicConfiguration from './PondPublicConfiguration.vue' | 52 | import PondPublicConfiguration from './PondPublicConfiguration.vue' |
54 | import PondRequestConfiguration from './PondRequestConfiguration.vue' | 53 | import PondRequestConfiguration from './PondRequestConfiguration.vue' |
55 | -import { merge } from 'lodash' | ||
56 | import { useTargetData } from '../../../../hooks/useTargetData.hook' | 54 | import { useTargetData } from '../../../../hooks/useTargetData.hook' |
57 | 55 | ||
58 | const props = defineProps({ | 56 | const props = defineProps({ |
@@ -78,7 +76,7 @@ watch( | @@ -78,7 +76,7 @@ watch( | ||
78 | modelShowRef.value = newValue | 76 | modelShowRef.value = newValue |
79 | if(newValue) { | 77 | if(newValue) { |
80 | nextTick(() => { | 78 | nextTick(() => { |
81 | - pondPublicConfigurationRef?.value?.setConfigurationData(props.targetDataRequest?.dataPondRequestConfig as unknown as RequestDataPondItemType) | 79 | + pondPublicConfigurationRef?.value?.setConfigurationData(props.targetDataRequest?.dataPondRequestConfig as unknown as RequestConfigType) |
82 | pondRequestConfigurationRef?.value?.setConfigurationData(props.targetDataRequest?.dataPondRequestConfig as unknown as RequestDataPondItemType) | 80 | pondRequestConfigurationRef?.value?.setConfigurationData(props.targetDataRequest?.dataPondRequestConfig as unknown as RequestDataPondItemType) |
83 | }) | 81 | }) |
84 | } | 82 | } |
@@ -97,14 +95,15 @@ const closeAndSendHandle = () => { | @@ -97,14 +95,15 @@ const closeAndSendHandle = () => { | ||
97 | } | 95 | } |
98 | const pondPublicData = pondPublicConfigurationRef?.value?.getConfigurationData() | 96 | const pondPublicData = pondPublicConfigurationRef?.value?.getConfigurationData() |
99 | const pondRequestData = pondRequestConfigurationRef?.value?.getConfigurationData() | 97 | const pondRequestData = pondRequestConfigurationRef?.value?.getConfigurationData() |
100 | - merge(props.targetDataRequest.dataPondRequestConfig, pondRequestData, pondPublicData) | 98 | + const mergeTargetDataRequestData = Object.assign(props.targetDataRequest.dataPondRequestConfig, pondPublicData, pondRequestData) |
99 | + props.targetDataRequest.dataPondRequestConfig = mergeTargetDataRequestData | ||
101 | goDialog({ | 100 | goDialog({ |
102 | message: '保存内容将同步修改所有使用此接口的组件, 是否继续?', | 101 | message: '保存内容将同步修改所有使用此接口的组件, 是否继续?', |
103 | isMaskClosable: true, | 102 | isMaskClosable: true, |
104 | transformOrigin: 'center', | 103 | transformOrigin: 'center', |
105 | onPositiveCallback: () => { | 104 | onPositiveCallback: () => { |
106 | emit('update:modelShow', false) | 105 | emit('update:modelShow', false) |
107 | - emit('editSaveHandle', props.targetDataRequest) | 106 | + emit('editSaveHandle', props.targetDataRequest) |
108 | } | 107 | } |
109 | }) | 108 | }) |
110 | } | 109 | } |
@@ -21,11 +21,15 @@ import { ChevronDown, ChevronUp } from '@vicons/carbon' | @@ -21,11 +21,15 @@ import { ChevronDown, ChevronUp } from '@vicons/carbon' | ||
21 | import { useDesignStore } from '@/store/modules/designStore/designStore' | 21 | import { useDesignStore } from '@/store/modules/designStore/designStore' |
22 | import { selectTimeOptions } from '../../../index.d' | 22 | import { selectTimeOptions } from '../../../index.d' |
23 | import { RequestHttpIntervalEnum } from '@/enums/httpEnum' | 23 | import { RequestHttpIntervalEnum } from '@/enums/httpEnum' |
24 | +import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d' | ||
25 | +import { useTargetData } from '../../../../hooks/useTargetData.hook' | ||
24 | 26 | ||
25 | const { PencilIcon } = icon.ionicons5 | 27 | const { PencilIcon } = icon.ionicons5 |
26 | 28 | ||
27 | const designStore = useDesignStore() | 29 | const designStore = useDesignStore() |
28 | 30 | ||
31 | +const { targetData } = useTargetData() | ||
32 | + | ||
29 | const editDisabled = ref(false) | 33 | const editDisabled = ref(false) |
30 | 34 | ||
31 | const collapseHeaderTable = ref(false) | 35 | const collapseHeaderTable = ref(false) |
@@ -40,6 +44,8 @@ const pondRequestGlobalTokenSuffixRef = ref('') | @@ -40,6 +44,8 @@ const pondRequestGlobalTokenSuffixRef = ref('') | ||
40 | 44 | ||
41 | const pondRequestGlobalTokenKeyRef = ref('') | 45 | const pondRequestGlobalTokenKeyRef = ref('') |
42 | 46 | ||
47 | +const pondRequestGlobalIsTokenRef = ref(true) | ||
48 | + | ||
43 | const handleCollapse = () => { | 49 | const handleCollapse = () => { |
44 | collapseHeaderTable.value = !unref(collapseHeaderTable) | 50 | collapseHeaderTable.value = !unref(collapseHeaderTable) |
45 | } | 51 | } |
@@ -49,23 +55,29 @@ const themeColor = computed(() => { | @@ -49,23 +55,29 @@ const themeColor = computed(() => { | ||
49 | return designStore.getAppTheme | 55 | return designStore.getAppTheme |
50 | }) | 56 | }) |
51 | 57 | ||
52 | -const getConfigurationData = (): Recordable => { | 58 | +const handleIsTokenSwitch = (value: boolean) => { |
59 | + targetData.value.request.pondRequestGlobalIsToken = value | ||
60 | +} | ||
61 | + | ||
62 | +const getConfigurationData = (): Partial<RequestConfigType> => { | ||
53 | return { | 63 | return { |
54 | pondRequestOriginUrl: unref(pondRequestOriginUrlRef), | 64 | pondRequestOriginUrl: unref(pondRequestOriginUrlRef), |
55 | pondRequestInterval: unref(pondRequestIntervalRef), | 65 | pondRequestInterval: unref(pondRequestIntervalRef), |
56 | pondRequestIntervalUnit: unref(pondRequestIntervalUnitRef), | 66 | pondRequestIntervalUnit: unref(pondRequestIntervalUnitRef), |
57 | pondRequestGlobalTokenSuffix: unref(pondRequestGlobalTokenSuffixRef), | 67 | pondRequestGlobalTokenSuffix: unref(pondRequestGlobalTokenSuffixRef), |
58 | pondRequestGlobalTokenKey: unref(pondRequestGlobalTokenKeyRef), | 68 | pondRequestGlobalTokenKey: unref(pondRequestGlobalTokenKeyRef), |
69 | + pondRequestGlobalIsToken: unref(pondRequestGlobalIsTokenRef), | ||
59 | } | 70 | } |
60 | } | 71 | } |
61 | 72 | ||
62 | -const setConfigurationData = (request: Recordable) => { | ||
63 | - const { pondRequestOriginUrl, pondRequestInterval, pondRequestIntervalUnit, pondRequestGlobalTokenSuffix, pondRequestGlobalTokenKey } = request | ||
64 | - pondRequestOriginUrlRef.value = pondRequestOriginUrl | 73 | +const setConfigurationData = (request: Partial<RequestConfigType>) => { |
74 | + const { pondRequestOriginUrl, pondRequestInterval, pondRequestIntervalUnit, pondRequestGlobalTokenSuffix, pondRequestGlobalTokenKey, pondRequestGlobalIsToken } = request | ||
75 | + pondRequestOriginUrlRef.value = pondRequestOriginUrl! | ||
65 | pondRequestIntervalRef.value = pondRequestInterval | 76 | pondRequestIntervalRef.value = pondRequestInterval |
66 | - pondRequestIntervalUnitRef.value = pondRequestIntervalUnit | ||
67 | - pondRequestGlobalTokenSuffixRef.value = pondRequestGlobalTokenSuffix | ||
68 | - pondRequestGlobalTokenKeyRef.value = pondRequestGlobalTokenKey | 77 | + pondRequestIntervalUnitRef.value = pondRequestIntervalUnit! |
78 | + pondRequestGlobalTokenSuffixRef.value = pondRequestGlobalTokenSuffix! | ||
79 | + pondRequestGlobalTokenKeyRef.value = pondRequestGlobalTokenKey! | ||
80 | + pondRequestGlobalIsTokenRef.value = pondRequestGlobalIsToken! | ||
69 | } | 81 | } |
70 | 82 | ||
71 | defineExpose({ | 83 | defineExpose({ |
@@ -129,7 +141,12 @@ defineExpose({ | @@ -129,7 +141,12 @@ defineExpose({ | ||
129 | </NButton> | 141 | </NButton> |
130 | </SettingItemBox> | 142 | </SettingItemBox> |
131 | <!-- 针对第三方接口 --> | 143 | <!-- 针对第三方接口 --> |
132 | - <SettingItemBox name="配置"> | 144 | + <SettingItemBox name="Token配置"> |
145 | + <SettingItem> | ||
146 | + <n-switch @update:value="handleIsTokenSwitch" v-model:value="pondRequestGlobalIsTokenRef"/> | ||
147 | + </SettingItem> | ||
148 | + </SettingItemBox> | ||
149 | + <SettingItemBox v-if="pondRequestGlobalIsTokenRef" name="配置"> | ||
133 | <SettingItem name="请求标头"> | 150 | <SettingItem name="请求标头"> |
134 | <n-input v-model:value.trim="pondRequestGlobalTokenKeyRef" type="text" placeholder="默认值: X-Authorization " /> | 151 | <n-input v-model:value.trim="pondRequestGlobalTokenKeyRef" type="text" placeholder="默认值: X-Authorization " /> |
135 | </SettingItem> | 152 | </SettingItem> |
@@ -12,6 +12,9 @@ import { | @@ -12,6 +12,9 @@ import { | ||
12 | import { ref, unref } from 'vue' | 12 | import { ref, unref } from 'vue' |
13 | import DefaultRequestContent from './DefaultRequestContent.vue' | 13 | import DefaultRequestContent from './DefaultRequestContent.vue' |
14 | import SqlConfiguration from './SqlConfiguration.vue' | 14 | import SqlConfiguration from './SqlConfiguration.vue' |
15 | +import { useTargetData } from '../../../../hooks/useTargetData.hook' | ||
16 | + | ||
17 | +const { targetData } = useTargetData() | ||
15 | 18 | ||
16 | const pondRequestContentTypeRef = ref(RequestContentTypeEnum.DEFAULT) | 19 | const pondRequestContentTypeRef = ref(RequestContentTypeEnum.DEFAULT) |
17 | 20 | ||
@@ -74,6 +77,8 @@ defineExpose({ | @@ -74,6 +77,8 @@ defineExpose({ | ||
74 | </script> | 77 | </script> |
75 | 78 | ||
76 | <template> | 79 | <template> |
80 | + <div v-if="targetData.request.pondRequestGlobalIsToken"> | ||
81 | + <NDivider /> | ||
77 | <SettingItemBox | 82 | <SettingItemBox |
78 | name="地址" | 83 | name="地址" |
79 | :itemRightStyle="{ | 84 | :itemRightStyle="{ |
@@ -135,4 +140,5 @@ defineExpose({ | @@ -135,4 +140,5 @@ defineExpose({ | ||
135 | v-if="pondRequestContentTypeRef === RequestContentTypeEnum.SQL" | 140 | v-if="pondRequestContentTypeRef === RequestContentTypeEnum.SQL" |
136 | /> | 141 | /> |
137 | </SettingItemBox> | 142 | </SettingItemBox> |
143 | +</div> | ||
138 | </template> | 144 | </template> |
@@ -35,7 +35,6 @@ const openModal = async (flag = true, type: RequestDataTypeEnum) => { | @@ -35,7 +35,6 @@ const openModal = async (flag = true, type: RequestDataTypeEnum) => { | ||
35 | requestDataType.value = type | 35 | requestDataType.value = type |
36 | showModal.value = flag | 36 | showModal.value = flag |
37 | await nextTick() | 37 | await nextTick() |
38 | - console.log(unref(selectTarget)!.request) | ||
39 | unref(componentConfigurationEl as any)?.setConfigurationData(unref(selectTarget)!.request || {}) | 38 | unref(componentConfigurationEl as any)?.setConfigurationData(unref(selectTarget)!.request || {}) |
40 | unref(publicInterfaceFormEl as any)?.setConfigurationData(unref(selectTarget)!.request || {}) | 39 | unref(publicInterfaceFormEl as any)?.setConfigurationData(unref(selectTarget)!.request || {}) |
41 | } | 40 | } |
@@ -98,6 +97,7 @@ const handleSaveAction = async () => { | @@ -98,6 +97,7 @@ const handleSaveAction = async () => { | ||
98 | value.thirdSelectCascaderLabel = targetData.value.request.thirdSelectCascaderLabel | 97 | value.thirdSelectCascaderLabel = targetData.value.request.thirdSelectCascaderLabel |
99 | value.requestDataType = targetData.value.request.requestDataType | 98 | value.requestDataType = targetData.value.request.requestDataType |
100 | value.publicInterfaceSelectId = targetData.value.request.publicInterfaceSelectId | 99 | value.publicInterfaceSelectId = targetData.value.request.publicInterfaceSelectId |
100 | + value.pondRequestGlobalIsToken = targetData.value.request.pondRequestGlobalIsToken | ||
101 | if (unref(selectTarget)) { | 101 | if (unref(selectTarget)) { |
102 | chartEditStore.updateComponentList(chartEditStore.fetchTargetIndex(), { | 102 | chartEditStore.updateComponentList(chartEditStore.fetchTargetIndex(), { |
103 | ...unref(selectTarget)!, | 103 | ...unref(selectTarget)!, |