Commit 49bf1089e3eb9a28f0851dd189fcdaff5be79e3f

Authored by ww
1 parent b3bfc357

chore(types): 修复类型错误

... ... @@ -15,7 +15,12 @@ import { customRequest } from '@/api/external/customRequest'
15 15 const { HelpOutlineIcon, FlashIcon } = icon.ionicons5
16 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 25 const designStore = useDesignStore()
21 26
... ... @@ -61,7 +66,7 @@ const themeColor = computed(() => {
61 66 })
62 67
63 68 const handleClickPanel = () => {
64   - unref(requestModal)?.openModal(true, unref(selectedRequestType))
  69 + unref(requestModal)?.openModal?.(true, unref(selectedRequestType))
65 70 }
66 71
67 72 watchEffect(() => {
... ...
... ... @@ -5,24 +5,28 @@ import { CreateComponentType } from '@/packages/index.d';
5 5 import { CreateComponentGroupType } from '@/packages/index.d';
6 6 import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d';
7 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 9 import { ref, unref, computed, nextTick } from 'vue';
10 10 import { PublicInterfaceForm } from '../PublicInterfaceForm';
11 11 import ComponentConfiguration from './ComponentConfiguration.vue';
12 12 import GlobalPublicConfiguration from './GlobalPublicConfiguration.vue';
13 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 21 const requestDataType = ref<RequestDataTypeEnum>(RequestDataTypeEnum.AJAX)
16 22
17 23 const showModal = ref(false)
18 24
19 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 31 const getRequestTypeName = computed(() => {
28 32 return RequestDataTypeNameEnum[RequestDataTypeEnum[unref(requestDataType)] as keyof typeof RequestDataTypeEnum]
... ... @@ -34,6 +38,7 @@ const openModal = async (flag = true, type: RequestDataTypeEnum) => {
34 38 requestDataType.value = type
35 39 showModal.value = flag
36 40 await nextTick()
  41 +
37 42 unref(componentConfigurationEl)?.setConfigurationData(unref(selectTarget)!.request || {})
38 43 unref(publicInterfaceFormEl)?.setConfigurationData(unref(selectTarget)!.request || {})
39 44 }
... ... @@ -92,7 +97,7 @@ defineExpose({
92 97
93 98 <template>
94 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 101 <NDivider v-if="requestDataType === RequestDataTypeEnum.AJAX" />
97 102 <ComponentConfiguration v-if="requestDataType === RequestDataTypeEnum.AJAX" ref="componentConfigurationEl" />
98 103 <PublicInterfaceForm v-if="requestDataType === RequestDataTypeEnum.Pond" ref="publicInterfaceFormEl" />
... ...