浏览代码

fix: duplicate webhook headers

Ahmad Kholid 3 年之前
父节点
当前提交
c1645815fe
共有 2 个文件被更改,包括 10 次插入10 次删除
  1. 9 9
      src/components/newtab/workflow/edit/EditWebhook.vue
  2. 1 1
      src/utils/shared.js

+ 9 - 9
src/components/newtab/workflow/edit/EditWebhook.vue

@@ -48,7 +48,7 @@
         value="headers"
         value="headers"
         class="grid grid-cols-7 justify-items-center gap-2"
         class="grid grid-cols-7 justify-items-center gap-2"
       >
       >
-        <template v-for="(items, index) in headerRef" :key="index">
+        <template v-for="(items, index) in headers" :key="index">
           <ui-input
           <ui-input
             v-model="items.name"
             v-model="items.name"
             :placeholder="`Header ${index + 1}`"
             :placeholder="`Header ${index + 1}`"
@@ -75,15 +75,15 @@
       </ui-tab-panel>
       </ui-tab-panel>
       <ui-tab-panel value="body">
       <ui-tab-panel value="body">
         <pre
         <pre
-          v-if="!showContentModalRef"
+          v-if="!showBodyModal"
           class="rounded-lg text-gray-200 p-4 max-h-80 bg-gray-900 overflow-auto"
           class="rounded-lg text-gray-200 p-4 max-h-80 bg-gray-900 overflow-auto"
-          @click="showContentModalRef = true"
+          @click="showBodyModal = true"
           v-text="data.body"
           v-text="data.body"
         />
         />
       </ui-tab-panel>
       </ui-tab-panel>
     </ui-tab-panels>
     </ui-tab-panels>
     <ui-modal
     <ui-modal
-      v-model="showContentModalRef"
+      v-model="showBodyModal"
       content-class="max-w-3xl"
       content-class="max-w-3xl"
       :title="t('workflow.blocks.webhook.tabs.body')"
       :title="t('workflow.blocks.webhook.tabs.body')"
     >
     >
@@ -123,21 +123,21 @@ const emit = defineEmits(['update:data']);
 const { t } = useI18n();
 const { t } = useI18n();
 
 
 const activeTab = ref('headers');
 const activeTab = ref('headers');
-const headerRef = ref(props.data.headers);
-const showContentModalRef = ref(false);
+const showBodyModal = ref(false);
+const headers = ref(JSON.parse(JSON.stringify(props.data.headers)));
 
 
 function updateData(value) {
 function updateData(value) {
   emit('update:data', { ...props.data, ...value });
   emit('update:data', { ...props.data, ...value });
 }
 }
 function removeHeader(index) {
 function removeHeader(index) {
-  headerRef.value.splice(index, 1);
+  headers.value.splice(index, 1);
 }
 }
 function addHeader() {
 function addHeader() {
-  headerRef.value.push({ name: '', value: '' });
+  headers.value.push({ name: '', value: '' });
 }
 }
 
 
 watch(
 watch(
-  headerRef,
+  headers,
   (value) => {
   (value) => {
     updateData({ headers: value });
     updateData({ headers: value });
   },
   },

+ 1 - 1
src/utils/shared.js

@@ -493,7 +493,7 @@ export const tasks = {
       url: '',
       url: '',
       contentType: 'json',
       contentType: 'json',
       timeout: 10000,
       timeout: 10000,
-      headers: [{ name: '', value: '' }],
+      headers: [],
       body: '{}',
       body: '{}',
     },
     },
   },
   },