This commit is contained in:
Vanessa 2022-06-01 10:12:14 +08:00
parent 66ee7d4715
commit 0337d12bef
6 changed files with 20 additions and 14 deletions

View file

@ -12,6 +12,7 @@ import {lockFile} from "../dialog/processSystem";
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
export const openMobileFileById = (id: string, hasContext?: boolean, action = [Constants.CB_GET_HL], pushStack = true) => {
window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({id, hasContext, action}));
if (window.siyuan.mobileEditor) {
let blockElement;
Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {
@ -83,7 +84,6 @@ export const openMobileFileById = (id: string, hasContext?: boolean, action = [C
(document.getElementById("toolbarName") as HTMLInputElement).value = data.data.rootTitle;
setEditor();
closePanel();
window.localStorage.setItem(Constants.LOCAL_DOC, id);
if (pushStack) {
window.siyuan.backStack.push({
id,

View file

@ -91,14 +91,14 @@ export const initFramework = () => {
});
initEditorName();
if (getOpenNotebookCount() > 0) {
const id = window.localStorage.getItem(Constants.LOCAL_DOC) || "";
fetchPost("/api/block/checkBlockExist", {id}, existResponse => {
const localDoc = JSON.parse(window.localStorage.getItem(Constants.LOCAL_DOCINFO) || '{"id": ""}');
fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => {
if (existResponse.data) {
openMobileFileById(id);
openMobileFileById(localDoc.id, localDoc.hasContext, localDoc.action);
} else {
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
if (response.data.length !== 0) {
openMobileFileById(response.data[0].id);
openMobileFileById(response.data[0].id, true);
} else {
setEmpty();
}

View file

@ -77,7 +77,7 @@ export const popSearch = (modelElement: HTMLElement, modelMainElement: HTMLEleme
preventScroll(window.siyuan.mobileEditor.protyle);
}
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openMobileFileById(id, !foldResponse.data);
openMobileFileById(id, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]);
});
closePanel();
event.preventDefault();