Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/9368 isFullScreen

Vanessab869fd1d9d1a
diff --git a/app/electron/main.js b/app/electron/main.js
index f5025a5f04..c00c83ac8f 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -664,8 +664,16 @@ app.whenReady().then(() => {
ipcMain.on("siyuan-first-quit", () => {
app.exit();
});
- ipcMain.handle("siyuan-dialog", (event, data) => {
- return dialog[data.type || "showOpenDialog"](data);
+ ipcMain.handle("siyuan-get", (event, data) => {
+ if (data.cmd === "showOpenDialog") {
+ return dialog.showOpenDialog(data);
+ }
+ if (data.cmd === "showSaveDialog") {
+ return dialog.showSaveDialog(data);
+ }
+ if (data.cmd === "isFullScreen") {
+ return getWindowByContentId(event.sender.id).isFullScreen();
+ }
});
ipcMain.on("siyuan-cmd", (event, cmd) => {
switch (cmd) {
diff --git a/app/src/config/exportConfig.ts b/app/src/config/exportConfig.ts
index 24ed952f01..d409a98169 100644
--- a/app/src/config/exportConfig.ts
+++ b/app/src/config/exportConfig.ts
@@ -186,8 +186,8 @@ export const exportConfig = {
window.location.href = response.data.zip;
});
/// #else
- const filePaths = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{
- type: "showOpenDialogSync",
+ const filePaths = await ipcRenderer.invoke(Constants.SIYUAN_GET,{
+ cmd: "showOpenDialogSync",
title: window.siyuan.languages.export + " " + "Data",
properties: ["createDirectory", "openDirectory"],
});
@@ -211,8 +211,8 @@ export const exportConfig = {
});
const pandocBinElement = exportConfig.element.querySelector("#pandocBin") as HTMLInputElement;
pandocBinElement.addEventListener("click", async () => {
- const localPath = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{
- type: "showOpenDialog",
+ const localPath = await ipcRenderer.invoke(Constants.SIYUAN_GET,{
+ cmd: "showOpenDialog",
defaultPath: window.siyuan.config.system.homeDir,
properties: ["openFile"],
});
diff --git a/app/src/constants.ts b/app/src/constants.ts
index b931798b22..b0aa2fb602 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -25,7 +25,7 @@ export abstract class Constants {
// 渲染进程调主进程
public static readonly SIYUAN_CMD: string = "siyuan-cmd";
- public static readonly SIYUAN_DIALOG: string = "siyuan-dialog";
+ public static readonly SIYUAN_GET: string = "siyuan-get";
public static readonly SIYUAN_CONFIG_TRAY: string = "siyuan-config-tray";
public static readonly SIYUAN_QUIT: string = "siyuan-quit";
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index 6b34c8fe77..9285d70061 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -642,8 +642,8 @@ export const genImportMenu = (notebookId: string, pathString: string) => {
if (isDoc) {
filters = [{name: "Markdown", extensions: ["md", "markdown"]}];
}
- const localPath = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG, {
- type: "showOpenDialog",
+ const localPath = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
+ cmd: "showOpenDialog",
defaultPath: window.siyuan.config.system.homeDir,
filters,
properties: [isDoc ? "openFile" : "openDirectory"],
diff --git a/app/src/menus/util.ts b/app/src/menus/util.ts
index 462270b4ce..6fa16b5ad2 100644
--- a/app/src/menus/util.ts
+++ b/app/src/menus/util.ts
@@ -17,8 +17,8 @@ export const exportAsset = (src: string) => {
label: window.siyuan.languages.export,
icon: "iconUpload",
async click() {
- const result = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{
- type: "showSaveDialog",
+ const result = await ipcRenderer.invoke(Constants.SIYUAN_GET,{
+ cmd: "showSaveDialog",
defaultPath: getAssetName(src) + pathPosix().extname(src),
properties: ["showOverwriteConfirmation"],
});
diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.ts
index 982ce51602..c9bd801e7f 100644
--- a/app/src/menus/workspace.ts
+++ b/app/src/menus/workspace.ts
@@ -85,8 +85,8 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
label: `${window.siyuan.languages.new} / ${window.siyuan.languages.openBy}`,
iconHTML: "",
click: async () => {
- const localPath = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{
- type: "showOpenDialog",
+ const localPath = await ipcRenderer.invoke(Constants.SIYUAN_GET,{
+ cmd: "showOpenDialog",
defaultPath: window.siyuan.config.system.homeDir,
properties: ["openDirectory", "createDirectory"],
});
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 1da2731432..ee90e20000 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -545,8 +545,8 @@ const getExportPath = (option: { type: string, id: string }, removeAssets?: bool
break;
}
- const result = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG, {
- type: "showOpenDialog",
+ const result = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
+ cmd: "showOpenDialog",
title: window.siyuan.languages.export + " " + exportType,
properties: ["createDirectory", "openDirectory"],
});
diff --git a/app/src/window/setHeader.ts b/app/src/window/setHeader.ts
index 1cd5395d1a..cebde8fb8e 100644
--- a/app/src/window/setHeader.ts
+++ b/app/src/window/setHeader.ts
@@ -1,11 +1,11 @@
import {isWindow} from "../util/functions";
import {Wnd} from "../layout/Wnd";
-import {getCurrentWindow} from "@electron/remote";
import {Layout} from "../layout";
import {getAllTabs} from "../layout/getAll";
import {Editor} from "../editor";
import {Asset} from "../asset";
import {Constants} from "../constants";
+import { ipcRenderer } from "electron";
const getAllWnds = (layout: Layout, wnds: Wnd[]) => {
for (let i = 0; i < layout.children.length; i++) {
@@ -24,7 +24,7 @@ export const setTabPosition = () => {
}
const wndsTemp: Wnd[] = [];
getAllWnds(window.siyuan.layout.layout, wndsTemp);
- wndsTemp.forEach(item => {
+ wndsTemp.forEach(async item => {
const headerElement = item.headersElement.parentElement;
const rect = headerElement.getBoundingClientRect();
const dragElement = headerElement.querySelector(".item--readonly .fn__flex-1") as HTMLElement;
@@ -38,7 +38,10 @@ export const setTabPosition = () => {
}
const headersLastElement = headerElement.lastElementChild as HTMLElement;
if ("darwin" === window.siyuan.config.system.os) {
- if (rect.top <= 0 && rect.left <= 0 && !getCurrentWindow().isFullScreen()) {
+ const isFullScreen = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
+ cmd: "isFullScreen",
+ });
+ if (rect.top <= 0 && rect.left <= 0 && !isFullScreen) {
item.headersElement.style.marginLeft = "var(--b3-toolbar-left-mac)";
headersLastElement.style.paddingRight = "42px";
} else {