统一格式化参数的方法

This commit is contained in:
fofolee
2025-01-06 09:43:48 +08:00
parent d98966a5b0
commit 2dbd6f0c50
16 changed files with 130 additions and 144 deletions

View File

@@ -90,7 +90,7 @@
<script>
import { defineComponent } from "vue";
import { stringifyObject, parseFunction } from "js/composer/formatString";
import { stringifyArgv, parseFunction } from "js/composer/formatString";
export default defineComponent({
name: "OsEditor",
@@ -248,7 +248,7 @@ export default defineComponent({
return `${this.modelValue.value}.${argvs.operation}()`;
}
return `${this.modelValue.value}.${argvs.operation}(${stringifyObject(
return `${this.modelValue.value}.${argvs.operation}(${stringifyArgv(
params
)})`;
},

View File

@@ -161,7 +161,7 @@
<script>
import { defineComponent } from "vue";
import { stringifyObject, parseFunction } from "js/composer/formatString";
import { stringifyArgv, parseFunction } from "js/composer/formatString";
import VariableInput from "components/composer/ui/VariableInput.vue";
export default defineComponent({
@@ -288,33 +288,33 @@ export default defineComponent({
case "dirname":
case "extname":
case "isAbsolute":
return `${this.modelValue.value}.${argvs.operation}(${stringifyObject(
return `${this.modelValue.value}.${argvs.operation}(${stringifyArgv(
argvs.path
)})`;
case "basename":
if (argvs.ext && argvs.ext.value) {
return `${this.modelValue.value}.${
argvs.operation
}(${stringifyObject(argvs.path)}, ${stringifyObject(argvs.ext)})`;
return `${this.modelValue.value}.${argvs.operation}(${stringifyArgv(
argvs.path
)}, ${stringifyArgv(argvs.ext)})`;
}
return `${this.modelValue.value}.${argvs.operation}(${stringifyObject(
return `${this.modelValue.value}.${argvs.operation}(${stringifyArgv(
argvs.path
)})`;
case "join":
case "resolve":
return `${this.modelValue.value}.${argvs.operation}(${argvs.paths
.map((p) => stringifyObject(p))
.map((p) => stringifyArgv(p))
.join(", ")})`;
case "relative":
return `${this.modelValue.value}.${argvs.operation}(${stringifyObject(
return `${this.modelValue.value}.${argvs.operation}(${stringifyArgv(
argvs.from
)}, ${stringifyObject(argvs.to)})`;
)}, ${stringifyArgv(argvs.to)})`;
case "format":
return `${this.modelValue.value}.${argvs.operation}(${stringifyObject(
return `${this.modelValue.value}.${argvs.operation}(${stringifyArgv(
argvs.pathObject
)})`;

View File

@@ -131,11 +131,7 @@
<script>
import { defineComponent } from "vue";
import {
parseFunction,
stringifyObject,
stringifyWithType,
} from "js/composer/formatString";
import { parseFunction, stringifyArgv } from "js/composer/formatString";
import VariableInput from "components/composer/ui/VariableInput.vue";
import NumberInput from "components/composer/ui/NumberInput.vue";
import DictEditor from "components/composer/ui/DictEditor.vue";
@@ -239,7 +235,7 @@ export default defineComponent({
const args = [];
// 添加命令
args.push(stringifyWithType(argvs.command));
args.push(stringifyArgv(argvs.command));
// 添加选项
const options = { ...argvs.options };
@@ -254,7 +250,7 @@ export default defineComponent({
});
if (Object.keys(options).length > 0) {
args.push(stringifyObject(options));
args.push(stringifyArgv(options));
}
return `${this.modelValue.value}(${args.join(", ")})`;