From 1daf8cef9a62e066ccc0fa58bcb12b4d1a41a739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E9=B9=B0?= <17kungfuboy@gmail.com> Date: Fri, 22 Apr 2022 14:16:24 +0800 Subject: [PATCH] fix: query params import --- .../pages/api/edit/header/api-edit-header.component.html | 2 +- .../app/pages/api/edit/query/api-edit-query.component.html | 2 +- .../pages/api/test/header/api-test-header.component.html | 2 +- .../app/pages/api/test/query/api-test-query.component.html | 2 +- .../components/params-import/params-import.component.html | 2 +- .../components/params-import/params-import.component.ts | 7 +++++++ 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/workbench/browser/src/app/pages/api/edit/header/api-edit-header.component.html b/src/workbench/browser/src/app/pages/api/edit/header/api-edit-header.component.html index c67f4487c..64a378036 100644 --- a/src/workbench/browser/src/app/pages/api/edit/header/api-edit-header.component.html +++ b/src/workbench/browser/src/app/pages/api/edit/header/api-edit-header.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/workbench/browser/src/app/pages/api/edit/query/api-edit-query.component.html b/src/workbench/browser/src/app/pages/api/edit/query/api-edit-query.component.html index c67f4487c..28cb1b4c4 100644 --- a/src/workbench/browser/src/app/pages/api/edit/query/api-edit-query.component.html +++ b/src/workbench/browser/src/app/pages/api/edit/query/api-edit-query.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/workbench/browser/src/app/pages/api/test/header/api-test-header.component.html b/src/workbench/browser/src/app/pages/api/test/header/api-test-header.component.html index c67f4487c..64a378036 100644 --- a/src/workbench/browser/src/app/pages/api/test/header/api-test-header.component.html +++ b/src/workbench/browser/src/app/pages/api/test/header/api-test-header.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/workbench/browser/src/app/pages/api/test/query/api-test-query.component.html b/src/workbench/browser/src/app/pages/api/test/query/api-test-query.component.html index c67f4487c..28cb1b4c4 100644 --- a/src/workbench/browser/src/app/pages/api/test/query/api-test-query.component.html +++ b/src/workbench/browser/src/app/pages/api/test/query/api-test-query.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html index e95770219..118006402 100644 --- a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html +++ b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html @@ -16,7 +16,7 @@ diff --git a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts index c9f46091c..f444265e8 100644 --- a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts +++ b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts @@ -2,6 +2,7 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; import { NzMessageService } from 'ng-zorro-antd/message'; import { whatType } from '../../../utils'; import { flatData } from '../../../utils/tree/tree.utils'; +import * as qs from 'qs'; import { form2json, parseTree, xml2UiData, isXML } from '../../../utils/data-transfer/data-transfer.utils'; @Component({ selector: 'params-import', @@ -12,6 +13,7 @@ export class ParamsImportComponent { @Input() rootType: 'array' | string | 'object' = 'object'; @Input() contentType = 'json'; @Input() baseData: object[] = []; + @Input() modalTitle: string = ''; @Output() baseDataChange = new EventEmitter(); isVisible = false; paramCode = ''; @@ -33,6 +35,7 @@ export class ParamsImportComponent { get contenTypeEditor() { switch (this.contentType) { case 'formData': + case 'query': return 'text'; default: return this.contentType; @@ -57,6 +60,10 @@ export class ParamsImportComponent { return; } } + if (this.contentType === 'query') { + paramCode = qs.parse(this.paramCode.split('?')[1]); + // console.log('-->', paramCode); + } if (this.contentType === 'formData') { const json = {}; form2json(this.paramCode).forEach((it) => {