This commit is contained in:
Vanessa 2022-12-31 22:14:42 +08:00
parent 7688733364
commit 4ee566cbd9
30 changed files with 153 additions and 163 deletions

View file

@ -14,7 +14,7 @@ import {hideElements} from "../protyle/ui/hideElements";
import {pushBack} from "./util/MobileBackFoward";
export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) => {
localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({id, action}));
window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id, action};
if (window.siyuan.mobileEditor) {
hideElements(["toolbar", "hint", "util"], window.siyuan.mobileEditor.protyle);
if (window.siyuan.mobileEditor.protyle.contentElement.classList.contains("fn__none")) {

View file

@ -44,10 +44,10 @@ class App {
window.siyuan.menus.menu.remove();
}
});
setLocalStorage();
fetchPost("/api/system/getConf", {}, confResponse => {
confResponse.data.conf.keymap = Constants.SIYUAN_KEYMAP;
window.siyuan.config = confResponse.data.conf;
setLocalStorage();
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
window.siyuan.languages = lauguages;
document.title = window.siyuan.languages.siyuanNote;

View file

@ -12,10 +12,10 @@ const forwardStack: IBackStack[] = [];
const focusStack = (backStack: IBackStack) => {
const protyle = window.siyuan.mobileEditor.protyle;
localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({
window.siyuan.storage[Constants.LOCAL_DOCINFO] = {
id: backStack.id,
action: backStack.callback,
}));
};
hideElements(["toolbar", "hint", "util"], window.siyuan.mobileEditor.protyle);
if (protyle.contentElement.classList.contains("fn__none")) {
setEditMode(protyle, "wysiwyg");

View file

@ -127,7 +127,7 @@ export const initFramework = () => {
});
initEditorName();
if (getOpenNotebookCount() > 0) {
const localDoc = JSON.parse(localStorage.getItem(Constants.LOCAL_DOCINFO) || '{"id": ""}');
const localDoc = window.siyuan.storage[Constants.LOCAL_DOCINFO];
fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => {
if (existResponse.data) {
openMobileFileById(localDoc.id, localDoc.action);

View file

@ -1,5 +1,5 @@
import {fetchPost} from "../../util/fetch";
import {getEventName, openByMobile, writeText} from "../../protyle/util/compatibility";
import {exportLocalStorage, getEventName, openByMobile, writeText} from "../../protyle/util/compatibility";
import {popSearch} from "./search";
import {initAppearance} from "../settings/appearance";
import {closePanel} from "./closePanel";
@ -172,7 +172,9 @@ ${accountHTML}
event.stopPropagation();
break;
} else if (target.id === "menuSafeQuit") {
exitSiYuan();
exportLocalStorage(() => {
exitSiYuan();
});
event.preventDefault();
event.stopPropagation();
break;
@ -439,8 +441,10 @@ ${accountHTML}
event.stopPropagation();
break;
} else if (target.id === "menuLock") {
fetchPost("/api/system/logoutAuth", {}, () => {
window.location.href = "/";
exportLocalStorage(() => {
fetchPost("/api/system/logoutAuth", {}, () => {
window.location.href = "/";
});
});
event.preventDefault();
event.stopPropagation();
@ -457,6 +461,7 @@ ${accountHTML}
event.stopPropagation();
break;
} else if (target.id === "menuSyncNow") {
exportLocalStorage();
syncGuide();
event.preventDefault();
event.stopPropagation();

View file

@ -37,17 +37,14 @@ export const toolbarSearchEvent = () => {
onRecentBlocks(response.data.blocks, response.data.matchedRootCount,response.data.matchedBlockCount);
});
}
const localData = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEDATA) || "{}");
localData.k = inputElement.value;
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(localData));
window.siyuan.storage[Constants.LOCAL_SEARCHEDATA].k = inputElement.value;
}, Constants.TIMEOUT_SEARCH);
};
const initToolbarSearch = () => {
const inputElement = document.getElementById("toolbarSearch") as HTMLInputElement;
inputElement.focus();
const localData = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEDATA) || "{}");
inputElement.value = localData.k || "";
inputElement.value = window.siyuan.storage[Constants.LOCAL_SEARCHEDATA].k;
inputElement.addEventListener("compositionend", (event: InputEvent) => {
if (event && event.isComposing) {
return;