mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-07-10 03:12:51 +08:00
细节调整
This commit is contained in:
parent
ee7d965826
commit
661654a4cf
@ -12,14 +12,15 @@ import inputBox from "../components/InputBox"
|
|||||||
|
|
||||||
let showInputBox = (options = [], title = "") => {
|
let showInputBox = (options = [], title = "") => {
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
let props = {}
|
let props = {
|
||||||
|
labels: [],
|
||||||
|
values: [],
|
||||||
|
hints: [],
|
||||||
|
title: title
|
||||||
|
}
|
||||||
if (!(options instanceof Object)) return reject(new TypeError("必须为数组或对象"))
|
if (!(options instanceof Object)) return reject(new TypeError("必须为数组或对象"))
|
||||||
if (options instanceof Array) props.labels = options
|
if (options instanceof Array) props.labels = options
|
||||||
else props = options
|
else Object.assign(props, options)
|
||||||
if (!props.labels) return reject(new SyntaxError("缺少必须要的参数"))
|
|
||||||
if (!props.values) props.values = props.labels.map(() => "")
|
|
||||||
if (!props.hints) props.hints = props.labels.map(() => "")
|
|
||||||
props.title = title
|
|
||||||
Dialog.create({
|
Dialog.create({
|
||||||
component: inputBox,
|
component: inputBox,
|
||||||
componentProps: props
|
componentProps: props
|
||||||
|
@ -209,9 +209,8 @@ export default {
|
|||||||
this.routeData.action === "edit"
|
this.routeData.action === "edit"
|
||||||
? this.routeData.data
|
? this.routeData.data
|
||||||
: this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory");
|
: this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory");
|
||||||
quickCommandInfo = this.fillDefaultKeys(quickCommandInfo);
|
Object.assign(this.quickcommandInfo, quickCommandInfo)
|
||||||
this.$refs.editor.setEditorValue(quickCommandInfo.cmd);
|
this.$refs.editor.setEditorValue(quickCommandInfo.cmd);
|
||||||
this.quickcommandInfo = quickCommandInfo;
|
|
||||||
// 只有新建或运行时才保存记录
|
// 只有新建或运行时才保存记录
|
||||||
if (this.routeData.action === "edit") return;
|
if (this.routeData.action === "edit") return;
|
||||||
utools.onPluginOut(() => {
|
utools.onPluginOut(() => {
|
||||||
@ -223,15 +222,6 @@ export default {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 补充没有的键值
|
|
||||||
fillDefaultKeys(command) {
|
|
||||||
let commandKeys = Object.keys(command);
|
|
||||||
Object.keys(this.quickcommandInfo).forEach((key) => {
|
|
||||||
if (!commandKeys.includes(key))
|
|
||||||
command[key] = this.quickcommandInfo[key];
|
|
||||||
});
|
|
||||||
return command;
|
|
||||||
},
|
|
||||||
// 绑定快捷键
|
// 绑定快捷键
|
||||||
bindKeys() {
|
bindKeys() {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
@ -332,7 +332,6 @@ export default {
|
|||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return commands.filter(
|
return commands.filter(
|
||||||
// 可选链操作符
|
|
||||||
(cmd) => cmd.tags?.includes(this.currentTag)
|
(cmd) => cmd.tags?.includes(this.currentTag)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user