An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/9368 dialog
Vanessaec6511833906
diff --git a/app/electron/main.js b/app/electron/main.jsindex 11a8b4dbc2..f5025a5f04 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -665,7 +665,7 @@ app.whenReady().then(() => {app.exit();});ipcMain.handle("siyuan-dialog", (event, data) => {- return dialog.showOpenDialog(data);+ return dialog[data.type || "showOpenDialog"](data);});ipcMain.on("siyuan-cmd", (event, cmd) => {switch (cmd) {diff --git a/app/src/config/exportConfig.ts b/app/src/config/exportConfig.tsindex d071c1d84b..24ed952f01 100644--- a/app/src/config/exportConfig.ts+++ b/app/src/config/exportConfig.ts@@ -1,12 +1,13 @@import {fetchPost} from "../util/fetch";/// #if !BROWSER-import {dialog} from "@electron/remote";import {afterExport} from "../protyle/export/util";+import { ipcRenderer } from "electron";import * as path from "path";/// #endifimport {isBrowser} from "../util/functions";import {showMessage} from "../dialog/message";import {showFileInFolder} from "../util/pathName";+import {Constants} from "../constants";export const exportConfig = {element: undefined as Element,@@ -179,13 +180,14 @@ export const exportConfig = {});}});- exportConfig.element.querySelector("#exportData").addEventListener("click", () => {+ exportConfig.element.querySelector("#exportData").addEventListener("click", async () => {/// #if BROWSERfetchPost("/api/export/exportData", {}, response => {window.location.href = response.data.zip;});/// #else- const filePaths = dialog.showOpenDialogSync({+ const filePaths = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{+ type: "showOpenDialogSync",title: window.siyuan.languages.export + " " + "Data",properties: ["createDirectory", "openDirectory"],});@@ -209,7 +211,8 @@ export const exportConfig = {});const pandocBinElement = exportConfig.element.querySelector("#pandocBin") as HTMLInputElement;pandocBinElement.addEventListener("click", async () => {- const localPath = await dialog.showOpenDialog({+ const localPath = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{+ type: "showOpenDialog",defaultPath: window.siyuan.config.system.homeDir,properties: ["openFile"],});diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex 87dd29bd04..6b34c8fe77 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -643,6 +643,7 @@ export const genImportMenu = (notebookId: string, pathString: string) => {filters = [{name: "Markdown", extensions: ["md", "markdown"]}];}const localPath = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG, {+ type: "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.tsindex 7338a6633a..462270b4ce 100644--- a/app/src/menus/util.ts+++ b/app/src/menus/util.ts@@ -1,6 +1,5 @@/// #if !BROWSER-import {dialog} from "@electron/remote";-import {SaveDialogReturnValue} from "electron";+import {ipcRenderer} from "electron";import * as path from "path";/// #endifimport {fetchPost} from "../util/fetch";@@ -17,15 +16,15 @@ export const exportAsset = (src: string) => {return {label: window.siyuan.languages.export,icon: "iconUpload",- click() {- dialog.showSaveDialog({+ async click() {+ const result = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{+ type: "showSaveDialog",defaultPath: getAssetName(src) + pathPosix().extname(src),properties: ["showOverwriteConfirmation"],- }).then((result: SaveDialogReturnValue) => {- if (!result.canceled) {- fetchPost("/api/file/copyFile", {src, dest: result.filePath});- }});+ if (!result.canceled) {+ fetchPost("/api/file/copyFile", {src, dest: result.filePath});+ }}};/// #endifdiff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.tsindex 41ee51035b..982ce51602 100644--- a/app/src/menus/workspace.ts+++ b/app/src/menus/workspace.ts@@ -1,6 +1,6 @@import {MenuItem} from "./Menu";/// #if !BROWSER-import {dialog, getCurrentWindow} from "@electron/remote";+import {getCurrentWindow} from "@electron/remote";import {ipcRenderer} from "electron";/// #endifimport {openHistory} from "../history/history";@@ -85,7 +85,8 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {label: `${window.siyuan.languages.new} / ${window.siyuan.languages.openBy}`,iconHTML: "",click: async () => {- const localPath = await dialog.showOpenDialog({+ const localPath = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG,{+ type: "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.tsindex 0089f4d4bd..1da2731432 100644--- a/app/src/protyle/export/index.ts+++ b/app/src/protyle/export/index.ts@@ -1,8 +1,8 @@import {hideMessage, showMessage} from "../../dialog/message";import {Constants} from "../../constants";/// #if !BROWSER-import {ipcRenderer, OpenDialogReturnValue} from "electron";-import {app, BrowserWindow, dialog, getCurrentWindow} from "@electron/remote";+import {ipcRenderer} from "electron";+import {app, BrowserWindow, getCurrentWindow} from "@electron/remote";import * as fs from "fs";import * as path from "path";import {afterExport} from "./util";@@ -527,7 +527,7 @@ const renderPDF = (id: string) => {const getExportPath = (option: { type: string, id: string }, removeAssets?: boolean, mergeSubdocs?: boolean) => {fetchPost("/api/block/getBlockInfo", {id: option.id- }, (response) => {+ }, async (response) => {if (response.code === 3) {showMessage(response.msg);return;@@ -545,43 +545,43 @@ const getExportPath = (option: { type: string, id: string }, removeAssets?: boolbreak;}- dialog.showOpenDialog({+ const result = await ipcRenderer.invoke(Constants.SIYUAN_DIALOG, {+ type: "showOpenDialog",title: window.siyuan.languages.export + " " + exportType,properties: ["createDirectory", "openDirectory"],- }).then((result: OpenDialogReturnValue) => {- if (!result.canceled) {- const msgId = showMessage(window.siyuan.languages.exporting, -1);- let url = "/api/export/exportHTML";- if (option.type === "htmlmd") {- url = "/api/export/exportMdHTML";- } else if (option.type === "word") {- url = "/api/export/exportDocx";- }- let savePath = result.filePaths[0];- if (option.type !== "word" && !savePath.endsWith(response.data.rootTitle)) {- savePath = path.join(savePath, replaceLocalPath(response.data.rootTitle));- }- savePath = savePath.trim();- fetchPost(url, {- id: option.id,- pdf: option.type === "pdf",- removeAssets: removeAssets,- merge: mergeSubdocs,- savePath- }, exportResponse => {- if (option.type === "word") {- if (exportResponse.code === 1) {- showMessage(exportResponse.msg, undefined, "error");- hideMessage(msgId);- return;- }- afterExport(path.join(savePath, replaceLocalPath(response.data.rootTitle)) + ".docx", msgId);- } else {- onExport(exportResponse, savePath, option.type, removeAssets, msgId);- }- });- }});+ if (!result.canceled) {+ const msgId = showMessage(window.siyuan.languages.exporting, -1);+ let url = "/api/export/exportHTML";+ if (option.type === "htmlmd") {+ url = "/api/export/exportMdHTML";+ } else if (option.type === "word") {+ url = "/api/export/exportDocx";+ }+ let savePath = result.filePaths[0];+ if (option.type !== "word" && !savePath.endsWith(response.data.rootTitle)) {+ savePath = path.join(savePath, replaceLocalPath(response.data.rootTitle));+ }+ savePath = savePath.trim();+ fetchPost(url, {+ id: option.id,+ pdf: option.type === "pdf",+ removeAssets: removeAssets,+ merge: mergeSubdocs,+ savePath+ }, exportResponse => {+ if (option.type === "word") {+ if (exportResponse.code === 1) {+ showMessage(exportResponse.msg, undefined, "error");+ hideMessage(msgId);+ return;+ }+ afterExport(path.join(savePath, replaceLocalPath(response.data.rootTitle)) + ".docx", msgId);+ } else {+ onExport(exportResponse, savePath, option.type, removeAssets, msgId);+ }+ });+ }});};