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