一键换装内嵌 gmweb:取消独立 exe 启动并支持页面热键

This commit is contained in:
90CN committed 2026-11-05 21:08:20 +08:00
1 parent ab778e9e4c
commit 1e936bfb84
3 files changed
+153 -19

No files matched your search

+133
View File
@@ -200,10 +200,14 @@
if (!sc) {
detail.innerHTML = '未选择方案';
slotsBox.innerHTML = '';
var emptyHotkey = $('lo-hotkey-text');
if (emptyHotkey) { emptyHotkey.innerHTML = ''; }
return;
}
detail.innerHTML = '<b>' + esc(sc.Name || '') + '</b>' +
'<span class="lo-scheme-meta">' + esc(sc.CharacterName || '未绑定角色') + '</span>';
var hotkeyTextEl = $('lo-hotkey-text');
if (hotkeyTextEl) { hotkeyTextEl.innerHTML = '快捷键:' + esc(hotkeyText(sc)); }
var slots = sc.Slots || [];
if (!slots.length) {
slotsBox.innerHTML = '<div class="lo-empty">该方案没有保存装备</div>';
@@ -217,6 +221,123 @@
slotsBox.innerHTML = h.join('');
}
function hotkeyText(sc) {
if (!sc || !sc.KeyCode) { return '未设置'; }
var parts = modText(sc.Modifiers || 0);
parts.push(keyText(sc.KeyCode));
return parts.join('+');
}
function currentScheme() {
var page = currentPage();
var schemes = (page && page.Schemes) || [];
return schemes[S.scheme] || null;
}
function setHotkey() {
var sc = currentScheme();
if (!sc) { msg('请先选择方案'); return; }
S.capture = true;
msg('请按下快捷键,Esc 取消');
var handler = function (ev) {
ev = ev || window.event;
var code = ev.keyCode || ev.which;
if (code === 27) {
S.capture = false;
document.removeEventListener('keydown', handler, true);
msg('已取消设置快捷键');
return false;
}
if (!code || code === 16 || code === 17 || code === 18) {
return false;
}
var mods = 0;
if (ev.ctrlKey) { mods |= 2; }
if (ev.altKey) { mods |= 1; }
if (ev.shiftKey) { mods |= 4; }
sc.KeyCode = code;
sc.Modifiers = mods;
S.capture = false;
document.removeEventListener('keydown', handler, true);
saveConfig(function (ok) {
if (ok) {
renderDetail();
loadHotkeys();
msg('快捷键已保存:' + hotkeyText(sc));
}
});
if (ev.preventDefault) { ev.preventDefault(); }
return false;
};
document.addEventListener('keydown', handler, true);
}
function clearHotkey() {
var sc = currentScheme();
if (!sc) { msg('请先选择方案'); return; }
sc.KeyCode = 0;
sc.Modifiers = 0;
saveConfig(function (ok) {
if (ok) {
renderDetail();
loadHotkeys();
msg('快捷键已清除');
}
});
}
function addScheme() {
var page = currentPage();
if (!page) { return; }
var name = window.prompt('方案名称', '方案' + ((page.Schemes || []).length + 1));
if (!name) { return; }
var character = window.prompt('绑定角色游戏内名称', S.charName || '') || '';
page.Schemes = page.Schemes || [];
page.Schemes.push({
Name: String(name),
CharacterName: String(character),
Modifiers: 0,
KeyCode: 0,
Slots: []
});
S.scheme = page.Schemes.length - 1;
saveConfig(function (ok) {
if (ok) {
renderSchemes();
msg('已新增方案:' + name);
}
});
}
function renameScheme() {
var sc = currentScheme();
if (!sc) { msg('请先选择方案'); return; }
var name = window.prompt('重命名方案', sc.Name || '');
if (!name) { return; }
sc.Name = String(name);
saveConfig(function (ok) {
if (ok) {
renderSchemes();
msg('方案已重命名');
}
});
}
function deleteScheme() {
var page = currentPage();
var sc = currentScheme();
if (!page || !sc) { msg('请先选择方案'); return; }
if (!window.confirm('删除方案“' + (sc.Name || '') + '”?')) { return; }
page.Schemes.splice(S.scheme, 1);
S.scheme = -1;
saveConfig(function (ok) {
if (ok) {
renderSchemes();
msg('方案已删除');
}
});
}
function loadChars() {
api('/loadout/characters', 'GET', null, function (d) {
if (!d) { msg('角色读取失败,确认服务端已启动'); return; }
@@ -347,8 +468,15 @@
sel.onchange = function () {
S.page = parseInt(this.value, 10) || 0;
S.scheme = -1;
if (S.cfg) { S.cfg.ActivePage = S.page; }
renderSchemes();
loadHotkeys();
// The launcher hotkey worker reads ActivePage from config.json. Persist
// the page switch here, otherwise a hotkey assigned on this page never
// becomes the active page's hotkey.
saveConfig(function (ok) {
if (ok) { loadHotkeys(); }
});
};
}
var ch = $('lo-char');
@@ -360,6 +488,11 @@
if ((b = $('lo-page-add'))) { b.onclick = addPage; }
if ((b = $('lo-page-ren'))) { b.onclick = renamePage; }
if ((b = $('lo-page-del'))) { b.onclick = deletePage; }
if ((b = $('lo-scheme-add'))) { b.onclick = addScheme; }
if ((b = $('lo-scheme-ren'))) { b.onclick = renameScheme; }
if ((b = $('lo-scheme-del'))) { b.onclick = deleteScheme; }
if ((b = $('lo-hotkey'))) { b.onclick = setHotkey; }
if ((b = $('lo-hotkey-clear'))) { b.onclick = clearHotkey; }
}
function loadTab() {