mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 02:21:38 +08:00
This commit is contained in:
parent
d2e6198e21
commit
c79048ad73
@ -441,7 +441,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB
|
||||
}
|
||||
}
|
||||
if (window.siyuan.mobileEditor) {
|
||||
window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({
|
||||
localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({
|
||||
id,
|
||||
action: id === protyle.block.rootID ? [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT] : [Constants.CB_GET_ALL]
|
||||
}));
|
||||
|
@ -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]) => {
|
||||
window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({id, action}));
|
||||
localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({id, action}));
|
||||
if (window.siyuan.mobileEditor) {
|
||||
hideElements(["toolbar", "hint", "util"], window.siyuan.mobileEditor.protyle);
|
||||
if (window.siyuan.mobileEditor.protyle.contentElement.classList.contains("fn__none")) {
|
||||
|
@ -12,7 +12,7 @@ const forwardStack: IBackStack[] = [];
|
||||
|
||||
const focusStack = (backStack: IBackStack) => {
|
||||
const protyle = window.siyuan.mobileEditor.protyle;
|
||||
window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({
|
||||
localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({
|
||||
id: backStack.id,
|
||||
action: backStack.callback,
|
||||
}));
|
||||
|
@ -127,7 +127,7 @@ export const initFramework = () => {
|
||||
});
|
||||
initEditorName();
|
||||
if (getOpenNotebookCount() > 0) {
|
||||
const localDoc = JSON.parse(window.localStorage.getItem(Constants.LOCAL_DOCINFO) || '{"id": ""}');
|
||||
const localDoc = JSON.parse(localStorage.getItem(Constants.LOCAL_DOCINFO) || '{"id": ""}');
|
||||
fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => {
|
||||
if (existResponse.data) {
|
||||
openMobileFileById(localDoc.id, localDoc.action);
|
||||
|
@ -135,21 +135,20 @@ export const hotKey2Electron = (key: string) => {
|
||||
|
||||
export const setLocalStorage = () => {
|
||||
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
|
||||
localStorage.clear();
|
||||
if (response.data) {
|
||||
Object.keys(response.data).forEach(item => {
|
||||
window.localStorage.setItem(item, response.data[item]);
|
||||
localStorage.setItem(item, response.data[item]);
|
||||
});
|
||||
} else {
|
||||
localStorage.clear();
|
||||
}
|
||||
});
|
||||
|
||||
// 复写 localStorage
|
||||
window.__localStorage__setItem = localStorage.setItem
|
||||
window.__localStorage__removeItem = localStorage.removeItem
|
||||
localStorage.setItem = function (key, value) {
|
||||
window.__localStorage__setItem.call(this, key, value)
|
||||
fetchPost("/api/storage/setLocalStorageVal", {key, value});
|
||||
localStorage.setItem = function (key, val) {
|
||||
window.__localStorage__setItem.call(this, key, val)
|
||||
fetchPost("/api/storage/setLocalStorageVal", {key, val});
|
||||
}
|
||||
localStorage.removeItem = function (key) {
|
||||
window.__localStorage__removeItem.call(this, key)
|
||||
@ -158,7 +157,7 @@ export const setLocalStorage = () => {
|
||||
};
|
||||
|
||||
export const exportLocalStorage = (cb: () => void) => {
|
||||
fetchPost("/api/storage/setLocalStorage", {val: window.localStorage}, () => {
|
||||
fetchPost("/api/storage/setLocalStorage", {val: localStorage}, () => {
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
@ -119,7 +119,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) =>
|
||||
replaceInnerHTML += "\n```";
|
||||
}
|
||||
const languageIndex = replaceInnerHTML.indexOf("```") + 3;
|
||||
replaceInnerHTML = replaceInnerHTML.substring(0, languageIndex) + (window.localStorage["local-codelang"] || "") + replaceInnerHTML.substring(languageIndex);
|
||||
replaceInnerHTML = replaceInnerHTML.substring(0, languageIndex) + (localStorage["local-codelang"] || "") + replaceInnerHTML.substring(languageIndex);
|
||||
|
||||
editableElement.innerHTML = replaceInnerHTML;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
|
||||
const opElement = element.querySelector('.b3-select[data-type="opselect"]') as HTMLSelectElement;
|
||||
const typeElement = element.querySelector('.b3-select[data-type="typeselect"]') as HTMLSelectElement;
|
||||
const notebookElement = element.querySelector('.b3-select[data-type="notebookselect"]') as HTMLSelectElement;
|
||||
window.localStorage.setItem(Constants.LOCAL_HISTORYNOTEID, notebookElement.value);
|
||||
localStorage.setItem(Constants.LOCAL_HISTORYNOTEID, notebookElement.value);
|
||||
const docElement = element.querySelector('.history__text[data-type="docPanel"]');
|
||||
const assetElement = element.querySelector('.history__text[data-type="assetPanel"]');
|
||||
const mdElement = element.querySelector('.history__text[data-type="mdPanel"]') as HTMLTextAreaElement;
|
||||
|
@ -25,7 +25,7 @@ export const newDailyNote = () => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
const localNotebookId = window.localStorage.getItem(Constants.LOCAL_DAILYNOTEID);
|
||||
const localNotebookId = localStorage.getItem(Constants.LOCAL_DAILYNOTEID);
|
||||
if (localNotebookId && getNotebookName(localNotebookId) && !isMobile()) {
|
||||
fetchPost("/api/filetree/createDailyNote", {
|
||||
notebook:localNotebookId,
|
||||
@ -56,7 +56,7 @@ export const newDailyNote = () => {
|
||||
});
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
const notebook = selectElement.value;
|
||||
window.localStorage.setItem(Constants.LOCAL_DAILYNOTEID, notebook);
|
||||
localStorage.setItem(Constants.LOCAL_DAILYNOTEID, notebook);
|
||||
fetchPost("/api/filetree/createDailyNote", {
|
||||
notebook,
|
||||
app: Constants.SIYUAN_APPID,
|
||||
|
@ -271,7 +271,7 @@ const initBar = () => {
|
||||
notebook: item.id,
|
||||
app: Constants.SIYUAN_APPID,
|
||||
});
|
||||
window.localStorage.setItem(Constants.LOCAL_DAILYNOTEID, item.id);
|
||||
localStorage.setItem(Constants.LOCAL_DAILYNOTEID, item.id);
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user