mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
匹配及环境下拉框调整
This commit is contained in:
parent
bd4ac225e9
commit
a9a8f569b6
@ -278,13 +278,8 @@
|
||||
})
|
||||
let customWindow = `<div id="customize">
|
||||
<p><input type="text" id="code" style="display: none">
|
||||
<span class="word">模 式</span>
|
||||
<select id="type">
|
||||
<option value="key">通过关键字进入插件</option>
|
||||
<option value="regex">正则匹配主输入框文本</option>
|
||||
<option value="window">窗口匹配</option>
|
||||
<option value="files">文件匹配</option>
|
||||
</select>
|
||||
<span class="word">匹 配</span>
|
||||
<select id="type"></select>
|
||||
<span class="word" id="ruleWord">关键字</span><input class="customize" type="text" id="rule" placeholder="多个关键字用逗号隔开"></p>
|
||||
<p><span class="word">说 明</span><input class="customize" type="text" id="desc" placeholder="命令功能的描述">
|
||||
<img id="icon" src="">
|
||||
@ -357,17 +352,12 @@
|
||||
$("#icon").attr('src', 'logo/quickcommand.png');
|
||||
getSpecialVars()
|
||||
createEditor()
|
||||
$('#program, #type, #output').select2({
|
||||
width: '40%',
|
||||
minimumResultsForSearch: Infinity,
|
||||
dropdownParent: $("#customize")
|
||||
});
|
||||
$('#vars').select2({
|
||||
width: '40%',
|
||||
placeholder: "插入特殊变量",
|
||||
minimumResultsForSearch: Infinity,
|
||||
dropdownParent: $("#customize")
|
||||
});
|
||||
createProgramSelect2('40%')
|
||||
createTypeSelect2('40%')
|
||||
var singleSelectOpt = { width: '40%', minimumResultsForSearch: Infinity, dropdownParent: $("#customize") }
|
||||
$('#output').select2(singleSelectOpt);
|
||||
singleSelectOpt.placeholder = "插入特殊变量"
|
||||
$('#vars').select2(singleSelectOpt);
|
||||
$('#tags').select2({
|
||||
width: '40%',
|
||||
placeholder: "选择或添加标签, 最多3个",
|
||||
@ -383,6 +373,53 @@
|
||||
})
|
||||
}
|
||||
|
||||
let getSelect2Option = (data, width, dropdownAutoWidth = false) => {
|
||||
var options = {
|
||||
data: data,
|
||||
minimumResultsForSearch: Infinity,
|
||||
dropdownParent: $("#customize"),
|
||||
dropdownAutoWidth: dropdownAutoWidth,
|
||||
escapeMarkup: markup => markup,
|
||||
templateSelection: data => data.text,
|
||||
templateResult: data => data.html
|
||||
}
|
||||
if (width) options.width = width
|
||||
return options
|
||||
}
|
||||
|
||||
let createTypeSelect2 = (width = false) => {
|
||||
var data = [
|
||||
{
|
||||
id: "key",
|
||||
text: "关键字",
|
||||
html: "<img src='img/key.svg'><span>关键字</span><div>在主输入框输入对应关键字进入插件,最通用的一种模式,关键字可以设置多个</div>"
|
||||
},
|
||||
{
|
||||
id: "regex",
|
||||
text: "正则/划词",
|
||||
html: "<img src='img/regex.svg'><span>正则/划词</span><div>正则匹配主输入框文本或唤出语音面板时选中的文本,可以获取输入框文本或选中文本作为变量</div>"
|
||||
},
|
||||
{
|
||||
id: "window",
|
||||
text: "窗口/进程",
|
||||
html: "<img src='img/window.svg'><span>窗口/进程</span><div>匹配呼出uTools前或唤出语音面板时的活动窗口,可以获取窗口的信息或文件夹路径作为变量</div>"
|
||||
},
|
||||
{
|
||||
id: "files",
|
||||
text: "复制/选中文件",
|
||||
html: "<img src='img/file.svg'><span>复制/选中文件</span><div>匹配拖入主输入框的文件或唤出语音面板时选中的文件,可以获取复制及选中的文件信息作为变量</div>"
|
||||
}
|
||||
]
|
||||
$('#type').select2(getSelect2Option(data, width));
|
||||
}
|
||||
|
||||
let createProgramSelect2 = (width, dropdownAutoWidth = false) => {
|
||||
var programStyled = p => `<img src="logo/${p}.png"><span>${p}</span>`
|
||||
var data = [{ id: "quickcommand", text: 'quickcommand', html: programStyled('quickcommand') }]
|
||||
data = data.concat(Object.keys(programs).map(x => { return { id: x, text: x, html: programStyled(x) } }))
|
||||
$('#program').select2(getSelect2Option(data, width, dropdownAutoWidth));
|
||||
}
|
||||
|
||||
let createEditor = () => {
|
||||
window.editor = CodeMirror.fromTextArea(document.getElementById("cmd"), {
|
||||
lineNumbers: true,
|
||||
@ -673,7 +710,7 @@
|
||||
<option value="message" args="要发送的系统消息文本">发送系统消息</option>
|
||||
<option value="alert" args="要弹窗显示的消息文本">弹窗显示消息</option>
|
||||
<option value="send" args="要发送到窗口的文本内容">发送文本到活动窗口</option>
|
||||
<option value="utools.redirect" args="要跳转至的插件名称">跳转到指定插件</option>
|
||||
<option value="utools.redirect" args="要跳转至的插件名称">转至指定插件(自定义关键字)</option>
|
||||
<option value="quickcommand.sleep" args="延迟的毫秒数,不要勾选“加引号”">添加延时</option>
|
||||
</select>
|
||||
<input placeholder="文件、文件夹或软件的绝对路径" id="actionArgs" class="swal2-input" style="width: 80%; height: 3rem;">
|
||||
@ -705,6 +742,7 @@
|
||||
json = getDB('customFts')[code],
|
||||
options = {
|
||||
title: '选择保存位置',
|
||||
defaultPath: `${json.features.explain}.json`,
|
||||
filters: [
|
||||
{ name: 'json', extensions: ['json'] },
|
||||
]
|
||||
@ -999,14 +1037,9 @@
|
||||
}
|
||||
|
||||
showCodeEditor = file => {
|
||||
let options = `<option>${Object.keys(programs).join('</option><option>')}</option>`
|
||||
var customWindow = `
|
||||
|
||||
<div id="customize">
|
||||
<select id="program">
|
||||
<option value="quickcommand">quickcommand</option>
|
||||
${options}
|
||||
</select>
|
||||
<select id="program"></select>
|
||||
<span class="customscript">
|
||||
<input type="text" id="custombin" placeholder="解释器路径">
|
||||
<input type="text" id="customarg" placeholder="解释器参数">
|
||||
@ -1030,16 +1063,16 @@
|
||||
$("#customize").css({ top: '0px', padding: '0px' });
|
||||
$("span.customscript > input").css({"height": "30px"})
|
||||
var db = getDB('codeHistory')
|
||||
createProgramSelect2(140, true)
|
||||
if (file) {
|
||||
var fileinfo = getFileInfo({ type: 'file', argvs: file, readfile: true })
|
||||
console.log(fileinfo);
|
||||
window.editor.setValue(fileinfo.data)
|
||||
var program = Object.keys(programs).filter(x => `.${programs[x].ext}` == fileinfo.ext)
|
||||
if (program) $('#program').val(program[0])
|
||||
if (program) $('#program').val(program[0]).trigger('change')
|
||||
// runCurrentCommand()
|
||||
} else if(db.history){
|
||||
window.editor.setValue(db.history.cmd)
|
||||
$('#program').val(db.history.program)
|
||||
$('#program').val(db.history.program).trigger('change')
|
||||
$('#scptarg').val(db.history.scptarg)
|
||||
var custom = db.history.customoptions
|
||||
if (db.history.program = 'custom' && custom) {
|
||||
@ -1050,12 +1083,6 @@
|
||||
}
|
||||
}
|
||||
programCheck()
|
||||
$('#program').select2({
|
||||
width: 140,
|
||||
minimumResultsForSearch: Infinity,
|
||||
dropdownParent: $("#customize"),
|
||||
dropdownAutoWidth: true
|
||||
});
|
||||
$("#options").show()
|
||||
}
|
||||
|
||||
|
1
src/img/file.svg
Normal file
1
src/img/file.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 48 48"><path fill="#90CAF9" d="M40 45L8 45 8 3 30 3 40 13z"/><path fill="#E1F5FE" d="M38.5 14L29 14 29 4.5z"/><path fill="#1976D2" d="M16 21H33V23H16zM16 25H29V27H16zM16 29H33V31H16zM16 33H29V35H16z"/></svg>
|
After Width: | Height: | Size: 274 B |
1
src/img/key.svg
Normal file
1
src/img/key.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#9C27B0" d="M37,12H27v30h-7V12H10V6h27V12z"/></svg>
|
After Width: | Height: | Size: 146 B |
1
src/img/regex.svg
Normal file
1
src/img/regex.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#9C27B0" d="M21 5H27V43H21z"/><path fill="#9C27B0" d="M42 30.596L39.158 35.842 6 17.404 8.842 12.158z"/><path fill="#9C27B0" d="M8.992 36.031L6 30.822 39.008 11.969 42 17.178z"/></svg>
|
After Width: | Height: | Size: 279 B |
1
src/img/window.svg
Normal file
1
src/img/window.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="#455a64" d="M42,19H6V9c0-1.657,1.343-3,3-3h30c1.657,0,3,1.343,3,3V19z"/><path fill="#bbdefb" d="M6,16h36v23c0,1.657-1.343,3-3,3H9c-1.657,0-3-1.343-3-3V16z"/><path fill="#8bc34a" d="M11 9A2 2 0 1 0 11 13A2 2 0 1 0 11 9Z"/><path fill="#ffeb3b" d="M17 9A2 2 0 1 0 17 13A2 2 0 1 0 17 9Z"/><path fill="#fafafa" d="M39,12c0,0.553-0.447,1-1,1H23c-0.553,0-1-0.447-1-1v-2c0-0.553,0.447-1,1-1h15c0.553,0,1,0.447,1,1 V12z"/></svg>
|
After Width: | Height: | Size: 491 B |
Loading…
x
Reference in New Issue
Block a user