mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +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":
|
||||
progressLoading(data);
|
||||
break;
|
||||
case"setLocalStorage":
|
||||
setLocalStorage(data);
|
||||
break;
|
||||
case "rename":
|
||||
getAllTabs().forEach((tab) => {
|
||||
if (tab.headElement) {
|
||||
|
|
|
|||
|
|
@ -139,8 +139,17 @@ export const hotKey2Electron = (key: string) => {
|
|||
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) => {
|
||||
setDefaultStorage(response)
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
const setDefaultStorage = (response: IWebSocketData) => {
|
||||
window.siyuan.storage = response.data;
|
||||
// 历史数据迁移
|
||||
const defaultStorage: any = {};
|
||||
|
|
@ -209,8 +218,7 @@ export const setLocalStorage = () => {
|
|||
window.siyuan.storage[key] = defaultStorage[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const exportLocalStorage = (cb?: () => void) => {
|
||||
fetchPost("/api/storage/setLocalStorage", {val: window.siyuan.storage}, () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue