From 5bc5eeb4db7548fc9099c4da4895ba73caa04611 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 7 Aug 2020 17:37:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=AB=98=E7=BA=A7=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/components/ApiKeyValue.vue | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/frontend/src/business/components/api/test/components/ApiKeyValue.vue b/frontend/src/business/components/api/test/components/ApiKeyValue.vue index f4777b31bd..f1760ff972 100644 --- a/frontend/src/business/components/api/test/components/ApiKeyValue.vue +++ b/frontend/src/business/components/api/test/components/ApiKeyValue.vue @@ -47,8 +47,11 @@
- - + + + {{ $t('commons.save') }} + + {{ $t('api_test.request.parameters_preview') }} @@ -171,24 +174,27 @@ export default { if (!itemValue) { return; } - let funcs = itemValue.split("|"); - let value = Mock.mock(funcs[0].trim()); - if (funcs.length === 1) { + try { + let funcs = itemValue.split("|"); + let value = Mock.mock(funcs[0].trim()); + if (funcs.length === 1) { + this.itemValuePreview = value; + return value; + } + for (let i = 1; i < funcs.length; i++) { + let func = funcs[i].trim(); + let args = func.split(":"); + let strings = []; + if (args[1]) { + strings = args[1].split(","); + } + value = funcFilters[args[0].trim()](value, ...strings); + } this.itemValuePreview = value; return value; + } catch (e) { + this.itemValuePreview = itemValue; } - - for (let i = 1; i < funcs.length; i++) { - let func = funcs[i].trim(); - let args = func.split(":"); - let strings = []; - if (args[1]) { - strings = args[1].split(","); - } - value = funcFilters[args[0].trim()](value, ...strings); - } - this.itemValuePreview = value; - return value; }, appendFunc(func) { if (this.itemValue) { @@ -198,9 +204,14 @@ export default { } }, advanced(item) { + this.currentItem = item; this.itemValueVisible = true; this.itemValue = item.value; }, + saveAdvanced() { + this.currentItem.value = this.itemValue; + this.itemValueVisible = false; + } }, created() { if (this.items.length === 0) {