mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 04:42:45 +08:00
子输入框
This commit is contained in:
parent
73c5dbacee
commit
8cc7f4f985
@ -44,6 +44,9 @@ export default defineComponent({
|
|||||||
utools.onPluginOut(() => {
|
utools.onPluginOut(() => {
|
||||||
// 切到空路由
|
// 切到空路由
|
||||||
this.$router.push("loading");
|
this.$router.push("loading");
|
||||||
|
// 清空临时数据
|
||||||
|
document.removeEventListener("keydown", this.$profile.tmp.handleEnter);
|
||||||
|
this.$profile.tmp = {};
|
||||||
// 保存偏好
|
// 保存偏好
|
||||||
this.$utools.putDB(
|
this.$utools.putDB(
|
||||||
_.cloneDeep(this.$profile),
|
_.cloneDeep(this.$profile),
|
||||||
|
@ -10,7 +10,8 @@ let defaultProfile = {
|
|||||||
primaryColor: "#009688",
|
primaryColor: "#009688",
|
||||||
defaultPrimaryColor: "#009688",
|
defaultPrimaryColor: "#009688",
|
||||||
backgroundImg: null,
|
backgroundImg: null,
|
||||||
codeHistory: {}
|
codeHistory: {},
|
||||||
|
tmp: {}
|
||||||
}
|
}
|
||||||
let userProfile = UTOOLS.getDB(
|
let userProfile = UTOOLS.getDB(
|
||||||
UTOOLS.DBPRE.CFG + "preferences"
|
UTOOLS.DBPRE.CFG + "preferences"
|
||||||
|
@ -22,7 +22,13 @@
|
|||||||
></pre>
|
></pre>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-actions align="right">
|
<q-card-actions align="right">
|
||||||
<q-btn flat label="关闭" color="primary" v-close-popup />
|
<q-btn
|
||||||
|
flat
|
||||||
|
label="关闭"
|
||||||
|
color="primary"
|
||||||
|
v-close-popup
|
||||||
|
@click="stopRun"
|
||||||
|
/>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
@ -52,6 +58,7 @@ export default {
|
|||||||
isResultShow: false,
|
isResultShow: false,
|
||||||
runResult: "",
|
runResult: "",
|
||||||
runResultStatus: true,
|
runResultStatus: true,
|
||||||
|
subInputValue: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -67,7 +74,12 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 运行命令
|
// 运行命令
|
||||||
async runCurrentCommand(currentCommand) {
|
runCurrentCommand(currentCommand) {
|
||||||
|
if (currentCommand.cmd.includes("{{subinput"))
|
||||||
|
return this.setSubInput(currentCommand);
|
||||||
|
this.fire(currentCommand);
|
||||||
|
},
|
||||||
|
async fire(currentCommand) {
|
||||||
currentCommand.cmd = this.assignSpecialVars(currentCommand.cmd);
|
currentCommand.cmd = this.assignSpecialVars(currentCommand.cmd);
|
||||||
// currentCommand.cmd = await this.replaceTempInputVars(currentCommand.cmd);
|
// currentCommand.cmd = await this.replaceTempInputVars(currentCommand.cmd);
|
||||||
let { hideWindow, outPlugin, action } =
|
let { hideWindow, outPlugin, action } =
|
||||||
@ -113,6 +125,31 @@ export default {
|
|||||||
});
|
});
|
||||||
return cmd;
|
return cmd;
|
||||||
},
|
},
|
||||||
|
// 子输入框
|
||||||
|
setSubInput(currentCommand) {
|
||||||
|
this.fromUtools && utools.setExpendHeight(0);
|
||||||
|
let matched = currentCommand.cmd.match(specialVars.subinput.match);
|
||||||
|
let placeholder = matched[1] || "请输入";
|
||||||
|
utools.setSubInput(({ text }) => {
|
||||||
|
this.subInputValue = text;
|
||||||
|
}, placeholder);
|
||||||
|
let querySubInput = () => {
|
||||||
|
let command = _.cloneDeep(currentCommand);
|
||||||
|
command.cmd = currentCommand.cmd.replace(
|
||||||
|
specialVars.subinput.match,
|
||||||
|
this.subInputValue
|
||||||
|
);
|
||||||
|
this.fire(command);
|
||||||
|
};
|
||||||
|
// 自动粘贴的情况下自动执行
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.subInputValue) querySubInput();
|
||||||
|
}, 100);
|
||||||
|
this.$profile.tmp.handleEnter = (event) => {
|
||||||
|
if (event.keyCode == 13) querySubInput();
|
||||||
|
};
|
||||||
|
document.addEventListener("keydown", this.$profile.tmp.handleEnter);
|
||||||
|
},
|
||||||
// 替换特殊变量
|
// 替换特殊变量
|
||||||
async replaceTempInputVars(cmd) {
|
async replaceTempInputVars(cmd) {
|
||||||
let tempInputVals = [];
|
let tempInputVals = [];
|
||||||
@ -170,6 +207,13 @@ export default {
|
|||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
stopRun() {
|
||||||
|
if (this.$profile.tmp.handleEnter) {
|
||||||
|
this.subInputValue = "";
|
||||||
|
document.removeEventListener("keydown", this.$profile.tmp.handleEnter);
|
||||||
|
utools.removeSubInput();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user