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