mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🐛 local storage
This commit is contained in:
parent
24bc7bec01
commit
722f71803e
1 changed files with 10 additions and 4 deletions
|
|
@ -135,11 +135,15 @@ export const hotKey2Electron = (key: string) => {
|
|||
|
||||
export const setLocalStorage = () => {
|
||||
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
|
||||
localStorage.clear();
|
||||
if (response.data) {
|
||||
localStorage.clear();
|
||||
Object.keys(response.data).forEach(item => {
|
||||
localStorage.setItem(item, response.data[item]);
|
||||
if (item !== "setItem" && item !== "removeItem") {
|
||||
localStorage.setItem(item, response.data[item]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
exportLocalStorage();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -156,8 +160,10 @@ export const setLocalStorage = () => {
|
|||
};
|
||||
};
|
||||
|
||||
export const exportLocalStorage = (cb: () => void) => {
|
||||
export const exportLocalStorage = (cb?: () => void) => {
|
||||
fetchPost("/api/storage/setLocalStorage", {val: localStorage}, () => {
|
||||
cb();
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue