Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
3 changes: 2 additions & 1 deletion app/src/config/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -259,7 +260,7 @@ ${checkUpdateHTML}
if (url.startsWith("http")) {
shell.openExternal(url);
} else {
shell.openPath(url);
openPath(url);
}
/// #else
window.open(url);
Expand Down
7 changes: 4 additions & 3 deletions app/src/config/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -233,13 +234,13 @@ export const appearance = {
});
/// #if !BROWSER
appearance.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"));
});
/// #endif
appearance.element.querySelectorAll("select").forEach(item => {
Expand Down
5 changes: 3 additions & 2 deletions app/src/config/bazaar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -625,9 +626,9 @@ export const bazaar = {
/// #if !BROWSER
const 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));
}
/// #endif
event.preventDefault();
Expand Down
1 change: 1 addition & 0 deletions app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 3 additions & 3 deletions app/src/editor/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {getInstanceById, getWndByLayout, pdfIsLoading, setPanelFocus} from "../l
import {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";
Expand Down Expand Up @@ -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);
}
Expand All @@ -713,7 +713,7 @@ export const openBy = (url: string, type: "folder" | "app") => {
// 拖入文件名包含 `)` 、`(` 的文件以 `file://` 插入后链接解析错误 https://github.com/siyuan-note/siyuan/issues/5786
address = 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/5980
Expand Down
6 changes: 3 additions & 3 deletions app/src/menus/navigation.ts
Original file line number Diff line number Diff line change
@@ -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";
/// #endif
import {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";
Expand Down Expand Up @@ -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);
/// #endif
Expand Down
6 changes: 6 additions & 0 deletions app/src/util/pathName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down