From 7a43695e2d280eca05e60ee65dfcf9dd810a047c Mon Sep 17 00:00:00 2001 From: fofolee Date: Wed, 8 Jan 2025 14:39:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80VarInput=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E7=9A=84=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/composer/MultiParams.vue | 7 +- .../composer/common/ArrayEditor.vue | 62 ++----- src/components/composer/common/DictEditor.vue | 25 +-- .../composer/common/VariableInput.vue | 44 +---- .../composer/data/AsymmetricCryptoEditor.vue | 8 +- .../composer/data/SymmetricCryptoEditor.vue | 7 +- src/components/composer/data/ZlibEditor.vue | 8 +- .../composer/data/regex/RegexEditor.vue | 13 +- .../composer/data/regex/RegexTester.vue | 13 +- .../composer/file/FileOperationEditor.vue | 7 +- .../composer/network/AxiosConfigEditor.vue | 61 ++----- .../composer/system/SystemCommandEditor.vue | 23 +-- .../composer/ubrowser/UBrowserBasic.vue | 8 +- .../operations/UBrowserCookieList.vue | 38 +--- .../operations/UBrowserDeviceName.vue | 8 +- .../ubrowser/operations/UBrowserFileList.vue | 8 +- .../operations/UBrowserNamedParamList.vue | 29 +--- .../composer/ui/SelectListEditor.vue | 17 +- src/js/composer/commands/dataCommands.js | 10 +- src/js/composer/commands/uiCommands.js | 26 +-- src/js/composer/customComponentGuide.js | 5 +- src/js/composer/formatString.js | 74 +++----- src/js/composer/ubrowserConfig.js | 164 ++++-------------- src/js/composer/varInputValManager.js | 41 +++++ 24 files changed, 190 insertions(+), 516 deletions(-) create mode 100644 src/js/composer/varInputValManager.js diff --git a/src/components/composer/MultiParams.vue b/src/components/composer/MultiParams.vue index 19c8ddb..08d6d6d 100644 --- a/src/components/composer/MultiParams.vue +++ b/src/components/composer/MultiParams.vue @@ -15,6 +15,7 @@ import { defineComponent } from "vue"; import OperationCard from "components/composer/common/OperationCard.vue"; import ParamInput from "components/composer/common/ParamInput.vue"; import { stringifyArgv, parseFunction } from "js/composer/formatString"; +import { newVarInputVal } from "js/composer/varInputValManager"; export default defineComponent({ name: "MultiParams", @@ -52,11 +53,7 @@ export default defineComponent({ return [...this.commonConfig, ...this.functionConfig].map((item) => { const value = item.type === "varInput" - ? item.defaultValue || { - value: "", - isString: true, - __varInputVal__: true, - } + ? item.defaultValue || newVarInputVal("str") : // 其他类型情况复杂,不做判断,没有默认值返回undefined item.defaultValue; return { diff --git a/src/components/composer/common/ArrayEditor.vue b/src/components/composer/common/ArrayEditor.vue index a11b71e..c5f536e 100644 --- a/src/components/composer/common/ArrayEditor.vue +++ b/src/components/composer/common/ArrayEditor.vue @@ -94,35 +94,30 @@ * @example * // 基础数组 * [ - * { - * value: "张三", - * isString: true, - * __varInputVal__: true - * } + * newVarInputVal("str", "张三") * ] * * // 多键对象数组 * options.keys = ['name', 'age', 'email'] * [ * { - * name: { value: "张三", isString: true, __varInputVal__: true }, - * age: { value: "18", isString: false, __varInputVal__: true }, - * email: { value: "zhangsan@example.com", isString: true, __varInputVal__: true } + * name: newVarInputVal("str", "张三"), + * age: newVarInputVal("str", "18"), + * email: newVarInputVal("str", "zhangsan@example.com") * } * ] * * // 下拉选择模式 * options.items = ['选项1', '选项2', '选项3'] * [ - * { - * value: "选项1", - * isString: true, - * __varInputVal__: true - * } + * newVarInputVal("str", "选项1"), + * newVarInputVal("str", "选项2"), + * newVarInputVal("str", "选项3") * ] */ import { defineComponent } from "vue"; import VariableInput from "components/composer/common/VariableInput.vue"; +import { newVarInputVal } from "js/composer/varInputValManager"; export default defineComponent({ name: "ArrayEditor", @@ -169,22 +164,12 @@ export default defineComponent({ if (this.optionsKeys?.length) { const item = {}; this.optionsKeys.forEach((key) => { - item[key] = { - value: "", - isString: true, - __varInputVal__: true, - }; + item[key] = newVarInputVal("str"); }); return [item]; } - return [ - { - value: "", - isString: true, - __varInputVal__: true, - }, - ]; + return [newVarInputVal("str")]; }, /** * 添加新的数组项 @@ -195,22 +180,11 @@ export default defineComponent({ if (this.options.keys) { const newItem = {}; this.options.keys.forEach((key) => { - newItem[key] = { - value: "", - isString: true, - __varInputVal__: true, - }; + newItem[key] = newVarInputVal("str"); }); newItems = [...this.items, newItem]; } else { - newItems = [ - ...this.items, - { - value: "", - isString: true, - __varInputVal__: true, - }, - ]; + newItems = [...this.items, newVarInputVal("str")]; } this.$emit("update:modelValue", newItems); }, @@ -225,19 +199,11 @@ export default defineComponent({ if (this.options.keys) { const newItem = {}; this.options.keys.forEach((key) => { - newItem[key] = { - value: "", - isString: true, - __varInputVal__: true, - }; + newItem[key] = newVarInputVal("str"); }); newItems.push(newItem); } else { - newItems.push({ - value: "", - isString: true, - __varInputVal__: true, - }); + newItems.push(newVarInputVal("str")); } } this.$emit("update:modelValue", newItems); diff --git a/src/components/composer/common/DictEditor.vue b/src/components/composer/common/DictEditor.vue index ce51305..2514b7a 100644 --- a/src/components/composer/common/DictEditor.vue +++ b/src/components/composer/common/DictEditor.vue @@ -95,6 +95,7 @@