修复新增命令后界面跳至顶端的bug

This commit is contained in:
fofolee 2020-07-13 23:18:43 +08:00
parent b09abf72e7
commit 468600971e

View File

@ -225,7 +225,7 @@
var platformIcons var platformIcons
if (features.platform) platformIcons = features.platform.map(x => `<img src="img/${x}.svg">`) if (features.platform) platformIcons = features.platform.map(x => `<img src="img/${x}.svg">`)
else platformIcons = ['<img src="img/win32.svg">', '<img src="img/darwin.svg">', '<img src="img/linux.svg">'] else platformIcons = ['<img src="img/win32.svg">', '<img src="img/darwin.svg">', '<img src="img/linux.svg">']
featureList += `<tr> featureList += `<tr id="${features.code}">
<td><img class="logo" src="${features.icon}"></td> <td><img class="logo" src="${features.icon}"></td>
<td> <td>
<div class="topchild">${features.explain}</div> <div class="topchild">${features.explain}</div>
@ -238,15 +238,15 @@
<td>${cmds}</td> <td>${cmds}</td>
<td> <td>
<label class="switch-btn"> <label class="switch-btn">
<input class="checked-switch" id="${features.code}" type="checkbox" ${isChecked}> <input class="checked-switch" type="checkbox" ${isChecked}>
<span class="text-switch"></span> <span class="text-switch"></span>
<span class="toggle-btn"></span> <span class="toggle-btn"></span>
</label> </label>
</td> </td>
<td> <td>
<span class="Btn editBtn" code="${features.code}"><img src="img/${tag == "默认" ? "view" : "edit"}.svg"></span> <span class="Btn editBtn"><img src="img/${tag == "默认" ? "view" : "edit"}.svg"></span>
<span class="Btn exportBtn" code="${features.code}"><img src="img/export.svg"></span> <span class="Btn exportBtn"><img src="img/export.svg"></span>
${tag == "默认" ? "" : `<span class="Btn delBtn" code="${features.code}"><img src="img/del.svg"></span>`} ${tag == "默认" ? "" : `<span class="Btn delBtn"><img src="img/del.svg"></span>`}
</td>` </td>`
}) })
featureList += `</tr></table></div>` featureList += `</tr></table></div>`
@ -605,7 +605,7 @@
// 开关 // 开关
$("#options").on('change', 'input[type=checkbox]', function () { $("#options").on('change', 'input[type=checkbox]', function () {
var customFts = getDB('customFts'), var customFts = getDB('customFts'),
code = $(this).attr('id'); code = $(this).parents('tr').attr('id')
if (!utools.removeFeature(code)) { if (!utools.removeFeature(code)) {
utools.setFeature(customFts[code].features); utools.setFeature(customFts[code].features);
} }
@ -635,7 +635,7 @@
// 编辑 // 编辑
$("#options").on('click', '.editBtn', function () { $("#options").on('click', '.editBtn', function () {
var readonly = false, var readonly = false,
code = $(this).attr('code'), code = $(this).parents('tr').attr('id'),
data = utools.db.get("customFts").data[code], data = utools.db.get("customFts").data[code],
cmds = data.features.cmds[0], cmds = data.features.cmds[0],
platform = data.features.platform; platform = data.features.platform;
@ -736,7 +736,7 @@
// 导出 // 导出
$("#options").on('click', '.exportBtn', function () { $("#options").on('click', '.exportBtn', function () {
var code = $(this).attr('code'), var code = $(this).parents('tr').attr('id'),
json = getDB('customFts')[code], json = getDB('customFts')[code],
options = { options = {
title: '选择保存位置', title: '选择保存位置',
@ -760,7 +760,7 @@
cancelButtonText: '手抖...', cancelButtonText: '手抖...',
}).then((result) => { }).then((result) => {
if (result.value) { if (result.value) {
var code = $(this).attr('code'), var code = $(this).parents('tr').attr('id'),
db = utools.db.get("customFts"), db = utools.db.get("customFts"),
data = db.data; data = db.data;
delete data[code]; delete data[code];
@ -774,7 +774,7 @@
}) })
// 选择图标 // 选择图标
$("#options").on('click', '#icon, #iconame', function () { $("#options").on('click', '#icon', function () {
var options = { var options = {
buttonLabel: '选择', buttonLabel: '选择',
filters: [{ filters: [{
@ -907,11 +907,9 @@
redirectTag = "未分类" redirectTag = "未分类"
} }
showOptions(redirectTag); showOptions(redirectTag);
location.href = '#' + code
$("#customize").empty() $("#customize").empty()
$(`#${code}`).click(); $(`#${code} .checked-switch`).is(':checked') || $(`#${code} .checked-switch`).click()
if (!$(`#${code}`).is(':checked')) {
$(`#${code}`).click();
}
}); });
} }
} }