mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 17:10:53 +08:00
This commit is contained in:
parent
f016a05fb7
commit
10c181659d
@ -433,7 +433,6 @@ const initKernel = (workspace, port, lang) => {
|
|||||||
backgroundColor: "#1e1e1e",
|
backgroundColor: "#1e1e1e",
|
||||||
icon: path.join(appDir, "stage", "icon-large.png"),
|
icon: path.join(appDir, "stage", "icon-large.png"),
|
||||||
});
|
});
|
||||||
|
|
||||||
let bootIndex = path.join(appDir, "app", "electron", "boot.html");
|
let bootIndex = path.join(appDir, "app", "electron", "boot.html");
|
||||||
if (isDevEnv) {
|
if (isDevEnv) {
|
||||||
bootIndex = path.join(appDir, "electron", "boot.html");
|
bootIndex = path.join(appDir, "electron", "boot.html");
|
||||||
@ -682,12 +681,9 @@ app.whenReady().then(() => {
|
|||||||
|
|
||||||
resetTrayMenu(tray, lang, mainWindow);
|
resetTrayMenu(tray, lang, mainWindow);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWindowByContentId = (id) => {
|
const getWindowByContentId = (id) => {
|
||||||
const wnd = BrowserWindow.getAllWindows().find((win) => win.webContents.id === id);
|
return BrowserWindow.getAllWindows().find((win) => win.webContents.id === id);
|
||||||
if (!wnd) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return BrowserWindow.fromId(wnd.id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcMain.on("siyuan-open-folder", (event, filePath) => {
|
ipcMain.on("siyuan-open-folder", (event, filePath) => {
|
||||||
@ -700,7 +696,7 @@ app.whenReady().then(() => {
|
|||||||
if (data.cmd === "showOpenDialog") {
|
if (data.cmd === "showOpenDialog") {
|
||||||
return dialog.showOpenDialog(data);
|
return dialog.showOpenDialog(data);
|
||||||
}
|
}
|
||||||
if (data.cmd === "getCurrentWindowId") {
|
if (data.cmd === "getContentsId") {
|
||||||
return event.sender.id;
|
return event.sender.id;
|
||||||
}
|
}
|
||||||
if (data.cmd === "setProxy") {
|
if (data.cmd === "setProxy") {
|
||||||
@ -796,8 +792,8 @@ app.whenReady().then(() => {
|
|||||||
case "openDevTools":
|
case "openDevTools":
|
||||||
event.sender.openDevTools({mode: "bottom"});
|
event.sender.openDevTools({mode: "bottom"});
|
||||||
break;
|
break;
|
||||||
case "unregisterAll":
|
case "unregisterGlobalShortcut":
|
||||||
globalShortcut.unregisterAll();
|
globalShortcut.unregister(hotKey2Electron(data.accelerator));
|
||||||
break;
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
if (!currentWindow) {
|
if (!currentWindow) {
|
||||||
@ -1036,7 +1032,6 @@ app.whenReady().then(() => {
|
|||||||
await net.fetch(getServer(data.port) + "/api/system/uiproc?pid=" + process.pid, {method: "POST"});
|
await net.fetch(getServer(data.port) + "/api/system/uiproc?pid=" + process.pid, {method: "POST"});
|
||||||
});
|
});
|
||||||
ipcMain.on("siyuan-hotkey", (event, data) => {
|
ipcMain.on("siyuan-hotkey", (event, data) => {
|
||||||
globalShortcut.unregisterAll();
|
|
||||||
if (!data.hotkeys || data.hotkeys.length === 0) {
|
if (!data.hotkeys || data.hotkeys.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1045,31 +1040,32 @@ app.whenReady().then(() => {
|
|||||||
if (!shortcut) {
|
if (!shortcut) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (globalShortcut.isRegistered(shortcut)) {
|
||||||
|
globalShortcut.unregister(shortcut)
|
||||||
|
}
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
globalShortcut.register(shortcut, () => {
|
globalShortcut.register(shortcut, () => {
|
||||||
workspaces.forEach(workspaceItem => {
|
workspaces.find(workspaceItem => {
|
||||||
const mainWindow = workspaceItem.browserWindow;
|
const mainWindow = workspaceItem.browserWindow;
|
||||||
if (mainWindow.isMinimized()) {
|
if (event.sender.id === mainWindow.webContents.id) {
|
||||||
mainWindow.restore();
|
if (mainWindow.isMinimized()) {
|
||||||
mainWindow.show(); // 按 `Alt+M` 后隐藏窗口,再次按 `Alt+M` 显示窗口后会卡住不能编辑 https://github.com/siyuan-note/siyuan/issues/8456
|
mainWindow.restore();
|
||||||
} else {
|
mainWindow.show(); // 按 `Alt+M` 后隐藏窗口,再次按 `Alt+M` 显示窗口后会卡住不能编辑 https://github.com/siyuan-note/siyuan/issues/8456
|
||||||
if (mainWindow.isVisible()) {
|
} else {
|
||||||
if (1 === workspaces.length) { // 改进 `Alt+M` 激活窗口 https://github.com/siyuan-note/siyuan/issues/7258
|
if (mainWindow.isVisible()) {
|
||||||
if (!mainWindow.isFocused()) {
|
if (!mainWindow.isFocused()) {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
} else {
|
} else {
|
||||||
hideWindow(mainWindow);
|
hideWindow(mainWindow);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hideWindow(mainWindow);
|
mainWindow.show();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
mainWindow.show();
|
|
||||||
}
|
}
|
||||||
}
|
if ("win32" === process.platform || "linux" === process.platform) {
|
||||||
|
resetTrayMenu(workspaceItem.tray, data.languages, mainWindow);
|
||||||
if ("win32" === process.platform || "linux" === process.platform) {
|
}
|
||||||
resetTrayMenu(workspaceItem.tray, data.languages, mainWindow);
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -55,7 +55,7 @@ export const keymap = {
|
|||||||
if (!dockConfig.hotkey) {
|
if (!dockConfig.hotkey) {
|
||||||
return;
|
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);
|
const keyValue = updateHotkeyTip(dockKeymap.custom);
|
||||||
commandHTML += `<label class="b3-list-item b3-list-item--narrow b3-list-item--hide-action">
|
commandHTML += `<label class="b3-list-item b3-list-item--narrow b3-list-item--hide-action">
|
||||||
<span class="b3-list-item__text">${dockConfig.title}</span>
|
<span class="b3-list-item__text">${dockConfig.title}</span>
|
||||||
@ -186,6 +186,7 @@ export const keymap = {
|
|||||||
},
|
},
|
||||||
_setkeymap(app: App) {
|
_setkeymap(app: App) {
|
||||||
const data: Config.IKeymap = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP));
|
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) => {
|
keymap.element.querySelectorAll("label.b3-list-item input").forEach((item) => {
|
||||||
const keys = item.getAttribute("data-key").split(Constants.ZWSP);
|
const keys = item.getAttribute("data-key").split(Constants.ZWSP);
|
||||||
const newHotkey = item.getAttribute("data-value");
|
const newHotkey = item.getAttribute("data-value");
|
||||||
@ -211,6 +212,12 @@ export const keymap = {
|
|||||||
fetchPost("/api/setting/setKeymap", {
|
fetchPost("/api/setting/setKeymap", {
|
||||||
data
|
data
|
||||||
}, () => {
|
}, () => {
|
||||||
|
if (oldToggleWin !== window.siyuan.config.keymap.general.toggleWin.custom) {
|
||||||
|
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||||
|
cmd: "unregisterGlobalShortcut",
|
||||||
|
accelerator: oldToggleWin
|
||||||
|
});
|
||||||
|
}
|
||||||
sendGlobalShortcut(app);
|
sendGlobalShortcut(app);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -298,7 +305,8 @@ export const keymap = {
|
|||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
searchKeymapElement.addEventListener("focus", () => {
|
searchKeymapElement.addEventListener("focus", () => {
|
||||||
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||||
cmd: "unregisterAll",
|
cmd: "unregisterGlobalShortcut",
|
||||||
|
accelerator: window.siyuan.config.keymap.general.toggleWin.custom
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
@ -325,6 +333,12 @@ export const keymap = {
|
|||||||
fetchPost("/api/setting/setKeymap", {
|
fetchPost("/api/setting/setKeymap", {
|
||||||
data: Constants.SIYUAN_KEYMAP,
|
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();
|
window.location.reload();
|
||||||
sendGlobalShortcut(app);
|
sendGlobalShortcut(app);
|
||||||
});
|
});
|
||||||
@ -444,7 +458,8 @@ export const keymap = {
|
|||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
item.addEventListener("focus", () => {
|
item.addEventListener("focus", () => {
|
||||||
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||||
cmd: "unregisterAll",
|
cmd: "unregisterGlobalShortcut",
|
||||||
|
accelerator: window.siyuan.config.keymap.general.toggleWin.custom
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
|
@ -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}"/>`;
|
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, {
|
const currentWindowId = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
||||||
cmd: "getCurrentWindowId",
|
cmd: "getContentsId",
|
||||||
});
|
});
|
||||||
// data-theme-mode="light" https://github.com/siyuan-note/siyuan/issues/7379
|
// data-theme-mode="light" https://github.com/siyuan-note/siyuan/issues/7379
|
||||||
const html = `<!DOCTYPE html>
|
const html = `<!DOCTYPE html>
|
||||||
|
Loading…
Reference in New Issue
Block a user