mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-07 21:46:12 +08:00
修复控制流程变量异常BUG
This commit is contained in:
parent
79d841e0b4
commit
db281ce38c
@ -73,7 +73,7 @@ export default defineComponent({
|
||||
values() {
|
||||
if (!this.currentFunction?.config) return [];
|
||||
return this.currentFunction.config.map(
|
||||
(input) => this.argvs[input.key] || ""
|
||||
(input) => this.argvs[input.name] || ""
|
||||
);
|
||||
},
|
||||
showBranchButton() {
|
||||
@ -94,7 +94,7 @@ export default defineComponent({
|
||||
methods: {
|
||||
handleInputUpdate(index, value) {
|
||||
const input = this.currentFunction.config[index];
|
||||
this.updateArgvs(input.key, value);
|
||||
this.updateArgvs(input.name, value);
|
||||
},
|
||||
updateArgvs(key, value) {
|
||||
const argvs = {
|
||||
@ -175,7 +175,7 @@ export default defineComponent({
|
||||
// 初始化默认值
|
||||
if (this.currentFunction?.config) {
|
||||
this.currentFunction.config.forEach((config) => {
|
||||
this.defaultArgvs[config.key] = config.defaultValue || "";
|
||||
this.defaultArgvs[config.name] = config.defaultValue || "";
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -15,6 +15,7 @@ export const controlCommands = {
|
||||
codeTemplate: "if (${condition}) {",
|
||||
config: [
|
||||
{
|
||||
name: "condition",
|
||||
label: "条件",
|
||||
component: "ControlInput",
|
||||
placeholder: "表达式",
|
||||
@ -35,6 +36,7 @@ export const controlCommands = {
|
||||
codeTemplate: "} else if (${condition}) {",
|
||||
config: [
|
||||
{
|
||||
name: "condition",
|
||||
label: "条件",
|
||||
component: "ControlInput",
|
||||
placeholder: "表达式",
|
||||
@ -63,12 +65,14 @@ export const controlCommands = {
|
||||
"for (let ${indexVar} = ${startValue}; ${indexVar} <= ${endValue}; ${indexVar} += ${stepValue}) {",
|
||||
config: [
|
||||
{
|
||||
name: "indexVar",
|
||||
label: "变量",
|
||||
component: "ControlInput",
|
||||
defaultValue: "i",
|
||||
width: 3,
|
||||
},
|
||||
{
|
||||
name: "startValue",
|
||||
label: "从",
|
||||
component: "ControlInput",
|
||||
icon: "first_page",
|
||||
@ -76,6 +80,7 @@ export const controlCommands = {
|
||||
width: 3,
|
||||
},
|
||||
{
|
||||
name: "endValue",
|
||||
label: "到",
|
||||
component: "ControlInput",
|
||||
icon: "last_page",
|
||||
@ -83,6 +88,7 @@ export const controlCommands = {
|
||||
width: 3,
|
||||
},
|
||||
{
|
||||
name: "stepValue",
|
||||
label: "步进",
|
||||
component: "ControlInput",
|
||||
icon: "trending_up",
|
||||
@ -125,18 +131,21 @@ export const controlCommands = {
|
||||
"for (let [${indexVar}, ${itemVar}] of ${arrayVar}.entries()) {",
|
||||
config: [
|
||||
{
|
||||
name: "indexVar",
|
||||
label: "元素",
|
||||
component: "ControlInput",
|
||||
defaultValue: "item",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
name: "indexVar",
|
||||
label: "索引",
|
||||
component: "ControlInput",
|
||||
defaultValue: "i",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
name: "arrayVar",
|
||||
label: "数组",
|
||||
component: "ControlInput",
|
||||
icon: "list",
|
||||
@ -179,18 +188,21 @@ export const controlCommands = {
|
||||
"for (const ${keyVar} in ${objectVar}) { const ${valueVar} = ${objectVar}[${keyVar}];",
|
||||
config: [
|
||||
{
|
||||
name: "keyVar",
|
||||
label: "键名",
|
||||
component: "ControlInput",
|
||||
defaultValue: "key",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
name: "valueVar",
|
||||
label: "值",
|
||||
component: "ControlInput",
|
||||
defaultValue: "value",
|
||||
width: 4,
|
||||
},
|
||||
{
|
||||
name: "objectVar",
|
||||
label: "对象",
|
||||
component: "ControlInput",
|
||||
defaultValue: "object",
|
||||
@ -231,6 +243,7 @@ export const controlCommands = {
|
||||
codeTemplate: "while (${condition}) {",
|
||||
config: [
|
||||
{
|
||||
name: "condition",
|
||||
label: "条件",
|
||||
component: "ControlInput",
|
||||
placeholder: "表达式",
|
||||
@ -271,6 +284,7 @@ export const controlCommands = {
|
||||
codeTemplate: "switch (${expression}) {",
|
||||
config: [
|
||||
{
|
||||
name: "expression",
|
||||
label: "变量",
|
||||
component: "ControlInput",
|
||||
placeholder: "变量或表达式",
|
||||
@ -285,6 +299,7 @@ export const controlCommands = {
|
||||
codeTemplate: "case ${value}:",
|
||||
config: [
|
||||
{
|
||||
name: "value",
|
||||
label: "值",
|
||||
component: "ControlInput",
|
||||
},
|
||||
@ -323,6 +338,7 @@ export const controlCommands = {
|
||||
codeTemplate: "} catch (${errorVar}) {",
|
||||
config: [
|
||||
{
|
||||
name: "errorVar",
|
||||
label: "错误",
|
||||
component: "ControlInput",
|
||||
defaultValue: "error",
|
||||
|
Loading…
x
Reference in New Issue
Block a user