mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 23:16:18 +08:00
特殊变量处理
This commit is contained in:
parent
c6cce49b82
commit
eddadcada4
@ -144,6 +144,7 @@
|
|||||||
transition-show="jump-down"
|
transition-show="jump-down"
|
||||||
transition-hide="jump-up"
|
transition-hide="jump-up"
|
||||||
borderless
|
borderless
|
||||||
|
@update:model-value="(val) => insertSpecialVar(val.label)"
|
||||||
square
|
square
|
||||||
:options="specialVarsOptions"
|
:options="specialVarsOptions"
|
||||||
v-model="specialVar"
|
v-model="specialVar"
|
||||||
@ -157,7 +158,7 @@
|
|||||||
<template v-slot:option="scope">
|
<template v-slot:option="scope">
|
||||||
<q-item v-bind="scope.itemProps">
|
<q-item v-bind="scope.itemProps">
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label v-html="scope.opt.name" />
|
<q-item-label v-html="scope.opt.label" />
|
||||||
<q-item-label caption>{{ scope.opt.desc }}</q-item-label>
|
<q-item-label caption>{{ scope.opt.desc }}</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
@ -247,7 +248,6 @@ export default {
|
|||||||
outputTypes: outputTypes,
|
outputTypes: outputTypes,
|
||||||
outputTypesOptions: Object.keys(outputTypes),
|
outputTypesOptions: Object.keys(outputTypes),
|
||||||
specialVar: "{{}}",
|
specialVar: "{{}}",
|
||||||
specialVarsOptions: Object.values(specialVars),
|
|
||||||
allQuickCommandTags: this.$parent.parent.allQuickCommandTags,
|
allQuickCommandTags: this.$parent.parent.allQuickCommandTags,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -257,7 +257,15 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
window.CommandMenu = this;
|
window.CommandMenu = this;
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {
|
||||||
|
specialVarsOptions() {
|
||||||
|
let x= Object.values(specialVars).filter(
|
||||||
|
(x) => !x.label.match(this.cmdType.disabledSpecialVars)
|
||||||
|
);
|
||||||
|
console.log(x);
|
||||||
|
return x
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
let currentQuickCommandCmds = this.getCommandType();
|
let currentQuickCommandCmds = this.getCommandType();
|
||||||
@ -307,12 +315,16 @@ export default {
|
|||||||
)
|
)
|
||||||
this.cmdMatch = `/${this.cmdMatch}/`;
|
this.cmdMatch = `/${this.cmdMatch}/`;
|
||||||
},
|
},
|
||||||
|
insertSpecialVar(text) {
|
||||||
|
this.$parent.$refs.editor.repacleEditorSelection(text);
|
||||||
|
},
|
||||||
// 保存各类数据
|
// 保存各类数据
|
||||||
SaveMenuData() {
|
SaveMenuData() {
|
||||||
let updateData = {
|
let updateData = {
|
||||||
features: this.currentCommand.features,
|
features: this.currentCommand.features,
|
||||||
output: this.currentCommand.output,
|
output: this.currentCommand.output,
|
||||||
tags: this.currentCommand.tags,
|
tags: this.currentCommand.tags,
|
||||||
|
cmd: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 说明为空填充一个空格
|
// 说明为空填充一个空格
|
||||||
@ -333,6 +345,16 @@ export default {
|
|||||||
this.cmdMatch,
|
this.cmdMatch,
|
||||||
updateData.features.explain
|
updateData.features.explain
|
||||||
);
|
);
|
||||||
|
|
||||||
|
updateData.cmd = this.$parent.$refs.editor.getEditorValue();
|
||||||
|
|
||||||
|
let blackLisk = updateData.cmd.match(this.cmdType.disabledSpecialVars);
|
||||||
|
if (blackLisk) {
|
||||||
|
return quickcommand.showMessageBox(
|
||||||
|
`当前模式无法使用${[...new Set(blackLisk)].join("、")}`,
|
||||||
|
"error"
|
||||||
|
);
|
||||||
|
}
|
||||||
return updateData;
|
return updateData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -151,6 +151,23 @@ export default {
|
|||||||
addEditorCommand(key, callback) {
|
addEditorCommand(key, callback) {
|
||||||
this.rawEditor.addCommand(key, callback);
|
this.rawEditor.addCommand(key, callback);
|
||||||
},
|
},
|
||||||
|
repacleEditorSelection(text) {
|
||||||
|
var selection = this.rawEditor.getSelection();
|
||||||
|
var range = new monaco.Range(
|
||||||
|
selection.startLineNumber,
|
||||||
|
selection.startColumn,
|
||||||
|
selection.endLineNumber,
|
||||||
|
selection.endColumn
|
||||||
|
);
|
||||||
|
var id = { major: 1, minor: 1 };
|
||||||
|
var op = {
|
||||||
|
identifier: id,
|
||||||
|
range: range,
|
||||||
|
text: text,
|
||||||
|
forceMoveMarkers: true,
|
||||||
|
};
|
||||||
|
this.rawEditor.executeEdits("my-source", [op]);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -6,8 +6,9 @@ const commandTypes = {
|
|||||||
matchLabel: "关键词",
|
matchLabel: "关键词",
|
||||||
desc: "在主输入框输入对应关键字进入插件,最通用的一种模式,关键字可以设置多个",
|
desc: "在主输入框输入对应关键字进入插件,最通用的一种模式,关键字可以设置多个",
|
||||||
valueType: "array",
|
valueType: "array",
|
||||||
|
disabledSpecialVars: /{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo}}|{{MatchedFiles}}/g,
|
||||||
matchToCmds: (rules, desc) => rules,
|
matchToCmds: (rules, desc) => rules,
|
||||||
verify: (rules) => rules.length > 0 || "关键词不能为空"
|
verify: (rules) => rules.length > 0 || "关键词不能为空",
|
||||||
},
|
},
|
||||||
regex: {
|
regex: {
|
||||||
name: "regex",
|
name: "regex",
|
||||||
@ -16,6 +17,7 @@ const commandTypes = {
|
|||||||
icon: "rule",
|
icon: "rule",
|
||||||
desc: "匹配主输入框或超级面板选中的文本,可以获取输入框文本或选中文本作为变量",
|
desc: "匹配主输入框或超级面板选中的文本,可以获取输入框文本或选中文本作为变量",
|
||||||
valueType: "regex",
|
valueType: "regex",
|
||||||
|
disabledSpecialVars: /{{SelectFile}}|{{WindowInfo}}|{{pwd}}|{{MatchedFiles}}/g,
|
||||||
matchToCmds: (rules, desc) => [{
|
matchToCmds: (rules, desc) => [{
|
||||||
label: desc,
|
label: desc,
|
||||||
type: "regex",
|
type: "regex",
|
||||||
@ -31,6 +33,7 @@ const commandTypes = {
|
|||||||
icon: "emergency",
|
icon: "emergency",
|
||||||
desc: "匹配主输入框的所有文本,但只有在该文本未设置对应的插件或功能时才生效",
|
desc: "匹配主输入框的所有文本,但只有在该文本未设置对应的插件或功能时才生效",
|
||||||
valueType: null,
|
valueType: null,
|
||||||
|
disabledSpecialVars: /{{SelectFile}}|{{WindowInfo}}|{{pwd}}|{{MatchedFiles}}/g,
|
||||||
matchToCmds: (rules, desc) => [{
|
matchToCmds: (rules, desc) => [{
|
||||||
label: desc,
|
label: desc,
|
||||||
type: "over",
|
type: "over",
|
||||||
@ -45,6 +48,7 @@ const commandTypes = {
|
|||||||
icon: "widgets",
|
icon: "widgets",
|
||||||
desc: "匹配呼出uTools前或唤出超级面板时的活动窗口,可以获取窗口的信息或文件夹路径作为变量",
|
desc: "匹配呼出uTools前或唤出超级面板时的活动窗口,可以获取窗口的信息或文件夹路径作为变量",
|
||||||
valueType: "array",
|
valueType: "array",
|
||||||
|
disabledSpecialVars: /{{input}}|{{MatchedFiles}}/g,
|
||||||
matchToCmds: (rules, desc) => [{
|
matchToCmds: (rules, desc) => [{
|
||||||
type: "window",
|
type: "window",
|
||||||
label: desc,
|
label: desc,
|
||||||
@ -61,6 +65,7 @@ const commandTypes = {
|
|||||||
icon: "panorama",
|
icon: "panorama",
|
||||||
desc: "匹配主输入框或超级面板选中的图片,并返回图片的 base64",
|
desc: "匹配主输入框或超级面板选中的图片,并返回图片的 base64",
|
||||||
valueType: null,
|
valueType: null,
|
||||||
|
disabledSpecialVars: /{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo}}|{{MatchedFiles}}/g,
|
||||||
matchToCmds: (rules, desc) => [{
|
matchToCmds: (rules, desc) => [{
|
||||||
label: desc,
|
label: desc,
|
||||||
type: "img",
|
type: "img",
|
||||||
@ -74,6 +79,7 @@ const commandTypes = {
|
|||||||
icon: "description",
|
icon: "description",
|
||||||
desc: "匹配主输入框或超级面板选中的文件,可以获取复制及选中的文件信息作为变量",
|
desc: "匹配主输入框或超级面板选中的文件,可以获取复制及选中的文件信息作为变量",
|
||||||
valueType: "regex",
|
valueType: "regex",
|
||||||
|
disabledSpecialVars: /{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo}}/g,
|
||||||
matchToCmds: (rules, desc) => [{
|
matchToCmds: (rules, desc) => [{
|
||||||
type: "files",
|
type: "files",
|
||||||
label: desc,
|
label: desc,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user