统一VarInput变量的管理

This commit is contained in:
fofolee
2025-01-08 14:39:08 +08:00
parent b528cfa97d
commit 7a43695e2d
24 changed files with 190 additions and 516 deletions

View File

@@ -178,15 +178,8 @@ import VariableInput from "../common/VariableInput.vue";
import ArrayEditor from "../common/ArrayEditor.vue";
import OperationCard from "../common/OperationCard.vue";
import { parseFunction, stringifyArgv } from "js/composer/formatString";
import { newVarInputVal, isVarInputVal} from "js/composer/varInputValManager";
const newVarInputVal = (type = "str", val = "") => {
if (typeof val !== "string") val = JSON.stringify(val);
return {
value: val,
isString: type === "str",
__varInputVal__: true,
};
};
const jsonDefaultSelects = new Array(3).fill().map((_, index) => ({
id: newVarInputVal("var", index),
@@ -228,11 +221,7 @@ export default defineComponent({
inputMode: "manual",
selects: defaultSelects.json,
optionType: "json",
placeholder: {
value: "搜索...",
isString: true,
__varInputVal__: true,
},
placeholder: newVarInputVal("str", "搜索..."),
enableSearch: true,
showCancelButton: false,
closeOnSelect: true,
@@ -303,7 +292,7 @@ export default defineComponent({
if (!result) return this.defaultArgvs;
const [selects, options = {}] = result.argvs;
const inputMode = selects.__varInputVal__ ? "variable" : "manual";
const inputMode = isVarInputVal(selects) ? "variable" : "manual";
return {
...this.defaultArgvs,
inputMode,