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: Open the Explorer window in the foreground (#14828)
Jeffrey Chenbf08509986a2
diff --git a/app/electron/main.js b/app/electron/main.jsindex e0fcdb8658..6b860bad5a 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -764,6 +764,9 @@ app.whenReady().then(() => {ipcMain.on("siyuan-open-folder", (event, filePath) => {shell.showItemInFolder(filePath);});+ ipcMain.on("siyuan-open-path", (event, filePath) => {+ shell.openPath(filePath);+ });ipcMain.on("siyuan-first-quit", () => {app.exit();});diff --git a/app/src/config/about.ts b/app/src/config/about.tsindex 7152c88571..cca47ffdfe 100644--- a/app/src/config/about.ts+++ b/app/src/config/about.ts@@ -12,6 +12,7 @@ import {showMessage} from "../dialog/message";import {Dialog} from "../dialog";import {confirmDialog} from "../dialog/confirmDialog";import {setKey} from "../sync/syncGuide";+import {openPath} from "../util/pathName";export const about = {element: undefined as Element,@@ -259,7 +260,7 @@ ${checkUpdateHTML}if (url.startsWith("http")) {shell.openExternal(url);} else {- shell.openPath(url);+ openPath(url);}/// #elsewindow.open(url);diff --git a/app/src/config/appearance.ts b/app/src/config/appearance.tsindex acdac0d507..3b9c9c299a 100644--- a/app/src/config/appearance.ts+++ b/app/src/config/appearance.ts@@ -11,6 +11,7 @@ import {openSnippets} from "./util/snippets";import {loadAssets} from "../util/assets";import {resetFloatDockSize} from "../layout/dock/util";import {confirmDialog} from "../dialog/confirmDialog";+import {openPath} from "../util/pathName";export const appearance = {element: undefined as Element,@@ -233,13 +234,13 @@ export const appearance = {});/// #if !BROWSERappearance.element.querySelector("#appearanceOpenIcon").addEventListener("click", () => {- shell.openPath(path.join(window.siyuan.config.system.confDir, "appearance", "icons"));+ openPath(path.join(window.siyuan.config.system.confDir, "appearance", "icons"));});appearance.element.querySelector("#appearanceOpenTheme").addEventListener("click", () => {- shell.openPath(path.join(window.siyuan.config.system.confDir, "appearance", "themes"));+ openPath(path.join(window.siyuan.config.system.confDir, "appearance", "themes"));});appearance.element.querySelector("#appearanceOpenEmoji").addEventListener("click", () => {- shell.openPath(path.join(window.siyuan.config.system.dataDir, "emojis"));+ openPath(path.join(window.siyuan.config.system.dataDir, "emojis"));});/// #endifappearance.element.querySelectorAll("select").forEach(item => {diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.tsindex 4efdb227d7..2fc5389d39 100644--- a/app/src/config/bazaar.ts+++ b/app/src/config/bazaar.ts@@ -19,6 +19,7 @@ import {uninstall} from "../plugin/uninstall";import {afterLoadPlugin, loadPlugin, loadPlugins, reloadPlugin} from "../plugin/loader";import {loadAssets} from "../util/assets";import {addScript} from "../protyle/util/addScript";+import {openPath} from "../util/pathName";export const bazaar = {element: undefined as Element,@@ -625,9 +626,9 @@ export const bazaar = {/// #if !BROWSERconst dirName = dataObj.bazaarType;if (dirName === "icons" || dirName === "themes") {- shell.openPath(path.join(window.siyuan.config.system.confDir, "appearance", dirName, dataObj.name));+ openPath(path.join(window.siyuan.config.system.confDir, "appearance", dirName, dataObj.name));} else {- shell.openPath(path.join(window.siyuan.config.system.dataDir, dirName, dataObj.name));+ openPath(path.join(window.siyuan.config.system.dataDir, dirName, dataObj.name));}/// #endifevent.preventDefault();diff --git a/app/src/constants.ts b/app/src/constants.tsindex e8c1ff93ca..30ad6ad65e 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -50,6 +50,7 @@ export abstract class Constants {public static readonly SIYUAN_OPEN_URL: string = "siyuan-open-url";public static readonly SIYUAN_OPEN_WINDOW: string = "siyuan-open-window";public static readonly SIYUAN_OPEN_FOLDER: string = "siyuan-open-folder";+ public static readonly SIYUAN_OPEN_PATH: string = "siyuan-open-path";public static readonly SIYUAN_OPEN_FILE: string = "siyuan-open-file";public static readonly SIYUAN_EXPORT_PDF: string = "siyuan-export-pdf";diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex 537ff3285c..42f754b79d 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -5,7 +5,7 @@ import {getInstanceById, getWndByLayout, pdfIsLoading, setPanelFocus} from "../limport {getDockByType} from "../layout/tabUtil";import {getAllModels, getAllTabs} from "../layout/getAll";import {highlightById, scrollCenter} from "../util/highlightById";-import {getDisplayName, pathPosix, showFileInFolder} from "../util/pathName";+import {getDisplayName, openPath, pathPosix, showFileInFolder} from "../util/pathName";import {Constants} from "../constants";import {setEditMode} from "../protyle/util/setEditMode";import {Files} from "../layout/dock/Files";@@ -695,7 +695,7 @@ export const openBy = (url: string, type: "folder" | "app") => {if (url.startsWith("assets/")) {fetchPost("/api/asset/resolveAssetPath", {path: url.replace(/\.pdf\?page=\d{1,}$/, ".pdf")}, (response) => {if (type === "app") {- shell.openPath(response.data);+ openPath(response.data);} else if (type === "folder") {showFileInFolder(response.data);}@@ -713,7 +713,7 @@ export const openBy = (url: string, type: "folder" | "app") => {// 拖入文件名包含 `)` 、`(` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786address = address.replace(/\\\)/g, ")").replace(/\\\(/g, "(");if (type === "app") {- shell.openPath(address);+ openPath(address);} else if (type === "folder") {if ("windows" === window.siyuan.config.system.os) {if (!address.startsWith("\\\\")) { // \\ 开头的路径是 Windows 网络共享路径 https://github.com/siyuan-note/siyuan/issues/5980diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex ff700a21a3..4c10ba2d8f 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -1,10 +1,10 @@import {copySubMenu, exportMd, movePathToMenu, openFileAttr, renameMenu,} from "./commonMenuItem";/// #if !BROWSER-import {FileFilter, ipcRenderer, shell} from "electron";+import {FileFilter, ipcRenderer} from "electron";import * as path from "path";/// #endifimport {MenuItem} from "./Menu";-import {getDisplayName, getNotebookName, getTopPaths, pathPosix} from "../util/pathName";+import {getDisplayName, getNotebookName, getTopPaths, openPath, pathPosix} from "../util/pathName";import {hideMessage, showMessage} from "../dialog/message";import {fetchPost, fetchSyncPost} from "../util/fetch";import {onGetnotebookconf} from "./onGetnotebookconf";@@ -362,7 +362,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {icon: "iconFolder",label: window.siyuan.languages.showInFolder,click: () => {- shell.openPath(path.join(window.siyuan.config.system.dataDir, notebookId));+ openPath(path.join(window.siyuan.config.system.dataDir, notebookId));}}).element);/// #endifdiff --git a/app/src/util/pathName.ts b/app/src/util/pathName.tsindex 4a2510a933..c5fb866130 100644--- a/app/src/util/pathName.ts+++ b/app/src/util/pathName.ts@@ -21,6 +21,12 @@ export const showFileInFolder = (filePath: string) => {/// #endif};+export const openPath = (filePath: string) => {+ /// #if !BROWSER+ ipcRenderer.send(Constants.SIYUAN_OPEN_PATH, filePath);+ /// #endif+};+export const getIdZoomInByPath = () => {const searchParams = new URLSearchParams(window.location.search);const PWAURL = searchParams.get("url");