mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
更改命令图标储存方式
This commit is contained in:
parent
6ea282b6f0
commit
f42e59ea82
@ -159,12 +159,7 @@ showOptions = () => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
featureList += `<tr><td><img class="logo" src="${features.icon}"></td>
|
||||||
var iconpath = cacheIco(customFts[fts].base64Ico, features.icon);
|
|
||||||
} catch (e) {
|
|
||||||
window.messageBox({ type: 'error', icon: window.logo, message: e.toString(), buttons: ['啊嘞?!'] })
|
|
||||||
}
|
|
||||||
featureList += `<tr><td><img class="logo" src="${iconpath}"></td>
|
|
||||||
<td>${cmds}</td><td>${features.explain}</td><td>
|
<td>${cmds}</td><td>${features.explain}</td><td>
|
||||||
<label class="switch-btn">
|
<label class="switch-btn">
|
||||||
<input class="checked-switch" id="${features.code}" type="checkbox" ${isChecked}>
|
<input class="checked-switch" id="${features.code}" type="checkbox" ${isChecked}>
|
||||||
@ -370,8 +365,6 @@ $("#options").on('click', '.editBtn', function () {
|
|||||||
$('#codec').val(data.codec);
|
$('#codec').val(data.codec);
|
||||||
$("#icon").attr('src', data.features.icon);
|
$("#icon").attr('src', data.features.icon);
|
||||||
let mode = data.program;
|
let mode = data.program;
|
||||||
let iconame = basename(data.features.icon);
|
|
||||||
if (iconame != `${mode}.png`) $('#iconame').val(iconame);
|
|
||||||
if (mode == 'custom') {
|
if (mode == 'custom') {
|
||||||
$('#custombin').show().val(data.customOptions.bin);
|
$('#custombin').show().val(data.customOptions.bin);
|
||||||
$('#customarg').show().val(data.customOptions.argv);
|
$('#customarg').show().val(data.customOptions.argv);
|
||||||
@ -416,7 +409,7 @@ $("#options").on('click', '#icon, #iconame', function () {
|
|||||||
buttonLabel: '选择',
|
buttonLabel: '选择',
|
||||||
filters: [{
|
filters: [{
|
||||||
name: 'Images',
|
name: 'Images',
|
||||||
extensions: ['jpg', 'jpeg', 'png']
|
extensions: ['png']
|
||||||
}, ]
|
}, ]
|
||||||
}
|
}
|
||||||
let iconpath = window.openFolder(options)[0];
|
let iconpath = window.openFolder(options)[0];
|
||||||
@ -476,18 +469,13 @@ $("#options").on('click', '.saveBtn', function () {
|
|||||||
base64ico,
|
base64ico,
|
||||||
hasSubInput;
|
hasSubInput;
|
||||||
if (!desc) desc = ' ';
|
if (!desc) desc = ' ';
|
||||||
// 自定义了图标的情况下
|
// 选择了图标的情况下
|
||||||
if (iconame) {
|
if (iconame) {
|
||||||
icon = `../QuickCommandIcons/${iconame}`;
|
|
||||||
if (iconpath == icon) {
|
|
||||||
base64ico = window.getBase64Ico(resolve(dirname, iconpath));
|
|
||||||
} else {
|
|
||||||
base64ico = window.getBase64Ico(iconpath);
|
base64ico = window.getBase64Ico(iconpath);
|
||||||
}
|
icon = "data:image/png;base64," + base64ico;
|
||||||
// 未自定义使用默认
|
// 未自定义使用默认
|
||||||
} else {
|
} else {
|
||||||
icon = iconpath;
|
icon = iconpath;
|
||||||
base64ico = '';
|
|
||||||
}
|
}
|
||||||
var noKeyword;
|
var noKeyword;
|
||||||
var rule = $('#rule').val();
|
var rule = $('#rule').val();
|
||||||
@ -533,7 +521,6 @@ $("#options").on('click', '.saveBtn', function () {
|
|||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
output: output,
|
output: output,
|
||||||
codec: codec,
|
codec: codec,
|
||||||
base64Ico: base64ico,
|
|
||||||
noKeyword: noKeyword,
|
noKeyword: noKeyword,
|
||||||
hasSubInput: hasSubInput
|
hasSubInput: hasSubInput
|
||||||
}
|
}
|
||||||
@ -553,10 +540,16 @@ $("#options").on('click', '.saveBtn', function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
hasCustomIcon = () => {
|
||||||
|
var src = $("#icon").attr('src');
|
||||||
|
var iconame = $("#iconame").val();
|
||||||
|
return /data:image\/png;base64,/.test(src) || iconame
|
||||||
|
}
|
||||||
|
|
||||||
// 语言选项改变时
|
// 语言选项改变时
|
||||||
$("#options").on('change', '#program', function () {
|
$("#options").on('change', '#program', function () {
|
||||||
let mode = $(this).val();
|
let mode = $(this).val();
|
||||||
if (!$("#iconame").val()) $("#icon").attr('src', `logo/${mode}.png`);
|
if (!hasCustomIcon()) $("#icon").attr('src', `logo/${mode}.png`);
|
||||||
if (mode == 'custom') {
|
if (mode == 'custom') {
|
||||||
$('#custombin').show();
|
$('#custombin').show();
|
||||||
$('#customarg').show();
|
$('#customarg').show();
|
||||||
|
@ -44,14 +44,6 @@ getBase64Ico = path => {
|
|||||||
return fs.readFileSync(path, 'base64');
|
return fs.readFileSync(path, 'base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheIco = (b64, icon) => {
|
|
||||||
var file = path.resolve(__dirname, icon),
|
|
||||||
dir = path.dirname(file);
|
|
||||||
!exists(dir) && fs.mkdirSync(dir);
|
|
||||||
b64 && !exists(file) && fs.writeFileSync(file, b64, 'base64');
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
openFolder = options => {
|
openFolder = options => {
|
||||||
return dialog.showOpenDialogSync(BrowserWindow.getFocusedWindow(), options);
|
return dialog.showOpenDialogSync(BrowserWindow.getFocusedWindow(), options);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user