diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index e5df3ccd4..ca4850405 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -590,7 +590,6 @@ export const zoomOut = (options: { if (window.siyuan.mobile?.editor) { window.siyuan.storage[Constants.LOCAL_DOCINFO] = { id: options.id, - action: options.id === options.protyle.block.rootID ? [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT] : [Constants.CB_GET_ALL] }; setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]); if (options.isPushBack) { diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts index 572c882a4..6b65ba274 100644 --- a/app/src/mobile/editor.ts +++ b/app/src/mobile/editor.ts @@ -20,7 +20,7 @@ export const getCurrentEditor = () => { }; export const openMobileFileById = (app: App, id: string, action = [Constants.CB_GET_HL]) => { - window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id, action}; + window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id}; setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]); if (window.siyuan.mobile.editor) { hideElements(["toolbar", "hint", "util"], window.siyuan.mobile.editor.protyle); @@ -48,9 +48,6 @@ export const openMobileFileById = (app: App, id: string, action = [Constants.CB_ return; } if (window.siyuan.mobile.editor) { - if (document.getElementById("empty").classList.contains("fn__none")) { - saveScroll(window.siyuan.mobile.editor.protyle); - } pushBack(); addLoading(window.siyuan.mobile.editor.protyle); fetchPost("/api/filetree/getDoc", { diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 41ef96063..c7293a2d4 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -22,6 +22,7 @@ import {initRightMenu} from "./menu"; import {openChangelog} from "../boot/openChangelog"; import {registerServiceWorker} from "../util/serviceWorker"; import {afterLoadPlugin, loadPlugins} from "../plugin/loader"; +import {saveScroll} from "../protyle/scroll/saveScroll"; class App { public plugins: import("../plugin").Plugin[] = []; @@ -59,6 +60,12 @@ class App { window.siyuan.menus.menu.remove(); } }); + window.addEventListener("beforeunload", () => { + saveScroll(window.siyuan.mobile.editor.protyle); + }, false); + window.addEventListener("pagehide", () => { + saveScroll(window.siyuan.mobile.editor.protyle); + }, false); fetchPost("/api/system/getConf", {}, async (confResponse) => { confResponse.data.conf.keymap = Constants.SIYUAN_KEYMAP; window.siyuan.config = confResponse.data.conf; diff --git a/app/src/mobile/util/MobileBackFoward.ts b/app/src/mobile/util/MobileBackFoward.ts index 441f18447..24dbd8062 100644 --- a/app/src/mobile/util/MobileBackFoward.ts +++ b/app/src/mobile/util/MobileBackFoward.ts @@ -19,7 +19,6 @@ const focusStack = (backStack: IBackStack) => { const protyle = getCurrentEditor().protyle; window.siyuan.storage[Constants.LOCAL_DOCINFO] = { id: backStack.id, - action: backStack.callback, }; setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]); hideElements(["toolbar", "hint", "util"], protyle); diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts index 053aaad5c..219a3f459 100644 --- a/app/src/mobile/util/initFramework.ts +++ b/app/src/mobile/util/initFramework.ts @@ -151,7 +151,7 @@ export const initFramework = (app: App) => { const localDoc = window.siyuan.storage[Constants.LOCAL_DOCINFO]; fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => { if (existResponse.data) { - openMobileFileById(app, localDoc.id, localDoc.action); + openMobileFileById(app, localDoc.id, [Constants.CB_GET_SCROLL]); } else { fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => { if (response.data.length !== 0) { diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index 49be79a4d..4976a014c 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -183,7 +183,6 @@ export const getLocalStorage = (cb: () => void) => { }; defaultStorage[Constants.LOCAL_DOCINFO] = { id: "", - action: [] }; defaultStorage[Constants.LOCAL_FONTSTYLES] = []; defaultStorage[Constants.LOCAL_SEARCHDATA] = {