mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
853ba5be3a
commit
e007324aa6
2 changed files with 79 additions and 68 deletions
|
|
@ -47,6 +47,9 @@ class App {
|
||||||
case"progress":
|
case"progress":
|
||||||
progressLoading(data);
|
progressLoading(data);
|
||||||
break;
|
break;
|
||||||
|
case"setLocalStorage":
|
||||||
|
setLocalStorage(data);
|
||||||
|
break;
|
||||||
case "rename":
|
case "rename":
|
||||||
getAllTabs().forEach((tab) => {
|
getAllTabs().forEach((tab) => {
|
||||||
if (tab.headElement) {
|
if (tab.headElement) {
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,17 @@ export const hotKey2Electron = (key: string) => {
|
||||||
return electronKey + key.substr(key.length - 1);
|
return electronKey + key.substr(key.length - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setLocalStorage = () => {
|
export const setLocalStorage = (data?: IWebSocketData) => {
|
||||||
|
if (data) {
|
||||||
|
setDefaultStorage(data)
|
||||||
|
} else {
|
||||||
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
|
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
|
||||||
|
setDefaultStorage(response)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
const setDefaultStorage = (response: IWebSocketData) => {
|
||||||
window.siyuan.storage = response.data;
|
window.siyuan.storage = response.data;
|
||||||
// 历史数据迁移
|
// 历史数据迁移
|
||||||
const defaultStorage: any = {};
|
const defaultStorage: any = {};
|
||||||
|
|
@ -209,8 +218,7 @@ export const setLocalStorage = () => {
|
||||||
window.siyuan.storage[key] = defaultStorage[key];
|
window.siyuan.storage[key] = defaultStorage[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
};
|
|
||||||
|
|
||||||
export const exportLocalStorage = (cb?: () => void) => {
|
export const exportLocalStorage = (cb?: () => void) => {
|
||||||
fetchPost("/api/storage/setLocalStorage", {val: window.siyuan.storage}, () => {
|
fetchPost("/api/storage/setLocalStorage", {val: window.siyuan.storage}, () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue