Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/7713

Vanessadbff939601d5
diff --git a/app/src/index.ts b/app/src/index.ts
index 85b0ba1286..3a8634b787 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -25,6 +25,7 @@ import {resizeDrag} from "./layout/util";
import {getAllTabs} from "./layout/getAll";
import {getLocalStorage} from "./protyle/util/compatibility";
import {updateEditModeElement} from "./layout/topBar";
+import {getSearch} from "./util/functions";
class App {
constructor() {
@@ -171,3 +172,13 @@ class App {
}
new App();
+window.openFileByURL = (openURL) => {
+ if (openURL && /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) {
+ openFileById({
+ id: openURL.substr(16, 22),
+ action:getSearch("focus", openURL) === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
+ });
+ return true;
+ }
+ return false;
+};
diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts
index b4e3f02ed1..be91edb210 100644
--- a/app/src/mobile/util/initFramework.ts
+++ b/app/src/mobile/util/initFramework.ts
@@ -131,10 +131,8 @@ export const initFramework = () => {
});
initEditorName();
if (getOpenNotebookCount() > 0) {
- if (window.JSAndroid) {
- if (window.openFileByURL(window.JSAndroid.getBlockURL())) {
- return;
- }
+ if (window.JSAndroid && window.openFileByURL(window.JSAndroid.getBlockURL())) {
+ return;
}
const openId = getSearch("id");
if (openId) {
diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts
index 4715bcac31..d45e8fe0e0 100644
--- a/app/src/util/onGetConfig.ts
+++ b/app/src/util/onGetConfig.ts
@@ -149,6 +149,9 @@ export const onGetConfig = (isStart: boolean) => {
window.siyuan.emojis = response.data as IEmoji[];
try {
JSONToLayout(isStart);
+ if (window.JSAndroid) {
+ window.openFileByURL(window.JSAndroid.getBlockURL())
+ }
} catch (e) {
resetLayout();
}