diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index 5e50ee6b2..ad4773386 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -191,9 +191,12 @@ export const transactionError = (data: { code: number, data: string }) => { let progressStatusTimeoutId: number; export const progressStatus = (data: IWebSocketData) => { + const statusElement = document.querySelector("#status") as HTMLElement; + if (!statusElement) { + return; + } if (isMobile()) { clearTimeout(progressStatusTimeoutId); - const statusElement = document.querySelector("#status") as HTMLElement; statusElement.innerHTML = data.msg; statusElement.classList.remove("status--hide"); if (document.querySelector("#keyboardToolbar").classList.contains("fn__none")) { @@ -206,7 +209,7 @@ export const progressStatus = (data: IWebSocketData) => { }, 6000); return; } - document.querySelector("#status .status__msg").innerHTML = data.msg; + statusElement.querySelector(".status__msg").innerHTML = data.msg; }; export const progressLoading = (data: IWebSocketData) => { diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts index f93c43a32..f808107e6 100644 --- a/app/src/mobile/util/initFramework.ts +++ b/app/src/mobile/util/initFramework.ts @@ -128,30 +128,6 @@ export const initFramework = () => { closePanel(); }); initEditorName(); - if (getOpenNotebookCount() > 0) { - const openId = getSearch("id"); - if (openId) { - openMobileFileById(openId, - getSearch("focus") === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]); - } else { - const localDoc = window.siyuan.storage[Constants.LOCAL_DOCINFO]; - fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => { - if (existResponse.data) { - openMobileFileById(localDoc.id, localDoc.action); - } else { - fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => { - if (response.data.length !== 0) { - openMobileFileById(response.data[0].id, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]); - } else { - setEmpty(); - } - }); - } - }); - } - } else { - setEmpty(); - } if (window.siyuan.config.newbie) { mountHelp(); } @@ -160,6 +136,36 @@ export const initFramework = () => { transactionTipElement.querySelector(".b3-button").addEventListener(getEventName(), () => { syncGuide(); }); + if (getOpenNotebookCount() > 0) { + const openURL = window.JSAndroid.getBlockURL(); + if (openURL && !/^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) { + openMobileFileById(openURL.substr(16, 22), + getSearch("focus", openURL) === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]); + return; + } + const openId = getSearch("id"); + if (openId) { + openMobileFileById(openId, + getSearch("focus") === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]); + return; + } + const localDoc = window.siyuan.storage[Constants.LOCAL_DOCINFO]; + fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => { + if (existResponse.data) { + openMobileFileById(localDoc.id, localDoc.action); + } else { + fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => { + if (response.data.length !== 0) { + openMobileFileById(response.data[0].id, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]); + } else { + setEmpty(); + } + }); + } + }); + return + } + setEmpty(); }; const initEditorName = () => { diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 63ef2880d..c2b72c958 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -42,6 +42,7 @@ interface Window { writeClipboard(text: string): void writeImageClipboard(uri: string): void readClipboard(): string + getBlockURL(): string } goBack(): void