Commit 6e78affd9f34fa569235ab73b4252ab63c7587f0

Authored by ww
1 parent ed285624

fix(public request): DEFECT-1239 修复未配置的空请求限制发送请求

@@ -47,7 +47,10 @@ const { fetchTargetData, } = useFetchTargetData() @@ -47,7 +47,10 @@ const { fetchTargetData, } = useFetchTargetData()
47 47
48 // 发送请求 48 // 发送请求
49 const sendHandle = async () => { 49 const sendHandle = async () => {
50 - if (!targetData.value?.request) return 50 + if (!targetData.value?.request || !targetData.value.request.requestUrl) {
  51 + window['$message'].warning('请先配置请求')
  52 + return
  53 + }
51 loading.value = true 54 loading.value = true
52 try { 55 try {
53 const res = await fetchTargetData() 56 const res = await fetchTargetData()
@@ -11,6 +11,9 @@ import { PublicInterfaceForm } from '../PublicInterfaceForm'; @@ -11,6 +11,9 @@ 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 +import { useTargetData } from '../../../../hooks/useTargetData.hook';
  15 +import { useFetchTargetData } from '@/hooks/external/useFetchTargetData';
  16 +import { useFilterFn } from '@/hooks/external/useFilterFn';
14 17
15 18
16 const requestDataType = ref<RequestDataTypeEnum>(RequestDataTypeEnum.AJAX) 19 const requestDataType = ref<RequestDataTypeEnum>(RequestDataTypeEnum.AJAX)
@@ -67,9 +70,26 @@ const getResult = () => { @@ -67,9 +70,26 @@ const getResult = () => {
67 return {} as unknown as RequestConfigType 70 return {} as unknown as RequestConfigType
68 } 71 }
69 72
  73 +const { targetData } = useTargetData()
  74 +const { fetchTargetData } = useFetchTargetData()
  75 +// 发送请求
  76 +const sendHandle = async () => {
  77 + if (!targetData.value?.request || !targetData.value.request.requestUrl) {
  78 + window['$message'].warning('请先配置请求')
  79 + return
  80 + }
  81 + const res = await fetchTargetData()
  82 + if (res) {
  83 + const { value } = useFilterFn(targetData.value.filter, res)
  84 + targetData.value.option.dataset = value
  85 + return
  86 + }
  87 +
  88 +}
  89 +
70 const handleSaveAction = async () => { 90 const handleSaveAction = async () => {
71 if (!(await validate())) return 91 if (!(await validate())) return
72 - const value = getResult() 92 + const value = getResult()
73 if (unref(selectTarget)) { 93 if (unref(selectTarget)) {
74 chartEditStore.updateComponentList(chartEditStore.fetchTargetIndex(), { 94 chartEditStore.updateComponentList(chartEditStore.fetchTargetIndex(), {
75 ...unref(selectTarget)!, 95 ...unref(selectTarget)!,
@@ -77,6 +97,7 @@ const handleSaveAction = async () => { @@ -77,6 +97,7 @@ const handleSaveAction = async () => {
77 }) 97 })
78 } 98 }
79 showModal.value = false 99 showModal.value = false
  100 + sendHandle()
80 } 101 }
81 102
82 createRequestModalContext({ 103 createRequestModalContext({