mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
编排新增按钮组弹窗
This commit is contained in:
parent
cb85aaa790
commit
94ba695fa9
@ -53,6 +53,9 @@
|
|||||||
:icon="item.icon"
|
:icon="item.icon"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="item.type === 'arrayEditor'">
|
||||||
|
<ArrayEditor :model-value="argvs[index]" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -62,13 +65,20 @@
|
|||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import VariableInput from "components/composer/ui/VariableInput.vue";
|
import VariableInput from "components/composer/ui/VariableInput.vue";
|
||||||
import NumberInput from "components/composer/ui/NumberInput.vue";
|
import NumberInput from "components/composer/ui/NumberInput.vue";
|
||||||
import { stringifyWithType, parseToHasType } from "js/composer/formatString";
|
import ArrayEditor from "components/composer/ui/ArrayEditor.vue";
|
||||||
|
import {
|
||||||
|
stringifyWithType,
|
||||||
|
stringifyObject,
|
||||||
|
parseToHasType,
|
||||||
|
parseFunction,
|
||||||
|
} from "js/composer/formatString";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "MultiParams",
|
name: "MultiParams",
|
||||||
components: {
|
components: {
|
||||||
VariableInput,
|
VariableInput,
|
||||||
NumberInput,
|
NumberInput,
|
||||||
|
ArrayEditor,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@ -119,7 +129,11 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
generateCode(funcName, argvs) {
|
generateCode(funcName, argvs) {
|
||||||
const newArgvs = argvs
|
const newArgvs = argvs
|
||||||
.map((argv) => stringifyWithType(argv))
|
.map((argv) => {
|
||||||
|
return typeof argv === "string"
|
||||||
|
? stringifyWithType(argv)
|
||||||
|
: stringifyObject(argv);
|
||||||
|
})
|
||||||
.filter((item) => item != null && item !== "");
|
.filter((item) => item != null && item !== "");
|
||||||
console.log(newArgvs);
|
console.log(newArgvs);
|
||||||
return `${funcName}(${newArgvs.join(",")})`;
|
return `${funcName}(${newArgvs.join(",")})`;
|
||||||
@ -167,6 +181,11 @@ export default defineComponent({
|
|||||||
} else if (config.type === "numInput") {
|
} else if (config.type === "numInput") {
|
||||||
// 对于 NumberInput 类型,转换为数字
|
// 对于 NumberInput 类型,转换为数字
|
||||||
argvs[index] = Number(param) || 0;
|
argvs[index] = Number(param) || 0;
|
||||||
|
} else if (config.type === "arrayEditor") {
|
||||||
|
let result = parseFunction(`${this.funcName}(${param})`, [
|
||||||
|
"arg0[*]",
|
||||||
|
]);
|
||||||
|
argvs[index] = result.argv;
|
||||||
} else {
|
} else {
|
||||||
// 其他类型直接使用值
|
// 其他类型直接使用值
|
||||||
argvs[index] = param;
|
argvs[index] = param;
|
||||||
|
@ -6,6 +6,7 @@ import { dataCommands } from "./dataCommands";
|
|||||||
import { otherCommands } from "./otherCommands";
|
import { otherCommands } from "./otherCommands";
|
||||||
import { simulateCommands } from "./simulateCommands";
|
import { simulateCommands } from "./simulateCommands";
|
||||||
import { controlCommands } from "./controlCommands";
|
import { controlCommands } from "./controlCommands";
|
||||||
|
import { uiCommands } from "./uiCommand";
|
||||||
|
|
||||||
export const commandCategories = [
|
export const commandCategories = [
|
||||||
fileCommands,
|
fileCommands,
|
||||||
@ -16,4 +17,5 @@ export const commandCategories = [
|
|||||||
controlCommands,
|
controlCommands,
|
||||||
otherCommands,
|
otherCommands,
|
||||||
simulateCommands,
|
simulateCommands,
|
||||||
|
uiCommands,
|
||||||
];
|
];
|
||||||
|
30
src/js/composer/commands/uiCommand.js
Normal file
30
src/js/composer/commands/uiCommand.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
export const uiCommands = {
|
||||||
|
label: "UI操作",
|
||||||
|
icon: "auto_graph",
|
||||||
|
defaultOpened: false,
|
||||||
|
commands: [
|
||||||
|
{
|
||||||
|
value: "quickcommand.showButtonBox",
|
||||||
|
label: "按钮组弹窗",
|
||||||
|
isAsync: true,
|
||||||
|
config: [
|
||||||
|
{
|
||||||
|
label: "按钮组",
|
||||||
|
type: "arrayEditor",
|
||||||
|
defaultValue: [
|
||||||
|
{
|
||||||
|
value: "按钮1",
|
||||||
|
isString: true,
|
||||||
|
__varInputVal__: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "按钮2",
|
||||||
|
isString: true,
|
||||||
|
__varInputVal__: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
@ -95,6 +95,9 @@ const processObject = (obj, parentPath = "") => {
|
|||||||
* @returns {string} 格式化后的JSON字符串
|
* @returns {string} 格式化后的JSON字符串
|
||||||
*/
|
*/
|
||||||
export const stringifyObject = (jsonObj) => {
|
export const stringifyObject = (jsonObj) => {
|
||||||
|
if (jsonObj instanceof Array) {
|
||||||
|
return `[${jsonObj.map((item) => stringifyObject(item)).join(",")}]`;
|
||||||
|
}
|
||||||
if (jsonObj?.hasOwnProperty("__varInputVal__")) {
|
if (jsonObj?.hasOwnProperty("__varInputVal__")) {
|
||||||
return stringifyWithType(jsonObj);
|
return stringifyWithType(jsonObj);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user