mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
33fa1700f8
commit
18415517bb
4 changed files with 26 additions and 11 deletions
|
|
@ -21,6 +21,7 @@ import {
|
|||
import {promiseTransactions} from "./protyle/wysiwyg/transaction";
|
||||
import {initMessage} from "./dialog/message";
|
||||
import {resizeDrag} from "./layout/util";
|
||||
import {setLocalStorage} from "./protyle/util/compatibility";
|
||||
|
||||
class App {
|
||||
constructor() {
|
||||
|
|
@ -81,6 +82,7 @@ class App {
|
|||
}),
|
||||
menus: new Menus()
|
||||
};
|
||||
setLocalStorage();
|
||||
fetchPost("/api/system/getConf", {}, response => {
|
||||
window.siyuan.config = response.data.conf;
|
||||
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages) => {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {setPadding} from "../protyle/ui/initUI";
|
|||
import {newFile} from "../util/newFile";
|
||||
import {Outline} from "./dock/Outline";
|
||||
import {Bookmark} from "./dock/Bookmark";
|
||||
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
import {exportLocalStorage, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
import {Tag} from "./dock/Tag";
|
||||
import {getAllModels, getAllTabs} from "./getAll";
|
||||
import {Asset} from "../asset";
|
||||
|
|
@ -138,7 +138,9 @@ const dockToJSON = (dock: Dock) => {
|
|||
|
||||
export const resetLayout = () => {
|
||||
fetchPost("/api/system/setUILayout", {layout: {}}, () => {
|
||||
window.location.reload();
|
||||
exportLocalStorage(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -157,11 +159,13 @@ export const exportLayout = (reload: boolean, cb?: () => void) => {
|
|||
};
|
||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
||||
fetchPost("/api/system/setUILayout", {layout: layoutJSON, exit: typeof cb !== "undefined"}, () => {
|
||||
if (reload) {
|
||||
window.location.reload();
|
||||
} else if (cb) {
|
||||
cb();
|
||||
}
|
||||
exportLocalStorage(() => {
|
||||
if (reload) {
|
||||
window.location.reload();
|
||||
} else if (cb) {
|
||||
cb();
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {bootSync} from "../dialog/processSystem";
|
|||
import {initMessage} from "../dialog/message";
|
||||
import {goBack} from "./util/MobileBackFoward";
|
||||
import {hideKeyboardToolbar, showKeyboardToolbar} from "./util/showKeyboardToolbar";
|
||||
import {setLocalStorage} from "../protyle/util/compatibility";
|
||||
|
||||
class App {
|
||||
constructor() {
|
||||
|
|
@ -43,6 +44,7 @@ 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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {focusByRange} from "./selection";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
|
||||
export const openByMobile = (uri: string) => {
|
||||
if (!uri) {
|
||||
|
|
@ -13,7 +14,7 @@ export const openByMobile = (uri: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const readText = async () => {
|
||||
export const readText = async () => {
|
||||
if ("android" === window.siyuan.config.system.container && window.JSAndroid) {
|
||||
return window.JSAndroid.readClipboard();
|
||||
}
|
||||
|
|
@ -133,9 +134,15 @@ export const hotKey2Electron = (key: string) => {
|
|||
};
|
||||
|
||||
export const setLocalStorage = () => {
|
||||
|
||||
fetchPost("/api/system/getLocalStorage", undefined, (response) => {
|
||||
Object.keys(response.data).forEach(item => {
|
||||
window.localStorage.setItem(item, response.data[item]);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export const exportLocalStorage = () => {
|
||||
|
||||
export const exportLocalStorage = (cb: () => void) => {
|
||||
fetchPost("/api/system/setLocalStorage", {val: JSON.stringify(localStorage)}, (response) => {
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue