Commit 94722a5c4ed720e69c971e0f892496597322ee93
Merge branch 'ww' into 'main_dev'
chore(types): 修复类型错误 See merge request yunteng/thingskit-view!18
Showing
2 changed files
with
18 additions
and
8 deletions
@@ -15,7 +15,12 @@ import { customRequest } from '@/api/external/customRequest' | @@ -15,7 +15,12 @@ import { customRequest } from '@/api/external/customRequest' | ||
15 | const { HelpOutlineIcon, FlashIcon } = icon.ionicons5 | 15 | const { HelpOutlineIcon, FlashIcon } = icon.ionicons5 |
16 | const { targetData } = useTargetData() | 16 | const { targetData } = useTargetData() |
17 | 17 | ||
18 | -const requestModal = ref<InstanceType<typeof RequestModal>>() | 18 | +interface ComponentExpose { |
19 | + openModal: ((flag: boolean | undefined, type: RequestDataTypeEnum) => Promise<void>) | undefined | ||
20 | +} | ||
21 | + | ||
22 | + | ||
23 | +const requestModal = ref<ComponentExpose>() | ||
19 | 24 | ||
20 | const designStore = useDesignStore() | 25 | const designStore = useDesignStore() |
21 | 26 | ||
@@ -61,7 +66,7 @@ const themeColor = computed(() => { | @@ -61,7 +66,7 @@ const themeColor = computed(() => { | ||
61 | }) | 66 | }) |
62 | 67 | ||
63 | const handleClickPanel = () => { | 68 | const handleClickPanel = () => { |
64 | - unref(requestModal)?.openModal(true, unref(selectedRequestType)) | 69 | + unref(requestModal)?.openModal?.(true, unref(selectedRequestType)) |
65 | } | 70 | } |
66 | 71 | ||
67 | watchEffect(() => { | 72 | watchEffect(() => { |
@@ -5,24 +5,28 @@ import { CreateComponentType } from '@/packages/index.d'; | @@ -5,24 +5,28 @@ import { CreateComponentType } from '@/packages/index.d'; | ||
5 | import { CreateComponentGroupType } from '@/packages/index.d'; | 5 | import { CreateComponentGroupType } from '@/packages/index.d'; |
6 | import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'; | 6 | import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'; |
7 | import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'; | 7 | import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'; |
8 | -import { GlobalComponentConfig, NButton, NDivider, NModal, NSpace, NTag } from 'naive-ui'; | 8 | +import { NButton, NDivider, NModal, NSpace, NTag } from 'naive-ui'; |
9 | import { ref, unref, computed, nextTick } from 'vue'; | 9 | import { ref, unref, computed, nextTick } from 'vue'; |
10 | import { PublicInterfaceForm } from '../PublicInterfaceForm'; | 10 | import { PublicInterfaceForm } from '../PublicInterfaceForm'; |
11 | import ComponentConfiguration from './ComponentConfiguration.vue'; | 11 | import ComponentConfiguration from './ComponentConfiguration.vue'; |
12 | import GlobalPublicConfiguration from './GlobalPublicConfiguration.vue'; | 12 | import GlobalPublicConfiguration from './GlobalPublicConfiguration.vue'; |
13 | import { createRequestModalContext } from './useRequestModalContext'; | 13 | import { createRequestModalContext } from './useRequestModalContext'; |
14 | 14 | ||
15 | +interface ComponentExpose { | ||
16 | + getConfigurationData: () => RequestConfigType | ||
17 | + setConfigurationData: (request: RequestConfigType) => void | ||
18 | + validate: () => Promise<boolean> | ||
19 | +} | ||
20 | + | ||
15 | const requestDataType = ref<RequestDataTypeEnum>(RequestDataTypeEnum.AJAX) | 21 | const requestDataType = ref<RequestDataTypeEnum>(RequestDataTypeEnum.AJAX) |
16 | 22 | ||
17 | const showModal = ref(false) | 23 | const showModal = ref(false) |
18 | 24 | ||
19 | const chartEditStore = useChartEditStore() | 25 | const chartEditStore = useChartEditStore() |
20 | 26 | ||
21 | -const globalConfigurationEl = ref<Nullable<InstanceType<typeof GlobalPublicConfiguration>>>() | 27 | +const componentConfigurationEl = ref<ComponentExpose>() |
22 | 28 | ||
23 | -const componentConfigurationEl = ref<Nullable<InstanceType<typeof ComponentConfiguration>>>() | ||
24 | - | ||
25 | -const publicInterfaceFormEl = ref<Nullable<InstanceType<typeof PublicInterfaceForm>>>() | 29 | +const publicInterfaceFormEl = ref<ComponentExpose>() |
26 | 30 | ||
27 | const getRequestTypeName = computed(() => { | 31 | const getRequestTypeName = computed(() => { |
28 | return RequestDataTypeNameEnum[RequestDataTypeEnum[unref(requestDataType)] as keyof typeof RequestDataTypeEnum] | 32 | return RequestDataTypeNameEnum[RequestDataTypeEnum[unref(requestDataType)] as keyof typeof RequestDataTypeEnum] |
@@ -34,6 +38,7 @@ const openModal = async (flag = true, type: RequestDataTypeEnum) => { | @@ -34,6 +38,7 @@ const openModal = async (flag = true, type: RequestDataTypeEnum) => { | ||
34 | requestDataType.value = type | 38 | requestDataType.value = type |
35 | showModal.value = flag | 39 | showModal.value = flag |
36 | await nextTick() | 40 | await nextTick() |
41 | + | ||
37 | unref(componentConfigurationEl)?.setConfigurationData(unref(selectTarget)!.request || {}) | 42 | unref(componentConfigurationEl)?.setConfigurationData(unref(selectTarget)!.request || {}) |
38 | unref(publicInterfaceFormEl)?.setConfigurationData(unref(selectTarget)!.request || {}) | 43 | unref(publicInterfaceFormEl)?.setConfigurationData(unref(selectTarget)!.request || {}) |
39 | } | 44 | } |
@@ -92,7 +97,7 @@ defineExpose({ | @@ -92,7 +97,7 @@ defineExpose({ | ||
92 | 97 | ||
93 | <template> | 98 | <template> |
94 | <NModal :class="prefixCls" v-model:show="showModal" preset="card" style="width: 1000px;" title="请求配置"> | 99 | <NModal :class="prefixCls" v-model:show="showModal" preset="card" style="width: 1000px;" title="请求配置"> |
95 | - <GlobalPublicConfiguration v-if="requestDataType === RequestDataTypeEnum.AJAX" ref="globalConfigurationEl" /> | 100 | + <GlobalPublicConfiguration v-if="requestDataType === RequestDataTypeEnum.AJAX" /> |
96 | <NDivider v-if="requestDataType === RequestDataTypeEnum.AJAX" /> | 101 | <NDivider v-if="requestDataType === RequestDataTypeEnum.AJAX" /> |
97 | <ComponentConfiguration v-if="requestDataType === RequestDataTypeEnum.AJAX" ref="componentConfigurationEl" /> | 102 | <ComponentConfiguration v-if="requestDataType === RequestDataTypeEnum.AJAX" ref="componentConfigurationEl" /> |
98 | <PublicInterfaceForm v-if="requestDataType === RequestDataTypeEnum.Pond" ref="publicInterfaceFormEl" /> | 103 | <PublicInterfaceForm v-if="requestDataType === RequestDataTypeEnum.Pond" ref="publicInterfaceFormEl" /> |