Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/pull/17843

Vanessaa1e16b283f33
diff --git a/app/src/editor/openLink.ts b/app/src/editor/openLink.ts
index 2a4b78034a..5e57db3dd5 100644
--- a/app/src/editor/openLink.ts
+++ b/app/src/editor/openLink.ts
@@ -1,4 +1,4 @@
-import {isLocalPath, isSiYuanUriProtocol, parseSiYuanUriBlockInfo, pathPosix} from "../util/pathName";
+import {isLocalPath, isSiYuanUriProtocol, parseSiYuanUriInfo, pathPosix} from "../util/pathName";
/// #if !BROWSER
import {shell, ipcRenderer} from "electron";
/// #endif
@@ -15,8 +15,8 @@ import {openMobileFileById} from "../mobile/editor";
import type {App} from "../index";
-export const processSiYuanUriBlocks = (app: App, uriObj: URL): boolean => {
- const blockInfo = parseSiYuanUriBlockInfo(uriObj);
+const processSiYuanUriBlocks = (app: App, uriObj: URL): boolean => {
+ const blockInfo = parseSiYuanUriInfo(uriObj);
if (blockInfo != null) {
const {id, focus} = blockInfo;
window.siyuan.editorIsFullscreen = blockInfo.fullscreen;
@@ -52,7 +52,7 @@ export const processSiYuanUriBlocks = (app: App, uriObj: URL): boolean => {
return false;
};
-export const processSiYuanUriPlugins = (app: App, uriObj: URL): boolean => {
+const processSiYuanUriPlugins = (app: App, uriObj: URL): boolean => {
const pluginNameOrTabType: string | null = (() => {
const name = uriObj.pathname.split("/")[1];
if (!name) {
diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.ts
index 8ca5e09162..8004fb9206 100644
--- a/app/src/util/pathName.ts
+++ b/app/src/util/pathName.ts
@@ -49,7 +49,7 @@ export const isSiYuanUriProtocol = (uri: URL | string | null | undefined): boole
* @param uri - the siyuan block uri to parse
* @returns the block id and other info, or null if the uri is not a valid siyuan block uri
*/
-export const parseSiYuanUriBlockInfo = (uri: URL | string | null | undefined): ISiYuanUriBlockInfo | null => {
+export const parseSiYuanUriInfo = (uri: URL | string | null | undefined): ISiYuanUriBlockInfo | null => {
try {
if (uri == null) return null;
@@ -76,9 +76,9 @@ export const getIdZoomInByPath = () => {
id: "",
isZoomIn: false,
};
-
- if (searchParams.has("url")) {
- const dataInfo = parseSiYuanUriBlockInfo(searchParams.get("url"));
+ const PWAURL = searchParams.get("url");
+ if (/^web\+siyuan:\/\/blocks\/\d{14}-\w{7}/.test(PWAURL)) {
+ const dataInfo = parseSiYuanUriInfo(PWAURL);
if (dataInfo != null) {
data.id = dataInfo.id;
data.isZoomIn = dataInfo.focus;
@@ -88,7 +88,7 @@ export const getIdZoomInByPath = () => {
}
if (window.JSAndroid) {
- const dataInfo = parseSiYuanUriBlockInfo(window.JSAndroid.getBlockURL());
+ const dataInfo = parseSiYuanUriInfo(window.JSAndroid.getBlockURL());
if (dataInfo != null) {
data.id = dataInfo.id;
data.isZoomIn = dataInfo.focus;