Vanessa 2024-03-26 21:04:06 +08:00
parent f016a05fb7
commit 10c181659d
3 changed files with 39 additions and 28 deletions

View file

@ -55,7 +55,7 @@ export const keymap = {
if (!dockConfig.hotkey) {
return;
}
const dockKeymap = window.siyuan.config.keymap.plugin[item.name][key];
const dockKeymap = window.siyuan.config.keymap.plugin[item.name][key];
const keyValue = updateHotkeyTip(dockKeymap.custom);
commandHTML += `<label class="b3-list-item b3-list-item--narrow b3-list-item--hide-action">
<span class="b3-list-item__text">${dockConfig.title}</span>
@ -186,6 +186,7 @@ export const keymap = {
},
_setkeymap(app: App) {
const data: Config.IKeymap = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP));
const oldToggleWin = window.siyuan.config.keymap.general.toggleWin.custom
keymap.element.querySelectorAll("label.b3-list-item input").forEach((item) => {
const keys = item.getAttribute("data-key").split(Constants.ZWSP);
const newHotkey = item.getAttribute("data-value");
@ -211,6 +212,12 @@ export const keymap = {
fetchPost("/api/setting/setKeymap", {
data
}, () => {
if (oldToggleWin !== window.siyuan.config.keymap.general.toggleWin.custom) {
ipcRenderer.send(Constants.SIYUAN_CMD, {
cmd: "unregisterGlobalShortcut",
accelerator: oldToggleWin
});
}
sendGlobalShortcut(app);
});
},
@ -298,7 +305,8 @@ export const keymap = {
/// #if !BROWSER
searchKeymapElement.addEventListener("focus", () => {
ipcRenderer.send(Constants.SIYUAN_CMD, {
cmd: "unregisterAll",
cmd: "unregisterGlobalShortcut",
accelerator: window.siyuan.config.keymap.general.toggleWin.custom
});
});
/// #endif
@ -325,6 +333,12 @@ export const keymap = {
fetchPost("/api/setting/setKeymap", {
data: Constants.SIYUAN_KEYMAP,
}, () => {
if (window.siyuan.config.keymap.general.toggleWin.default !== window.siyuan.config.keymap.general.toggleWin.custom) {
ipcRenderer.send(Constants.SIYUAN_CMD, {
cmd: "unregisterGlobalShortcut",
accelerator: window.siyuan.config.keymap.general.toggleWin.custom
});
}
window.location.reload();
sendGlobalShortcut(app);
});
@ -444,7 +458,8 @@ export const keymap = {
/// #if !BROWSER
item.addEventListener("focus", () => {
ipcRenderer.send(Constants.SIYUAN_CMD, {
cmd: "unregisterAll",
cmd: "unregisterGlobalShortcut",
accelerator: window.siyuan.config.keymap.general.toggleWin.custom
});
});
/// #endif

View file

@ -90,7 +90,7 @@ const renderPDF = async (id: string) => {
themeStyle = `<link rel="stylesheet" type="text/css" id="themeStyle" href="${servePath}/appearance/themes/${window.siyuan.config.appearance.themeLight}/theme.css?${Constants.SIYUAN_VERSION}"/>`;
}
const currentWindowId = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
cmd: "getCurrentWindowId",
cmd: "getContentsId",
});
// data-theme-mode="light" https://github.com/siyuan-note/siyuan/issues/7379
const html = `<!DOCTYPE html>