mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-07-04 23:22:46 +08:00
不再在command上添加funcName键,使用value
This commit is contained in:
parent
296c231c44
commit
5ac107d4b6
@ -9,14 +9,14 @@
|
|||||||
<div
|
<div
|
||||||
v-for="option in localCommand.functionSelector?.options"
|
v-for="option in localCommand.functionSelector?.options"
|
||||||
:key="option.value"
|
:key="option.value"
|
||||||
:class="['operation-card', { active: functionName === option.value }]"
|
:class="['operation-card', { active: funcName === option.value }]"
|
||||||
:data-value="option.value"
|
:data-value="option.value"
|
||||||
@click="functionName = option.value"
|
@click="funcName = option.value"
|
||||||
>
|
>
|
||||||
<q-icon
|
<q-icon
|
||||||
:name="option.icon || localCommand.icon || 'functions'"
|
:name="option.icon || localCommand.icon || 'functions'"
|
||||||
size="16px"
|
size="16px"
|
||||||
:color="functionName === option.value ? 'primary' : 'grey'"
|
:color="funcName === option.value ? 'primary' : 'grey'"
|
||||||
/>
|
/>
|
||||||
<div class="text-caption">{{ option.label }}</div>
|
<div class="text-caption">{{ option.label }}</div>
|
||||||
</div>
|
</div>
|
||||||
@ -85,13 +85,9 @@ export default defineComponent({
|
|||||||
defaultArgvs() {
|
defaultArgvs() {
|
||||||
return this.localConfig.map((item) => item.value);
|
return this.localConfig.map((item) => item.value);
|
||||||
},
|
},
|
||||||
functionName: {
|
funcName: {
|
||||||
get() {
|
get() {
|
||||||
return (
|
return this.modelValue.value;
|
||||||
this.modelValue.functionName ||
|
|
||||||
this.modelValue.functionSelector?.options[0]?.value ||
|
|
||||||
this.modelValue.value
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.updateModelValue(value, this.defaultArgvs);
|
this.updateModelValue(value, this.defaultArgvs);
|
||||||
@ -111,18 +107,18 @@ export default defineComponent({
|
|||||||
const newArgvs = [...this.argvs];
|
const newArgvs = [...this.argvs];
|
||||||
newArgvs[index] = value;
|
newArgvs[index] = value;
|
||||||
|
|
||||||
this.updateModelValue(this.functionName, newArgvs);
|
this.updateModelValue(this.funcName, newArgvs);
|
||||||
},
|
},
|
||||||
generateCode(functionName, argvs) {
|
generateCode(funcName, argvs) {
|
||||||
const newArgvs = argvs.map((argv) => stringifyWithType(argv));
|
const newArgvs = argvs.map((argv) => stringifyWithType(argv));
|
||||||
return `${functionName}(${newArgvs.join(",")})`;
|
return `${funcName}(${newArgvs.join(",")})`;
|
||||||
},
|
},
|
||||||
parseCodeToArgvs(code) {
|
parseCodeToArgvs(code) {
|
||||||
const argvs = window.lodashM.cloneDeep(this.defaultArgvs);
|
const argvs = window.lodashM.cloneDeep(this.defaultArgvs);
|
||||||
if (!code) return argvs;
|
if (!code) return argvs;
|
||||||
|
|
||||||
// 匹配函数名和参数
|
// 匹配函数名和参数
|
||||||
const pattern = new RegExp(`^${this.functionName}\\((.*?)\\)$`);
|
const pattern = new RegExp(`^${this.funcName}\\((.*?)\\)$`);
|
||||||
const match = code.match(pattern);
|
const match = code.match(pattern);
|
||||||
if (match) {
|
if (match) {
|
||||||
try {
|
try {
|
||||||
@ -176,7 +172,7 @@ export default defineComponent({
|
|||||||
getSummary(argvs) {
|
getSummary(argvs) {
|
||||||
// 虽然header里对溢出做了处理,但是这里截断主要是为了节省存储空间
|
// 虽然header里对溢出做了处理,但是这里截断主要是为了节省存储空间
|
||||||
const funcNameLabel = this.localCommand.functionSelector?.options.find(
|
const funcNameLabel = this.localCommand.functionSelector?.options.find(
|
||||||
(option) => option.value === this.functionName
|
(option) => option.value === this.funcName
|
||||||
)?.label;
|
)?.label;
|
||||||
const subFeature = funcNameLabel ? `${funcNameLabel} ` : "";
|
const subFeature = funcNameLabel ? `${funcNameLabel} ` : "";
|
||||||
const allArgvs = argvs
|
const allArgvs = argvs
|
||||||
@ -191,27 +187,23 @@ export default defineComponent({
|
|||||||
.filter((item) => item != null && item != "");
|
.filter((item) => item != null && item != "");
|
||||||
return `${subFeature}${allArgvs.join(",")}`;
|
return `${subFeature}${allArgvs.join(",")}`;
|
||||||
},
|
},
|
||||||
updateModelValue(functionName, argvs) {
|
updateModelValue(funcName, argvs) {
|
||||||
this.$emit("update:modelValue", {
|
this.$emit("update:modelValue", {
|
||||||
...this.modelValue,
|
...this.modelValue,
|
||||||
functionName,
|
value: funcName,
|
||||||
summary: this.getSummary(argvs),
|
|
||||||
argvs,
|
argvs,
|
||||||
code: this.generateCode(functionName, argvs),
|
summary: this.getSummary(argvs),
|
||||||
|
code: this.generateCode(funcName, argvs),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (
|
if (!this.modelValue.argvs && !this.modelValue.code) {
|
||||||
!this.modelValue.argvs &&
|
this.updateModelValue(this.funcName, this.defaultArgvs);
|
||||||
!this.modelValue.code &&
|
|
||||||
!this.modelValue.functionName
|
|
||||||
) {
|
|
||||||
this.updateModelValue(this.functionName, this.defaultArgvs);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
functionName: {
|
funcName: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(newVal) {
|
handler(newVal) {
|
||||||
// 当操作卡片改变时,确保它在视图中可见
|
// 当操作卡片改变时,确保它在视图中可见
|
||||||
|
Loading…
x
Reference in New Issue
Block a user