diff --git a/app/src/index.ts b/app/src/index.ts index 85b0ba128..3a8634b78 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 b4e3f02ed..be91edb21 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 4715bcac3..d45e8fe0e 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(); }