From dcd4e3a3829e8d18cdb0e751c3ea1c3bf2ade40d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 19 Aug 2022 23:20:30 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20`file://`=20=E5=8D=8F=E8=AE=AE=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=20Window=20=E5=B9=B3=E5=8F=B0=E4=BD=BF=E7=94=A8=20`/`?= =?UTF-8?q?=20=E4=BD=9C=E4=B8=BA=E7=9B=AE=E5=BD=95=E5=88=86=E5=89=B2?= =?UTF-8?q?=E7=BA=BF=20Fix=20https://github.com/siyuan-note/siyuan/issues/?= =?UTF-8?q?5681?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/editor/util.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index 04de8055c..70f76f6e9 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -18,11 +18,7 @@ import {shell} from "electron"; import {pushBack} from "../util/backForward"; import {Asset} from "../asset"; import {Layout} from "../layout"; -import { - hasClosestBlock, - hasClosestByAttribute, - hasClosestByClassName, -} from "../protyle/util/hasClosest"; +import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName,} from "../protyle/util/hasClosest"; import {getPreviousHeading} from "../protyle/wysiwyg/getBlock"; import {lockFile, setTitle} from "../dialog/processSystem"; import {zoomOut} from "../menus/protyle"; @@ -451,7 +447,13 @@ export const openBy = (url: string, type: "folder" | "app") => { }); return; } else { - address = url.replace("file://", ""); + address = url.replace("file:///", ""); + address = address.replace("file://", ""); + address = address.replace("file://\\", ""); + if ("windows" === window.siyuan.config.system.os) { + // `file://` 协议兼容 Window 平台使用 `/` 作为目录分割线 https://github.com/siyuan-note/siyuan/issues/5681 + address = address.replace("/", "\\"); + } } if (type === "app") {