mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
ac3b54a538
commit
8713734ba9
7 changed files with 19 additions and 33 deletions
|
|
@ -841,14 +841,9 @@ app.whenReady().then(() => {
|
|||
});
|
||||
});
|
||||
});
|
||||
ipcMain.on("siyuan-lock-screen", () => {
|
||||
ipcMain.on("siyuan-send_windows", (event, data) => {
|
||||
BrowserWindow.getAllWindows().forEach(item => {
|
||||
item.webContents.send("siyuan-lock-screen");
|
||||
});
|
||||
});
|
||||
ipcMain.on("siyuan-closetab", (event, data) => {
|
||||
BrowserWindow.getAllWindows().forEach(item => {
|
||||
item.webContents.send("siyuan-closetab", data);
|
||||
item.webContents.send("siyuan-send_windows", data);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ export abstract class Constants {
|
|||
|
||||
// 渲染进程调主进程
|
||||
public static readonly SIYUAN_SHOW: string = "siyuan-show";
|
||||
public static readonly SIYUAN_LOCK_SCREEN: string = "siyuan-lock-screen";
|
||||
public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";
|
||||
public static readonly SIYUAN_OPEN_WORKSPACE: string = "siyuan-open-workspace";
|
||||
public static readonly SIYUAN_QUIT: string = "siyuan-quit";
|
||||
|
|
@ -30,7 +29,7 @@ export abstract class Constants {
|
|||
public static readonly SIYUAN_INIT: string = "siyuan-init";
|
||||
public static readonly SIYUAN_OPENURL: string = "siyuan-openurl";
|
||||
public static readonly SIYUAN_OPENWINDOW: string = "siyuan-openwindow";
|
||||
public static readonly SIYUAN_CLOSETAB: string = "siyuan-closetab";
|
||||
public static readonly SIYUAN_SEND_WINDOWS: string = "siyuan-send_windows"; // 主窗口和各新窗口之间的通信,{cmd: "closetab"|"lockscreen", data: {}})
|
||||
public static readonly SIYUAN_SAVE_CLOSE: string = "siyuan-save-close";
|
||||
public static readonly SIYUAN_EXPORT_PDF: string = "siyuan-export-pdf";
|
||||
public static readonly SIYUAN_EXPORT_CLOSE: string = "siyuan-export-close";
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ import {needSubscribe} from "../util/needSubscribe";
|
|||
export const lockScreen = () => {
|
||||
/// #if BROWSER
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
window.location.href = "/";
|
||||
window.location.href = `/check-auth?url=${window.location.href}`;
|
||||
});
|
||||
/// #else
|
||||
ipcRenderer.send(Constants.SIYUAN_LOCK_SCREEN);
|
||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "lockscreen"});
|
||||
/// #endif
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ export class Wnd {
|
|||
if (wnd instanceof Wnd) {
|
||||
JSONToCenter(tabData, wnd);
|
||||
oldTab = wnd.children[wnd.children.length - 1];
|
||||
ipcRenderer.send(Constants.SIYUAN_CLOSETAB, tabData.id);
|
||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
||||
it.querySelector("li[data-clone='true']").remove();
|
||||
wnd.switchTab(oldTab.headElement);
|
||||
}
|
||||
|
|
@ -331,7 +331,7 @@ export class Wnd {
|
|||
if (!oldTab) { // 从主窗口拖拽到页签新窗口
|
||||
JSONToCenter(tabData, this);
|
||||
oldTab = this.children[this.children.length - 1];
|
||||
ipcRenderer.send(Constants.SIYUAN_CLOSETAB, tabData.id);
|
||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
||||
}
|
||||
/// #endif
|
||||
if (!oldTab) {
|
||||
|
|
|
|||
|
|
@ -89,9 +89,11 @@ const switchDialogEvent = (event: MouseEvent, switchDialog: Dialog) => {
|
|||
|
||||
export const globalShortcut = () => {
|
||||
document.body.addEventListener("mouseleave", () => {
|
||||
if (window.siyuan.layout.leftDock) {
|
||||
window.siyuan.layout.leftDock.hideDock();
|
||||
window.siyuan.layout.rightDock.hideDock();
|
||||
window.siyuan.layout.bottomDock.hideDock();
|
||||
}
|
||||
});
|
||||
window.addEventListener("mousemove", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
if (window.siyuan.hideBreadcrumb) {
|
||||
|
|
@ -837,7 +839,7 @@ export const globalShortcut = () => {
|
|||
}
|
||||
// dock float 时,点击空白处,隐藏 dock
|
||||
const floatDockLayoutElement = hasClosestByClassName(event.target, "layout--float", true);
|
||||
if (floatDockLayoutElement) {
|
||||
if (floatDockLayoutElement && window.siyuan.layout.leftDock) {
|
||||
if (!floatDockLayoutElement.isSameNode(window.siyuan.layout.bottomDock.layout.element)) {
|
||||
window.siyuan.layout.bottomDock.hideDock();
|
||||
}
|
||||
|
|
@ -847,7 +849,7 @@ export const globalShortcut = () => {
|
|||
if (!floatDockLayoutElement.isSameNode(window.siyuan.layout.rightDock.layout.element)) {
|
||||
window.siyuan.layout.rightDock.hideDock();
|
||||
}
|
||||
} else if (!hasClosestByClassName(event.target, "dock") && !isWindow()) {
|
||||
} else if (!hasClosestByClassName(event.target, "dock") && !isWindow() && window.siyuan.layout.leftDock) {
|
||||
window.siyuan.layout.bottomDock.hideDock();
|
||||
window.siyuan.layout.leftDock.hideDock();
|
||||
window.siyuan.layout.rightDock.hideDock();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {openSearch} from "../search/spread";
|
||||
import {exportLayout, getInstanceById, JSONToLayout, resetLayout, resizeDrag, resizeTabs} from "../layout/util";
|
||||
import {exportLayout, JSONToLayout, resetLayout, resizeDrag, resizeTabs} from "../layout/util";
|
||||
import {hotKey2Electron, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
/// #if !BROWSER
|
||||
import {dialog, getCurrentWindow} from "@electron/remote";
|
||||
|
|
@ -7,6 +7,7 @@ import {ipcRenderer, OpenDialogReturnValue, webFrame} from "electron";
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import {afterExport} from "../protyle/export/util";
|
||||
import {onWindowsMsg} from "../window/onWindowsMsg";
|
||||
/// #endif
|
||||
import {Constants} from "../constants";
|
||||
import {appearance} from "../config/appearance";
|
||||
|
|
@ -30,7 +31,6 @@ import {replaceLocalPath} from "../editor/rename";
|
|||
import {workspaceMenu} from "../menus/workspace";
|
||||
import {getWorkspaceName} from "./noRelyPCFunction";
|
||||
import {setTabPosition} from "../window/setHeader";
|
||||
import {Tab} from "../layout/Tab";
|
||||
|
||||
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
||||
if (key1 === "general") {
|
||||
|
|
@ -356,18 +356,8 @@ export const initWindow = () => {
|
|||
winOnClose(currentWindow, close);
|
||||
});
|
||||
}
|
||||
ipcRenderer.on(Constants.SIYUAN_CLOSETAB, (e, ipcData) => {
|
||||
const tab = getInstanceById(ipcData);
|
||||
if (tab && tab instanceof Tab) {
|
||||
tab.parent.removeTab(ipcData);
|
||||
}
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_LOCK_SCREEN, () => {
|
||||
exportLayout(false, () => {
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_SEND_WINDOWS, (e, ipcData: IWebSocketData) => {
|
||||
onWindowsMsg(ipcData);
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_EXPORT_CLOSE, () => {
|
||||
window.siyuan.printWin.destroy();
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@
|
|||
return response.json()
|
||||
}).then((response) => {
|
||||
if (0 === response.code) {
|
||||
window.location.href = '/'
|
||||
window.location.href = window.location.search.replace('?url=', '')
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue