Vanessa 2023-10-08 16:01:37 +08:00
parent 0ee6f5299e
commit 844c5ce688
3 changed files with 6 additions and 4 deletions

View file

@ -664,8 +664,10 @@ app.whenReady().then(() => {
ipcMain.on("siyuan-first-quit", () => {
app.exit();
});
ipcMain.handle("siyuan-dialog", (event, data) => {
return dialog.showOpenDialog(data);
});
ipcMain.on("siyuan-cmd", (event, cmd) => {
console.log(cmd)
switch (cmd) {
case "openDevTools":
event.sender.openDevTools({mode: "bottom"});

View file

@ -25,6 +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_CONFIG_TRAY: string = "siyuan-config-tray";
public static readonly SIYUAN_QUIT: string = "siyuan-quit";

View file

@ -1,7 +1,6 @@
import {copySubMenu, exportMd, movePathToMenu, openFileAttr, renameMenu,} from "./commonMenuItem";
/// #if !BROWSER
import {FileFilter, shell} from "electron";
import {dialog as remoteDialog} from "@electron/remote";
import {FileFilter, ipcRenderer, shell} from "electron";
import * as path from "path";
/// #endif
import {MenuItem} from "./Menu";
@ -643,7 +642,7 @@ export const genImportMenu = (notebookId: string, pathString: string) => {
if (isDoc) {
filters = [{name: "Markdown", extensions: ["md", "markdown"]}];
}
const localPath = await remoteDialog.showOpenDialog({
const localPath = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG, {
defaultPath: window.siyuan.config.system.homeDir,
filters,
properties: [isDoc ? "openFile" : "openDirectory"],