mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 超链接地址更好地兼容本地路径 https://github.com/siyuan-note/siyuan/issues/5980
This commit is contained in:
parent
9a931ee8dc
commit
afa0290ca5
3 changed files with 22 additions and 6 deletions
|
|
@ -472,7 +472,7 @@ export const openBy = (url: string, type: "folder" | "app") => {
|
||||||
let address = "";
|
let address = "";
|
||||||
if ("windows" === window.siyuan.config.system.os) {
|
if ("windows" === window.siyuan.config.system.os) {
|
||||||
// `file://` 协议兼容 Window 平台使用 `/` 作为目录分割线 https://github.com/siyuan-note/siyuan/issues/5681
|
// `file://` 协议兼容 Window 平台使用 `/` 作为目录分割线 https://github.com/siyuan-note/siyuan/issues/5681
|
||||||
address = url.replace("file:///", "").replace("file://\\", "").replace("file://", "").replace("/", "\\");
|
address = url.replace("file:///", "").replace("file://\\", "").replace("file://", "").replace(/\//g, "\\");
|
||||||
} else {
|
} else {
|
||||||
address = url.replace("file://", "");
|
address = url.replace("file://", "");
|
||||||
}
|
}
|
||||||
|
|
@ -482,8 +482,10 @@ export const openBy = (url: string, type: "folder" | "app") => {
|
||||||
shell.openPath(address);
|
shell.openPath(address);
|
||||||
} else if (type === "folder") {
|
} else if (type === "folder") {
|
||||||
if ("windows" === window.siyuan.config.system.os) {
|
if ("windows" === window.siyuan.config.system.os) {
|
||||||
// Windows 端打开本地文件所在位置失效 https://github.com/siyuan-note/siyuan/issues/5808
|
if (!address.startsWith("\\\\")) { // \\ 开头的路径是 Windows 网络共享路径 https://github.com/siyuan-note/siyuan/issues/5980
|
||||||
address = address.replace(/\\\\/g, "\\");
|
// Windows 端打开本地文件所在位置失效 https://github.com/siyuan-note/siyuan/issues/5808
|
||||||
|
address = address.replace(/\\\\/g, "\\");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
shell.showItemInFolder(address);
|
shell.showItemInFolder(address);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,19 @@ export const isLocalPath = (link: string) => {
|
||||||
if (!link) {
|
if (!link) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return link.startsWith("assets/") || link.startsWith("file://") ||
|
|
||||||
0 < link.indexOf(":/") || link.startsWith("\\\\"); // 超链接地址更好地兼容本地路径 https://github.com/siyuan-note/siyuan/issues/5980
|
link = link.trim()
|
||||||
|
if (1 > link.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
link = link.toLowerCase()
|
||||||
|
if (link.startsWith("assets/") || link.startsWith("file://") || link.startsWith("\\\\") /* Windows 网络共享路径 */) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
const colonIdx = link.indexOf(":")
|
||||||
|
return 1 === colonIdx // 冒号前面只有一个字符认为是 Windows 盘符而不是网络协议
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pathPosix = () => {
|
export const pathPosix = () => {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,10 @@ func InsertLocalAssets(id string, assetPaths []string, isUpload bool) (succMap m
|
||||||
fName += ext
|
fName += ext
|
||||||
baseName := fName
|
baseName := fName
|
||||||
if gulu.File.IsDir(p) || !isUpload {
|
if gulu.File.IsDir(p) || !isUpload {
|
||||||
succMap[baseName] = "file://" + p
|
if !strings.HasPrefix(p, "\\\\") {
|
||||||
|
p = "file://" + p
|
||||||
|
}
|
||||||
|
succMap[baseName] = p
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue