🎨 改进 保持移动端界面打开位置

This commit is contained in:
Vanessa 2023-07-04 12:24:02 +08:00
parent 073e738389
commit 23ebc726ac
6 changed files with 9 additions and 8 deletions

View file

@ -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) {

View file

@ -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", {

View file

@ -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;

View file

@ -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);

View file

@ -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) {

View file

@ -183,7 +183,6 @@ export const getLocalStorage = (cb: () => void) => {
};
defaultStorage[Constants.LOCAL_DOCINFO] = {
id: "",
action: []
};
defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
defaultStorage[Constants.LOCAL_SEARCHDATA] = {