添加自定义语言

This commit is contained in:
fofolee 2019-09-21 10:58:33 +08:00
parent 13e8c1ed71
commit 7c63df1641
7 changed files with 45 additions and 10 deletions

View File

@ -8,10 +8,11 @@
#### v0.0.2
- 可以自定义语言
- 修复uTools更新后进入插件空白的BUG
- 添加Linux支持
- 修复导入BUG
-
- 修复说明为空时无法启用命令的BUG
- 添加全部导出和全部删除的功能
## 功能

View File

@ -1,5 +1,5 @@
utools.onPluginEnter(({ code, type, payload }) => {
checkUpdate();
// checkUpdate();
// 配置页面
if (code == 'options') {
utools.setExpendHeight(600);
@ -12,8 +12,12 @@ utools.onPluginEnter(({ code, type, payload }) => {
$("#options").hide();
$("#out").show();
var db = utools.db.get('customFts').data[code],
cmd = db.cmd,
cmd = db.cmd;
if (db.program == "custom") {
option = db.customOptions;
} else {
option = programs[db.program];
}
// 通过主输入框直接进入
if (type == 'over') cmd = cmd.replace(/\{\{input\}\}/mg, payload);
// 无输出的批处理

View File

@ -249,6 +249,11 @@
color: #bd3523;
}
#options #customize input#custombin, #options #customize input#customarg, #options #customize input#customext {
margin-left: 5px;
width: 200px;
}
#options #customize {
position: fixed;
height: 100%;

View File

@ -126,7 +126,12 @@ programs = {
bin: 'perl',
agrv: '',
ext: 'pl'
}
},
custom: {
bin: '',
agrv: '',
ext: ''
}
}
showOptions = () => {
@ -216,12 +221,11 @@ showCustomize = () => {
</p>
<p>
<span class="word">&#12288;</span>
<!--
<select id="codec">
<option value="gbk">GBK 编码</option>
<option value="utf8">UTF8 编码</option>
</select>
-->
<span>
<input type="text" id="custombin" style="display: none;" placeholder="解释器绝对路径">
<input type="text" id="customarg" style="display: none;" placeholder="参数">
<input type="text" id="customext" style="display: none;" placeholder="脚本后缀,不含.">
</span>
</p>
<p><textarea id="cmd" placeholder="可以直接拖放脚本文件至此处"></textarea></p>
<p>
@ -300,6 +304,11 @@ $("#options").on('click', '.editBtn', function () {
let mode = data.program;
let iconame = basename(data.features.icon);
if (iconame != `${mode}.png`) $('#iconame').val(iconame);
if (mode == 'custom') {
$('#custombin').show().val(data.customOptions.bin);
$('#customarg').show().val(data.customOptions.args);
$('#customext').show().val(data.customOptions.ext);
}
mode == 'applescript' && (mode = 'shell');
mode == 'cmd' && (mode = 'powershell');
window.editor.setOption("mode", mode);
@ -405,6 +414,13 @@ $("#options").on('click', '.saveBtn', function () {
base64Ico: base64ico,
noKeyword: noKeyword
}
if (program == 'custom') {
pushData.customOptions = {
"bin": $('#custombin').val(),
"args": $('#customarg').val(),
"ext": $('#customext').val()
}
}
putCustomFts(code, pushData);
showOptions();
}
@ -414,6 +430,15 @@ $("#options").on('click', '.saveBtn', function () {
$("#options").on('change', '#program', function () {
let mode = $(this).val();
if (!$("#iconame").val()) $("#icon").attr('src', `logo/${mode}.png`);
if (mode == 'custom') {
$('#custombin').show();
$('#customarg').show();
$('#customext').show();
} else {
$('#custombin').hide();
$('#customarg').hide();
$('#customext').hide();
}
mode == 'applescript' && (mode = 'shell');
mode == 'cmd' && (mode = 'powershell');
window.editor.setOption("mode", mode);

BIN
logo/custom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Binary file not shown.